5
我是新来的目标C,并注意到在代码中我读过,有时一段代码将被包裹在一个函数内的大括号中。如果代码被包含在函数内的大括号中,会发生什么情况?
这是干什么的?
例如...
- (BOOL) application: (UIApplication *) application didFinishLaunchingWithOptions: (NSDictionary *) launchOptions {
// Load config, available via macro CONFIG
{
NSString *path = [[NSBundle mainBundle] pathForResource: @"config" ofType: @"plist"];
NSData *data = [[NSData alloc] initWithContentsOfFile: path];
self.config = [NSPropertyListSerialization propertyListWithData: data
options: NSPropertyListImmutable
format: nil
error: nil];
[data release];
}
// snip
}
好一个Macmade。还有一件事,范围并不是特定于目标C,它也存在于C中。 – Krishnabhadra 2011-04-21 09:30:42