0
我正在爲我的iphone應用程序創建聯繫人列表。我製作了一個包含以下屬性的自定義對象類。按照字母順序對對象排序並顯示按字母順序排列的表格標題,如Contact Book
- 姓
- 姓
- 編號
現在我想打一個聯繫人列表像iPhone的聯繫人列表。所以用A-B-C-D-E -...作爲tableview節標題。我正在關注這個tutorial。 但他只是在使用字符串。我的問題在於CellForRow。在這裏你可以看到我有什麼ATM。
NSString *alphabet = [firstIndex objectAtIndex:[indexPath section]];
//---get all states beginning with the letter---
NSPredicate *predicate =
[NSPredicate predicateWithFormat:@"SELF beginswith[c] %@", alphabet];
NSLog(@"list content is here %@",[listContent valueForKey:@"name"]);
NSArray *contacts = [[listContent valueForKey:@"name"] filteredArrayUsingPredicate:predicate];
NSLog(@"Contacts array is %@",contacts);
Contact *contact = nil;
contact = [contacts objectAtIndex:[indexPath row]];
NSLog(@"contact is in de else %@",contact.name);
NSString *text = [NSString stringWithFormat:@"%@ %@",contact.name,contact.firstName];
cell.textLabel.text = text;
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
我的第一行上崩潰,並顯示以下日誌
2013-02-07 10:52:47.963 Offitel2[7807:907] list content is here (
Claes,
Geelen,
Verheyen
)
2013-02-07 10:52:47.964 Offitel2[7807:907] Contacts array is (
Claes
)
2013-02-07 10:52:47.964 Offitel2[7807:907] -[__NSCFString name]: unrecognized selector sent to instance 0x208e2c20
2013-02-07 10:52:47.965 Offitel2[7807:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString name]: unrecognized selector sent to instance 0x208e2c20'
任何人可以幫助我嗎?
親切的問候
難道我不能只是自定義我的預測在某些方面?因爲一切工作除了在我的cellForRowAtIndexPath – Steaphann
修復它!謝謝 – Steaphann
您隨時歡迎。 :) – rptwsthi