これは私の設定です。 RadioStationsと呼ばれるオブジェクトがあり、コールサイン、周波数の宣言、およびamStationInfoというNSMutableArrayなどのいくつかの文字列があります。私のViewControllerで、私はそうのような配列を移入したSQLiteデータベースへのアクセス...UITableViewの結果を並べ替える
RadioStations.h
@interface RadioStations : NSObject {
NSString *format;
NSString *city;
}
@property (nonatomic, retain) NSString *format;
@property (nonatomic, retain) NSString *city;
ViewController.m
NSMutableArray* amStationInfo = [[NSMutableArray alloc] init];
while (sqlite3_step(statement) == SQLITE_ROW)
{
NSString *cityField = [[NSString alloc] initWithUTF8String:
(const char *) sqlite3_column_text(statement, 10)];
NSString *formatField = [[NSString alloc] initWithUTF8String:
(const char *) sqlite3_column_text(statement, 0)];
RadioStations *amStationClass = [[RadioStations alloc] init];
[amStationClass setCity:cityField];
[amStationClass setFormat:formatField];
[amStationInfo addObject:amStationClass];
}
[tabView reloadData];
sqlite3_finalize(statement);
そして私はのUITableView
を移入私は都市(市区町村、フォーマットのいずれかを入力します。私は形式がNSStringであることを知っています、私はすでにそれのdoubleValueを持っていると言ってみましょう。 5.0 2)サンフランシスコ - - 3.0 3)サンノゼ - 10.0 4)サンノゼ - 2.0 私はそう....
市(アルファベット順) 1)ロサンゼルスのような結果を持っているしたいのですが5)サンノゼ - 4.0
形式(数値) 1)サンノゼ - 2.0 2)サンフランシスコ - 3.0 3)サンノゼ - 4.0 4)ロサンゼルス - 5.0 5)サンノゼ - 10.0
両方(都市名とフォーマット) 1)ロサンゼルス - 5.0 2)サンフランシスコ - 3.0 3)サンノゼ - 2.0 4)サンノゼ - 4.0 5)サンノゼ - 10
私はそうのようなフォーマットをソートする方法を有します。私は 『IDを_strong』タイプのオブジェクトに見つからない「プロパティ 『フォーマット』を取得し、それがanObject.format
...私は何かが足りないのですが、私はそれがすべてを行う必要だと思います、しかし、今私はそれを呼び出すとき、私はこれが得ます私はamStationInfo = [amStationInfo sortedArrayUsingSelector:@selector(sortByFormat :)]を呼び出したときに 'NSArray *'から* _strong; – StarvingPilot
try amStationInfo = [[[NSMutableArray alloc] initWithArray [amStationInfo sortedArrayUsingSelector:@selector(sortByFormat :)]]; (またはそれに似たもの - 私の構文はこれで外れるかもしれません) –