2011-07-02 3 views
0

나는 데이터베이스 응용 프로그램을 만들고 있는데, 나는 sqlite 데이터베이스에서 결과를 추출하여 테이블에 넣을 수있다. 그러나 섹션에서 알파벳 순으로 정렬해야한다. 이 모두가 잘 작동Sectionable tableview problem

그래서 지금은이 코드

AArray = [[NSMutableArray alloc] init]; 
    BArray = [[NSMutableArray alloc] init]; 
    CArray = [[NSMutableArray alloc] init]; 
    DArray = [[NSMutableArray alloc] init]; 
    EArray = [[NSMutableArray alloc] init]; 
    FArray = [[NSMutableArray alloc] init]; 
    GArray = [[NSMutableArray alloc] init]; 
    HArray = [[NSMutableArray alloc] init]; 
    IArray = [[NSMutableArray alloc] init]; 
    JArray = [[NSMutableArray alloc] init]; 
    KArray = [[NSMutableArray alloc] init]; 
    LArray = [[NSMutableArray alloc] init]; 
    MArray = [[NSMutableArray alloc] init]; 
    NArray = [[NSMutableArray alloc] init]; 
    OArray = [[NSMutableArray alloc] init]; 
    PArray = [[NSMutableArray alloc] init]; 
    QArray = [[NSMutableArray alloc] init]; 
    RArray = [[NSMutableArray alloc] init]; 
    SArray = [[NSMutableArray alloc] init]; 
    TArray = [[NSMutableArray alloc] init]; 
    UArray = [[NSMutableArray alloc] init]; 
    VArray = [[NSMutableArray alloc] init]; 
    WArray = [[NSMutableArray alloc] init]; 
    XArray = [[NSMutableArray alloc] init]; 
    YArray = [[NSMutableArray alloc] init]; 
    ZArray = [[NSMutableArray alloc] init]; 

을하고 난 관련 배열로 데이터베이스에서 각 항목을 이동하는 코드가 있습니다.

나는 다음이 코드를 가지고 : 내가 그것을 잘 작동 실행하면 내가 위로 몇 번 아래로 스크롤 그러나 경우,

All = [NSMutableDictionary dictionaryWithObjectsAndKeys:AArray,@"A",BArray,@"B",CArray,@"C",DArray,@"D",EArray,@"E",FArray,@"F",GArray,@"G",HArray,@"H",IArray,@"I",JArray,@"J",KArray,@"K",LArray,@"L",MArray,@"M",NArray,@"N",OArray,@"O",PArray,@"P",QArray,@"Q",RArray,@"R",SArray,@"S",TArray,@"T",UArray,@"U",VArray,@"V",WArray,@"W",XArray,@"X",YArray,@"Y",ZArray,@"Z",nil]; 
    AllArray = [NSArray alloc]; 
    AllArray = [AllArray initWithArray:[[All allKeys]sortedArrayUsingSelector:@selector(compare:)]]; 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    // Return the number of sections. 
    return [AllArray count]; 
} 


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    // Return the number of rows in the section. 
    NSArray *Array = [All objectForKey:[AllArray objectAtIndex:section]]; 
    return [Array count]; 
} 
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { 
    int sectionindex = section; 
    return [AllArray objectAtIndex:sectionindex]; 

} 

을 오류 메시지없이 응용 프로그램이 충돌 . 내가 그들에 추가 할 때 충돌되는 것과 같이 함께 할 수있는 뭔가,하지만 난 그냥 시간 파일에 선언 잘못된

Everythings을하고 어떤 메신저를 볼 수 없습니다 그리고 난 @property와 @synthesize 다음

@property (nonatomic,retain) NSMutableDictionary *All; 
@property (nonatomic,retain) NSArray *AllArray; 
@property (nonatomic, retain) UITableView *TableView; 

누군가 나를 도울 수 있다면 정말 좋을 것입니다!

감사합니다.

답변

1

사전 "전체"가 유지되지 않는 것 같습니다. 사전 개체를 속성이 아닌 인스턴스 변수에 직접 할당하는 것처럼 보입니다 (이 경우 self.All을 사용했을 것입니다).

메시지없이 앱이 중단되는 경우 Xcode 도구 모음에서 중단 점 버튼을 사용하도록 설정해야합니다. 그러면 디버거에서 앱이 실행되어 충돌에 대한 유용한 정보를 얻을 수 있습니다. NSZombieEnabled를 YES로 설정하면 도움이됩니다.

+0

이 그것을 해결했다 ! 매우 감사합니다! – ApiMail

+1

웹 사이트가 허용하는대로 답변을 수락합니다. – ApiMail

0

것은 여기를보세요 :

가장 간단한 방법은, 정렬 선택 (자세한 내용은 링크를 참조)을 제공 :

sortedArray = [anArray sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];