objective-c函数执行得不好

mar*_*rcy -3 objective-c

此功能执行得不好.

-(void)sampleItemA:(NSString*)a itemB:(NSString*)b itemC:(NSDate*)c{
    NSLog(@"A");
    NSArray* ary = [[NSArray alloc] initWithObjects:a, b, c, nil];
    NSLog([ary description]);
    NSLog(@"B");
}
Run Code Online (Sandbox Code Playgroud)

日志

[Session started at 2009-11-07 20:46:10 +0900.]
2009-11-07 20:46:19.170 xxx[2374:207] A
Run Code Online (Sandbox Code Playgroud)

原因是什么?

编辑:

我试过了.但它没有执行.

-(void)sampleItemA:(NSString*)a itemB:(NSString*)b itemC:(NSDate*)c{
    NSLog(@"A");
    NSArray* ary = [[NSArray alloc] initWithObjects:a, b, c, nil];
    NSLog(@"%@", [ary description]);
    NSLog(@"B");
}
Run Code Online (Sandbox Code Playgroud)

日志

[Session started at 2009-11-07 21:25:37 +0900.]
2009-11-07 21:25:48.738 xxx[2455:207] A
Run Code Online (Sandbox Code Playgroud)

Lou*_*arg 6

将非常量格式字符串传递给NSLog通常是不明智的,事情变得很糟糕.尝试:

-(void)sampleItemA:(NSString*)a itemB:(NSString*)b itemC:(NSDate*)c{
    NSLog(@"A");
    NSArray* ary = [[NSArray alloc] initWithObjects:a, b, c, nil];
    NSLog(@"%@", [ary description]);
    NSLog(@"B");
}
Run Code Online (Sandbox Code Playgroud)