How do I declare class-level properties in Objective-C?
Maybe this is obvious, but I don't know how to declare class properties in Objective-C. I need to cache per-class a dictionary and wonder how put it in the class. ...
Maybe this is obvious, but I don't know how to declare class properties in Objective-C. I need to cache per-class a dictionary and wonder how put it in the class. ...
Are there any tutorials describing how to create a library or is it framework for the iPhone? I have a number of methods that are shared between applications. These will be better maintained as a library. ...
Suppose I have a class like this: @interface SomeClass : NSObject<NSCopying> { SomeOtherClass *obj; } In the definition of copyWithZone:, I do this: SomeClass *someCopy = [[SomeClass allocWithZone:zone] init]; So my question is, if I want to make a copy of obj, which of these is correct/recommended? option A: objCopy = [obj c...
I am developing an iPhone application using Objective-C. I want to access a data member which is of type NSMutableArray of the RootViewController class in another class. I tried making the array static. But I would like to have a non static array. How do I achieve this? ...
Hello I have this little code NSMutableArray *myArray = [[NSMutableArray alloc] init]; NSNumber *myNumber = [NSNumber numberWithDouble:752.65]; [myArray addObject:myNumber]; With this code I store Objects inside an array. But now I have two objects independent from each other. If I change myNumber after it's been added to the a...
I have a class called GameScene, with is a subclass of a cocos2d Scene. In there I have two layers. GameLayer and ControlsLayer. You can probably tell already that I want the ControlsLayer to move stuff around in the GameLayer. To be precise, I'm trying to control a cPBody in the GameLayer from the ControlsLayer. At the moment, I'm t...
I have a dialog with 1 or more buttons and want to be able to programmatically set the rightmost one be the default one, so that when the user presses the Enter or Return key it should respond as if the user clicked it. I'm using [btn setKeyEquivalent:@"\r"] and that makes it work fine but I want the button to have the blueish look whic...
I'm trying to learn Objective C & Cocoa, but I just can't manage to access a property inside an Object. Specifically an object from a C method. I'm working with the chipmunk dynamics library. Chipmunk has something similar to NSPoint called cpVect. Now I have no problem defining a cpVect inside my object, but when I try to make the acc...
What is an easy way to time a Cocoa application? (Alternatively, any good way to measure performance would suffice). (I have two different frameworks and would like to compare their performances over some fixed input data) ...
Hey guys, I am making a simple Twitter update application using MGTwitterEngine and I can't seem to get the TextField in Interface Builder to clear the text after they click the "update" button. Is there an easy method that I could do this with or something in Interface Builder? Thanks a lot! ...
I have an NSTimer running in my application that collects some data and sends it to a server periodically. In production the timer will fire every few hours. I am worried about interfering with automatic sleep. In testing, some combinations of timer and sleep time prevent automatic sleep entirely — the display sleeps, the system keeps r...
I am trying to add a variable amount of MenuItem objects to a Menu object on runtime. When my game starts I don't really know if my menu is having 2 or for example 5 items. for (MyItem* item in myItemCollection) { MenuItemImage* menuItem = [MenuItemImage itemFromNormalImage:@"MenuItem.png" selectedImage:@"MenuItemSelected.png" targ...
I need to have a NSTextField working with a NSStepper as being one control so that I can edit an integer value either by changing it directly on the text field or using the stepper up/down arrows. In IB I've added both of these controls then connected NSStepper's takeIntValueFrom to NSTextField and that makes the text value to change w...
I'm drawing offscreen to a CGContext created using CGBitmapContextCreate, then later generating a CGImage from it with CGBitmapContextCreateImage and drawing that onto my view in drawRect (I'm also drawing some other stuff on top of that - this is an exercise in isolating different levels of variability and complexity). This all works f...
I'm trying to convert CLLocation latitude / longitude to a string. I can successfully do this with the follow code: // extract latitude from CLLocation object and cast to string NSString *latitude = [[NSString alloc] initWithFormat:@"%g°", location.coordinate.latitude]; this gives me a value like: 34.10111º. I would like this number...
I'm trying to write an app where I need to accept keypresses, and call a function whenever the user has stopped typing (or when there is a specified delay between keystrokes). How do I measure the time between two keystrokes? ...
I want to send a UIImage to a server through a socket. a)I open the outputstream: - (IBAction)send:(id)sender { NSURL *website = [NSURL URLWithString:str_IP]; NSHost *host = [NSHost hostWithName:[website host]]; [NSStream getStreamsToHost:host port:1100 inputStream:nil outputStream: [oStream retain]; [oStream setDe...
I want to show a splash Screen before the App lunch. First I make the SplashWindow subclassing the NSWindow, the code is : - (id)initWithContentRect(NSRect)contentRect styleMask(unsigned int)aStyle backing(NSBackingStoreType)bufferingType defer(BOOL)flag { self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMa...
Hi, how do I parse a mail in Cocoa? I've read the NSScanner tutorial, but struggled. Do you know any better way than NSScanner? Is there any sample code? My example: http://pastie.org/private/pordph27stkwkyvrx2tiq Regards ...
See also: Objective-C Asynchronous Web Request with Cookies I spent a day writing this code and can anyone tell me what is wrong here? WSHelper is inherited from NSObject, I even tried NSDocument and NSObjectController and everything.. -(void) loadUrl: (NSString*) urlStr{ url = [[NSURL alloc] initWithString:urlStr]; reque...