objective-c

Deallocating NSMutableArray objects

This is my 'tick' function: - (void) tick: (ccTime) dt { NSLog(@"%d",ticker); if(fbut.Adown == YES && ticker > 4)//fbut is a button { elayer = [[effectsLayer alloc] init]; // each effectlayer draws a //projectile that moves forward 'x' ticks elayer.e_playpos = glayer.playerpos; // player position [self addChild:elayer z:2]...

Persistence scheme & state data for low memory situations (iphone)

What happens to state information held by a class's variable after coming back from a low memory situation? I know that views will get unloaded and then reloaded later but what about some ancillary classes & data held in them that's used by the controller that launched the view? Sample scenario in question: @interface MyCustomControll...

How to get rid of all this garbage in NSLog?

When I use NSLog(@"fooBar") it prints out a lot of stuff I don't want: 2009-09-03 13:46:34.531 MyApp[3703:20b] fooBar Is there a way to print something to the console without this big prefix? I want to draw a table and some other things in the console so that space is crucial... ...

resizing an NSPanel to fit a dynamic NSMatrix and a button

I have an NSMatrix that is filled dynamically with some form items. Now, I can conveniently call [theMatrix sizeToCells] and then pass it into the panel to be displayed. Now, I want the NSPanel object which contains this NSMatrix to resize to wrap nicely around it. The NSPanel also has a button at the bottom which should be under the ...

Application Delegate - Cocoa

Hey all, I want to incorporate an applicationDidFinishLaunching: into my cocoa delegate. How would I do this?? On the iphone SDK the applicationDidFinishLaunching is already in the application delegate, but when making my mac application I noticed that there were none. Best Regards, Kevin ...

Why is this Core Data example crashing?

I have a model where I have a Person entity and a Picture entity. In my Picture entity I have a property that is a relationship to a Person. I would like to have an example about how to add a Picture to a Person because what I did doesn't work. -(BOOL)savePicture:(NSString *)urlPicture:(Person *)person{ SettingsSingleton *userSettings ...

Is there a way to print an clickable link to the console?

Is that generally possible? Is the console able to format a link so that it is clickable? i.e. a link that launches an application, or anything else when clicked? ...

Initial selected Item in an UITabBar without a UITabBarController

Hello, How do I set the default selected UITabBarItem in an UITabBar that is within an UIView, not an UITabBarController? Just to clarify, the UIView does implement the protocol and the didSelectItem method works. At run-time, the tabbar works and the tabbaritems selected when the user touches them. My problem is setting the default s...

How to write a macro that can take a parameter?

I want to use some NSAssert stuff and other things to enable better debugging in my app. NSAssert wants a string which it prints if the assertion fails. Nice, but useless unless you type a whole bunch of information in that string, which can become a big mess when done all over the place. So I want to make a macro that will do the NSAss...

Problem reading values from .plist downloaded from webserver

Hello everyone. My .plist and code to read it is described in http://pastie.org/605082 NSLog(@"Test %@\n",[test valueForKey:@"FirstName"]); returns NULL and resultsRetrieved is not NULL; What could be wrong? ...

Objective C error messages

I'm trying to debug an objective C program. It used to run, and I'm not sure what changes could have broken it, but it no longer runs at all. In the debugger, I now get: . . . unable to read unknown load command 0x80000022 unable to read unknown load command 0x80000022 unable to read unknown load command 0x80000022 Program loaded. share...

How to call a method without an instantiated object

This is an objective-c question. I would like to call a method in an object, but there is no instantiation of the object. Is this possible? The method I want to call is not a class method. ...

Upgrading Xcode Project to 3.2

Hey guys, How would I update my xcode project to 3.2? I need the app delegate of 3.2, but on my current 3.1 project doesn't have them. Please let me know how to do this. Thanks, Kevin ...

In Objective-C, am I allowed to override a method in a subclass that the parent used to conform to a protocol?

Example is provided below. If I set id<RandomProtocol> delegate = [[B alloc] init]; Will doingSomething of class A or class B be called? A.h @protocol RandomProtocol -(NSString*)doingSomething; @end @interface A : NSObject <RandomProtocol> @end A.m #import "A.h" @implementation A - (NSString*) doingSomething { return @"...

Generating Random Numbers in Objective C for iPhone SDK

I was using the arc4random() function in order to generate a random group and sequence of numbers, but I was told that this was overkill and that I should use the random() function instead. However, the random() function gives me the same group and sequence of numbers every time. I call srand(time(0)) once when my app first starts in or...

Proper Usage and Formatting of a Float in Objective-C (or C)

Hi everyone, I have an iPhone app. I am storing a float value, (distance), in my sqlite3 db. (The field in the db is formatted to float) I am able to store float values correctly in the db no problem. However, I can't seem to figure out how to pull the value back out of the db the format and present it correctly. Here is my code for pul...

How can I maintain a global cache of objects? (or a NSMutableSet w/o retaining contents)

I have an iPhone app which deals with a subset of 25,000 places at any given time. I'd like to maintain a cache of places so that I know that if one part of my application updates a place, every other part that knows about that place sees the update. My nieve implementation is create an NSMutableSet to store references to the cached pl...

Converting NSNumbers saved in a plist to integers

Saving data: - (NSString *)dataFilePath { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; return [documentsDirectory stringByAppendingPathComponent:kFilename]; } - (void)applicationWillTerminate:(NSNotification *)notification { NSMu...

Browse files through iphone

Hi i want to create an app that can browse the files of iPhone using xcode. can anyone help me ? ...

stringByAppendingString problem

NSString *tmpStr = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding]; xmlSms = [xmlSms stringByAppendingString:tmpStr]; NSLog(xmlSms); I got code above but NSLog doesn't show anything... Anybody know the problem?? ...