iphone(xcode 4.2)のsqliteデータベースから抽出された名前のアルファベットグループセクションを作成する方法を知りたいと思います。私は名前のグループセクションを行うことができましたが、姓の部分を行うことができませんでした。ある名前には小文字があります。私は、ヘッダー文字にそれらの名前の大文字と小文字を含むすべての大文字を使用します。いくつかの名前は3つの名前があり、私は最後の名前を得ることを確認したかった。私のコードは下にあり、アルファベット(AからL、CからDまで)とeとE(表示したくない下位と上位)が混在しているようです。iphone sqliteを使用してグループセクションのテーブルビューの姓の最初の文字を取得する方法は?
// --- createインデックス---
nameIndex = [[NSMutableArray alloc] init];
for (int i=0; i<[_authorsInfo count]-1; i++){ //---get the first char of each state--- authors *tempAuthor = [_authorsInfo objectAtIndex:i]; char alphabet = [tempAuthor.name characterAtIndex:0]; NSString *uniChar = [NSString stringWithFormat:@"%C", alphabet]; //---add each letter to the index array--- if (![nameIndex containsObject:uniChar]) { [nameIndex addObject:uniChar]; }
UPDATE *
self.authorsInfo = [poemDatabaseデータベース] .authorsInfo。
//---create the index--- nameIndex = [[NSMutableArray alloc] init]; for (int i=0; i<[_authorsInfo count]-1; i++){ //---get the first char of each state--- authors *tempAuthor = [_authorsInfo objectAtIndex:i]; NSArray *nameComponents = [tempAuthor.name componentsSeparatedByString:@" "]; NSString *lastName = [ nameComponents objectAtIndex: nameComponents.count-1 ]; char alphabet = [lastName characterAtIndex:0]; //char alphabet = [tempAuthor.name characterAtIndex:0]; NSString *uniChar = [NSString stringWithFormat:@"%C", alphabet]; //---add each letter to the index array--- if (![nameIndex containsObject:uniChar]) { [nameIndex addObject:uniChar]; } }
を – merrill
こんにちは、私は何かを更新するかどうか疑問に思いますか? :) – merrill