开发者

What does Out Of Scope mean?

I have received an error that indicates that "savedNumberDict" is Out Of Scope. I am not quite sure where to look for a solution. Any suggestions? The code is below that I am using. Thanks.

- (void)applicationDidFinishLaunching开发者_运维知识库:(UIApplication*) application {
    self.savedNumber = [[NSUserDefaults standardUserDefaults]objectForKey:kNumberLocationKey];

    if (savedNumber == nil) {
        savedNumber = @"555 555 1212";
        NSDictionary *savedNumberDict = [NSDictionary dictionaryWithObject:savedNumber forKey:kNumberLocationKey];
        [[NSUserDefaults standardUserDefaults] registerDefaults:savedNumberDict ];
    }

    [window addSubview:viewController.view];
    [window makeKeyAndVisible]; 
}


Is this piece of code definitely the root of the error? Are you not trying to access savedNumberDict elsewhere? Since it is declared inside your if {} block, it only exists within the if {}, once the code exits that block the variable ceases to exist.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜