objective-c

Cocoa-touch and UIButtonContent

Curious, how does an NSMutableArray mutate into a type of UIButtonContent? I'm currently working with an instance variable of type NSMutableArray which crashes upon receiving an error with: *** -[UIButtonContent count]: unrecognized selector sent to instance 0x393ed0 Wasn't even aware of UIButtonContent, so not explicitly working with ...

NULL vs nil in Objective-C

In observeValueForKeyPath:ofObject:change:context: - why do the docs use NULL instead of nil when not specifying a context pointer? ...

Is it defined behavior to change an Objective-C object's isa?

In Objective-C, you can change an object's dynamic type at runtime by assigning to it's isa member variable: id object = ...; object->isa = [SomeClass class]; Is this undefined behavior? I'm currently doing this as a kludge for something else, and it appears to be working, but I feel so dirty doing it this way. The new class I'm set...

How do I change the color of a Cocos2d MenuItem?

[MenuItemFont setFontSize:20]; [MenuItemFont setFontName:@"Helvetica"]; //I'm trying to change the color of start (below item) MenuItem *start = [MenuItemFont itemFromString:@"Start Game" target:self selector:@selector(startGame:)]; MenuItem *help = [MenuItem...

Does anyone have a working example of ParticleExplosion in Cocos2d?

I'm new to iPhone development and I'd really like to see a working example of this particular effect. Thanks in advance. ParticleExplosion ...

What's the most efficient way to create particles on the iPhone.

I'm looking to create a snowfall effect on the iPhone and I'm looking for advice as to how to best implement this. I've planned to use a png image as the sprite. ...

How do I debug with NSLog(@"Inside of the iPhone Simulator")?

I'm used to programming and having log messages be viewable. I know you used to be able to use NSLog() to trace out messages when debugging Cocoa apps. What is the best way to "trace" messages when coding in a iPhone XCode development environment? ...

Animate CGContextStrokeEllipseInRect

I'm trying to animate the drawing of a circle. Something the Shazaam app is doing while recording, but much simpler. I've got this code in the drawRect: method to draw the circle: CGContextRef currentContext = UIGraphicsGetCurrentContext(); CGContextSetRGBStrokeColor(currentContext, 0.86, 0.86, 0.86, 1.0); CGContextSetLineWidth(currentC...

Creating a Quartz Composer Style interface

I'm wanting to add a Quartz Composer "patch editor" style interface element to my Cocoa/Objective C(++) application. For those unfamiliar with QC, the patch editor is a visual representation of the patch graph: effectively showing each node and it's properties, and providing a mouse driven select/click/drag interface. It looks like... ...

Difference between release and dealloc in objective-c

When deallocing a refrence I've seen release and dealloc being used for example -(void)dealloc { [foo release]; [nar dealloc]; [super dealloc]; } My question is when is release to be used and when is dealloc to be used? Thanks ...

Why doesn't an iPhone app's main() function ever get a chance to finish?

Consider the following main() method which you would find most iPhone applications: int main(int argc, char *argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, nil); [pool release]; return retVal; } In every iPhone app that I've run in Simulator with the...

how i can navigate to another page from a button

hey, i am new at the area of objective c. i am building an iphone app by using xcode . i have taken two button on a page and from among one i would like to go to another page how is it possible at xcode? ...

Does this copy class method leak memory?

- (id)copyWithZone:(NSZone *)zone { PoolFacility *copy = [[[self class] allocWithZone:zone]init]; copy.name = [self.name copy]; copy.type = [self.type copy]; copy.phoneNumber = [self.phoneNumber copy]; //make sure I get proper copies of my dictionaries copy.address = [self.address mutableCopy]; copy.webAddre...

how to set the float value to two decimal number in objective C

as title, i have a value 25.00 i use float as a variable but when i print it on screen it is 25.0000000 how can i set the decimal number in two only ...

Optional arguments in Objective-C 2.0?

In Objective-C 2.0, is it possible to make a method where the argument is optional? That is, you can have a method call like this: [aFraction print]; as well as this: [aFraction print: someParameter]; in the same program. Apple's Objective-C 2.0 Programming Language guide contrasts Obj-C with Python and seems to say this is not al...

Objective-C style formatter

I'm a newbie on Objective-C programming and aiming to follow Google's code convention: http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml. Some code formatting tool would be handy to use, is there any Objective-C code formatter that can easily be integrated into XCode? ...

Getting a segfault (EXC_BAD_ACCESS) when deallocating variables

Ok I understand that this error mostly comes from sending a method call or trying to access a variable that has already been deallocated. Here is the problem: .h @interface TimeEntry : NSObject <NSCopying, NSCoding> { NSDate *from; NSDate *to; NSString *information; } @property (nonatomic, retain) NSDate *from; @property (nonatomi...

NSArray; makeObjectsPerformSelector:

Hello, I want to make all objects in an array perform a selector. I've discovered the appropriately named makeObjectsPerformSelector: method, but I have a question with it. If I use it on an array, will it change the existing array or return a new one? If it modifies the existing object, what be the easiest way to return a new array with...

Coding in Objective-C 2.0 screencasts?

Has anyone used the Pragmatic Programmers screencast series Coding in Objective-C 2.0? They look good, but I don't know if I could get just as much value out of a text book or other web links. ...

Code linting for Objective C

Are there any code linting tools for ObjectiveC? ...