开发者

Iterating through an array

开发者 https://www.devze.com 2023-01-25 15:17 出处:网络
Hey everyone, I am trying to iterate though an array of strings when I click a button in my iPhone app. In the viewDidLoad method this code works great, however, I am using a Tab Bar to switch between

Hey everyone, I am trying to iterate though an array of strings when I click a button in my iPhone app. In the viewDidLoad method this code works great, however, I am using a Tab Bar to switch between views, and I want the view to refresh itself when i switch to it from another view. This is the code it is breaking around, very similar to code I am using in another button that works perfectly

        NSEnumerator *e = [deckList开发者_Python百科 objectEnumerator];
        id obj;

It crashes whenever it gets to "id obj" Any help would be most appreciated.


for (NSString* string in arrayOfStrings ){
    NSLog(@"%@", string);
}

The Objective-C Programming Language — Fast Enumeration


It turns out that as @vikingosegundo pointed me to in an NSZombieEngabled thread, I had not initialized the ids to nil. The simple fix of:

 id obj = nil;

solved all my problems!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号