objective-c

AutoreleasePool in UIApplication Loop

Hello, i have an app that starts with the default code for iPhone Apps: NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, nil); [pool release]; Cause my app never stopps, the [pool release] is never called. Has the standard UI loop of UIApplicationMain an own AutoreleasePool ...

NOOB Memory Problem - EXC_BAD_ACCESS (OBJ-C/iPhone)

I have been banging my head against the wall for a couple days and need some help. I have a feeling that I am doing something really silly here, but I cannot find the issue. This is the controller for a table view. I put the SQL in line to simplify it as part of the troubleshooting of this error. Normally, it would be in an accessor ...

Objective-C: when does an assigned object get deallocated

If I have a instance method and within this method I do something like this: NSString *peopleString = [peopleList componentsJoinedByString: @", "]; ... UILabel *likeLabel = [[UILabel alloc] initWithFrame:CGRectMake(16.0+6.0f, 4.0f, 252.0f, 12.0f)]; [likeLabel setText:peopleString]; [likeLabel setFont:[UIFont fontWithName:@"Arial" size:1...

Core Data - JSON (TouchJSON) on iPhone

I have the following code which seems to go on indefinitely until the app crashes. It seems to happen with the recursion in the datastructureFromManagedObject method. I suspect that this method: 1) looks at the first managed object and follows any relationship property recursively. 2) examines the object at the other end of the relation...

How do you check to see if a variable has changed every second or less in objective c?

I am using an if statement to check the value of a BOOLEAN when i click on a button. When the button is clicked if the value is false i want to display a UIActivityIndicator and if the value is true i want to push the new view. I can do this fine but i want the view to change automatically when the BOOLEAN Becomes true if the user has al...

Xcode - EXEC_BAD_ACCESS when concatenting a large string.

I'm getting a EXEC_BAD_ACCESS when concatenting a large string. I've read from a feed and to create my webview I build up my string like: NSString *pageData = @"<h1>header</h1>"; pageData = [pageData stringByAppendingFormat@"<p>"]; pageData = [pageData stringByAppendingFormat@"self.bodyText"]; pageData = [pageData stringByAppendingFor...

Objective-C : Sorting NSMutableArray containing NSMutableArrays

Hi ! I'm currently using NSMutableArrays in my developments to store some data taken from an HTTP Servlet. Everything is fine since now I have to sort what is in my array. This is what I do : NSMutableArray *array = [[NSMutableArray arrayWithObjects:nil] retain]; [array addObject:[NSArray arrayWithObjects: "Label 1", 1, nil]]; [array...

Objective C: Create arrays from first array based on value

I have an array of strings that are comma separated such as: Steve Jobs,12,CA Fake Name,21,CA Test Name,22,CA Bill Gates,44,WA Bill Nye,21,OR I have those values in an NSScanner object so that I can loop through the values and get each comma seperated value using objectAtIndex. So, what I would like to do, is group the array items in...

Connect iPhone to a Web Service?

New to iPhone development and working through exercises and examples to get me up to speed. Does anyone have a good reference for connecting an iPhone app to a website/webservice and push/pull data? ...

iPhone / Objective-C: NSMutableArray writeToFile won't write to file. Always returns NO

I'm trying to serialize two NSMutableArrays of NSObjects that implement the NSCoding protocol. However it works for one (stacks) and not the other (cards). I have the following block of code: -(void) saveCards { NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString* document...

Duplicate conflicting frameworks in cocoa plug-ins

I am currently writing a plug-in framework for my application. I would like to be able to release plugins without having to update my application, and I intend on making the framework available for third party plugins. I am currently running into issues when two plugins ship with identical frameworks. When the plugins are loaded the runt...

Saving data in custom class via AppDelegate

I can't seem to save data to a custom instance object in my AppDelegate. My custom class is very simple and is as follows: Person.h ... @interface Person : NSObject { int _age; } - (void) setAge: (int) age; - (int) age; @end Person.m #import "Person.h" @implementation Person - (void) setAge:(int) age { _age = age; } - (in...

NSCharacterSet: How do I add "_" to alphanumericCharacterSet text restriction?

Building an NSCharacter set to restrict a UITextField for entering user names. I want the user to be able to also enter an underscore (so [A-Za-z0-9_]) but alphanumericCharacterSet does not include it. Is there a way to specify a range like that in short form? I see + (id)characterSetWithRange:(NSRange)aRange, but I'm not really understa...

How to update SQLite DB on iPhone app update?

I currently have an iPhone app in the iTunes app store that uses a SQLite database as a datastore. The user can sync the app against a web service and data that is returned is then stored in the SQLite database. The user can also insert new items into the database and sync their changes back up to the web service. When a connection is o...

Objective-C Basic class related question, retaining the value of a specific object using a class file

Members, scholars, code gurus. My background is far from any computer programming thus my question may seems basic and somewhat trivial to you. Nevertheless it seems that I can't put my head around it. I have googled and searched for the answer, just to get myself confused even more. With that, I would kindly ask for a simple explanation...

Remove tab from UITabBar without UITabBarController

I'm using a UITabBar without a controller. I want to remove tabs from the UITabBar if certain conditions are met. For example, my UITabBar has 4 tabs set up in interface builder. If the scores module is not enabled at compile time, it should remove the scores tab. // defined in IB #define kTabScores 1 UITabBar *_tabBar; // in viewDi...

Problem with Core Data - EXC_BAD_ACCESS

I'm using the following code and I'm getting an EXC_BAD_ACCESS when trying to get the count of objects - anyone have any idea why? Oddly enough, the error only happens if the count should be one or greater, if there are no objects it seems to work fine (it outputs null). NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NS...

How to make an mutable C array for this data type?

There's this instance variable in my objective-c class: ALuint source; I need to have an mutable array of OpenAL Sources, so in this case probably I need a mutable C-array. But how would I create one? There are many questions regarding that: 1) How to create an mutable C-array? 2) How to add something to that mutable C-array? 3) H...

Where are constant NSStrings allocated?

I understand that constant CStrings are allocated statically, rather than on the heap. I also noticed that constant NSStrings have an infinite retain count. Does it hold true that constant NSStrings are also allocated statically, rather than on the heap? ...

How to select one NSCell in an NSTableView?

I have a small NSTableView with a checkbox. Whenever the checkbox is not checked, I want one of the adjacent NSCells to be grayed out and inaccessible. However, I can't figure out how to address only one specific cell. -dataCellForRow of NSTableColumn always changes the template cell for the whole table column. How can I access one sin...