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