Tag: objective c

TouchJSON, dealing with NSNull

Hi I am using TouchJSON to deserialize some JSON. I have been using it in the past and on those occasions I dealt with occurrences of NSNull manually. I would think the author had to deal with this as well, so me doing that again would just be overhead. I then found this in the […]

Avoiding “NSArray was mutated while being enumerated”

I have an NSMutableArray that stores mousejoints for a Box2d physics simulation. When using more than one finger to play I’ll get exceptions stating NSArray was mutated while being enumerated I know this is because I’m deleting objects from the array while also enumerating through it, invalidating the enum. What I want to know is […]

Objective-C : How to fetch the router address?

I tried to fetch the router address this way. – (NSString *) routerIp { NSString *address = @”error”; struct ifaddrs *interfaces = NULL; struct ifaddrs *temp_addr = NULL; int success = 0; // retrieve the current interfaces – returns 0 on success success = getifaddrs(&interfaces); if (success == 0) { // Loop through linked list […]

Moving a Stick figure, anchorpoints, animation, or something else…?

Ok so I am making a game with stick figures with cocos2d in objective c… Different things need to be animated so please, give me a suggestion of what would be the best way to go about accomplishing the movement for these things: The main character- he is an archer in the bottom left corner […]

property type or class using reflection

I was wondering if it’s possible to determine the class or primitive type of an Objects properties. Getting all properties names and values is pretty easy. SO answer So is there any way to get the properties class type while the property hast no value or nil value? Example Code @interface MyObject : NSObject @property […]

Accessing Method from other Classes Objective-C

Looked for an answer for this question, but I haven’t found a suitable one yet. I’m hoping you guys (and gals) can help me out! (This is for an iPhone app) Alright, I have a Mutliview application. Each view has it’s own class, and everything is happy. However, the different classes sometimes call the same […]

When should I call super?

What is the best using of [super … any method name]. Recently I have found out that In dealloc the [super dealloc] must stand in the same end. Because any variable what didn’t use before can be filled by garbage if we set it after [super dealloc] It’s a rare thing, but it’s possible. After […]

Objective C: what is a “(id) sender”?

In some IBAction I saw: – (IBAction)pushButton:(id)sender; This (id)sender when do I use it?

iTunes Song Title Scrolling in Cocoa

I have searched extensively and cannot for the life of me find any information about how to achieve a similar effect to that of the iTunes song title scrolling if the text is too large in Cocoa. I have tried setting the bounds on a NSTextField to no avail. I have tried using NSTextView as […]

Instance variables declared in ObjC implementation file

I was watching the WWDC ARC introduction video and I saw something I’ve never seen in ObjC before when some Apple engineer talked about a Stack example. The following code was used for a stack example with ARC: @implementation Stack { // instance variable declared in implementation context NSMutableArray *_array; } – (id)init { if […]