我有一個RowOfPlayerData類型的自定義數據容器對象。當我嘗試在NSLog中顯示RowOfPlayerData對象時,系統不知道如何顯示它,所以它只顯示對象的地址。ObC:如何將內存指針轉換爲數據P
我想弄清楚如何在NSLog語句中顯示什麼是該地址,以便我可以使用這些數據。
我想建立這樣一個關於NSPredicate教程:http://doronkatz.com/how-to-do-amazingly-simple-searches-with-nsar
我試圖做一些輸出的描述,但不succeded。
我試圖弄清楚如何做到這一點,所以我可以訪問數據。這裏是我使用的測試代碼和我目前有的輸出。順便說一句,我是新來的這個。
我真的很感激,如果有人可以幫助我以正確的格式顯示來自playerArray的數據,因爲我只是不明白這一點。
[CODE]
@interface RowOfPlayerData : NSObject {
NSString *playerName;
NSString *curGameType;
}
@property(nonatomic, retain) NSString *playerName;
@property (nonatomic, retain) NSString *curGameType;
-(void)addPlayerData2Array;
@end
這裏是.m文件:
-(void)addPlayerData2Array {
NSLog(@">>addPlayerData2Array started<<");
NSMutableArray *playerArray = [[NSMutableArray alloc] init];
RowOfPlayerData *row;
row = [[RowOfPlayerData alloc] init];
row.playerName = @"Player1";
row.curGameType = @"NORMAL1";
NSLog(@"<#1> row.playerName: %@", row.playerName);
NSLog(@"<#2> row.curGameType: %@", row.curGameType);
[playerArray addObject:row];
NSString *xx;
xx = [playerArray objectAtIndex:0];
NSLog(@"<#3> playerArray: %@", xx);
輸出:
addPlayerData2Array開始< <
2010-09-25 13:39:51.313 X1 [3675:207] <#1> row.playerName:PLAYER1
2010-09-25 13:39:51.314 X1 [3675:207] <#2> row.curGameType:正常1
2010-09-25 13:39:51.314 X1 [3675:207] <#3> playerArray:
[/ CODE]