它適用於我使用NSLog
,但不是printf
。我想使用printf
,因爲setA
中的所有元素都將顯示在一行中。爲什麼不是這種印刷方法的工作?
#import <Foundation/Foundation.h>
#define INTOBJ(v) [NSNumber numberWithInteger: v]
@interface NSSet (Printing)
-(void) print;
@end
@implementation NSSet (Printing)
-(void) print {
for (NSNumber *element in self)
printf("%li", (long) [element integerValue]);
}
@end
int main (int argc, char *argv[]) {
@autoreleasepool {
NSMutableSet *setA = [NSMutableSet setWithObjects:INTOBJ(3), INTOBJ(10), INTOBJ(1), INTOBJ(5), nil];
[setA print];
}
return 0;
}
我假設你想在iOS的設備上運行,對嗎?如果你在模擬器中運行,'printf'應該也能工作。 – dasblinkenlight 2012-08-01 18:40:08
你想做什麼? – Dustin 2012-08-01 18:40:20
問題被這裏ansered以及: [http://stackoverflow.com/questions/8924831/iphone-debugging-real-device][1] [1]:HTTP:/ /stackoverflow.com/questions/8924831/iphone-debugging-real-device – user1567896 2012-08-01 18:43:06