I am having a weird problem with variable values. This is the code (it is part of a class method):
MyAppDelegate *pDelegate = [[UIApplication sharedApplication] delegate]; SomeDictionaryData *appData = [pDelegate.theData retain]; NSLog(@"my instance var: %@",cardIndex); // outputs "my instance var: 4" NSDictionary *currentCard = [[NSDictionary alloc] initWithDictionary:[appData.cards objectAtIndex:cardIndex]];; // the above line breaks the app [currentCard release]; [appData release];
I am using the debugger with the
objc_exception_throw breakpoint. The input received by
objectAtIndex in there shows as having value = 13760640. The
cards attribute of appData is an
NSArray and it clearly does not have ten million + items so I get an out of bounds error. I tried casting with
(int)cardIndex with no better results. Weird thing is a similar code in some other class works fine.
This is some data I want to use throughout my app so I have a Model class that gets initialized in the AppDelegate as
theData and then is accesed by different ViewControllers. This error shows up after one successful access on some other ViewController (that one also does retain/release).
Any help will be appreciated.
Setting UILabel before adding Subview in UIWindow fails
1:Change navbar title programatically
[cardIndex unsignedIntValue]for the
objectAtIndex:line.. Preventing PHP scripts used in a iPhone app from being access via web browser You cannot commit
objectAtIndex:a pointer for the reason this it expects an unsigned integer.. Custom easing action with Cocos2D-iphone For example:. How to lose margin/padding in UITextView?
EDIT:. Creating a PHP Webservice with binary-encoded parameters? It sounds like
NSDictionary *currentCard = [[NSDictionary alloc] initWithDictionary:[appData.cards objectAtIndex:[cardIndex unsignedIntValue]]];
intalthough any where along the lines it is being set as an
NSNumberinstance. Is there an iPhone SDK API for twitter? [closed]As a hack, use
[(id)cardIndex unsignedIntValue]. iPhone Safari: Scroll a list inside a html containerIf this works, then it means you are using the wrong type for
cardIndex(it should be NSNumber, not