0
목표 C로 개발하는 데 새로운 것이므로 테이블 뷰에 NSDictionary를 적용 할 때 왜 오류가 발생하는지 파악하려고합니다. "배열 요소를 읽는 예상 된 메서드가 'NSDictionary *'형식의 개체에서 발견되지 않았습니다. 그게 무슨 뜻인지 아는 사람이 있습니까? 문제가 발생한 모델을 포함 시켰습니다. 업데이트]IOS에서 테이블보기에 사전 적용 중 오류가 발생했습니다.
: 문이 플래그지고는 다음과 같습니다
NSDictionary *conversation = self.data[indexPath.row];
감사합니다! 여기
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
ConversationTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"conversationCell" forIndexPath:indexPath];
// Get data from array at position of the row
NSDictionary *conversation = self.data[indexPath.row];
// Apply the data to each row
cell.conversationRecipients.text = [conversation valueForKey:@"recipients"];
cell.conversationPreview.text = [conversation valueForKey:@"last_message"];
cell.conversationTime.text = [conversation valueForKey:@"last_thread_post_short"];
//Set conversation thumbnail
[cell.conversationThumbnail sd_setImageWithURL:[conversation valueForKey:@"sender_avatar"]];
return cell;
}
내가 self.data을 설정하고있어 어디 :
// Successful Login
// Create the URL from a string.
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"URLISHERE"]];
NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60];
[request setHTTPMethod:@"GET"];
[request addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
// Prepare for the response back from the server
NSHTTPURLResponse *response = nil;
NSError *error = nil;
// Send a synchronous request to the server (i.e. sit and wait for the response)
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSError *serializeError;
id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&serializeError];
// Get response
self.data = json;
NSLog(@"%@", self.data);
// Reload data after Get
[self.tableView reloadData];
글쎄, 어떤 문장이 표시되는지 알면 좋을 것입니다. –
하지만 하나는'self.data'가 NSDictionary이고 정수로 색인하려고한다는 것입니다. –
어떻게 해결할 수 있습니까? –