나는 인터넷을 검색 한 결과 이것에 대한 결과가 전혀 없습니다. My IOS App은 사용자 정의 동적 셀()의 선택된 행의 제목을 uilabel에 보내야하는 인덱스 경로가있는 단순한 탐색 컨트롤러 일뿐입니다. catch는 데이터 원본이 nsarray에서 구문 분석 된 xml 인 mysql (coolarray)에 있음을 나타냅니다. 다음보기로 이동하기 직전에 오류가 발생하여 로그에 다음과 같이 표시됩니다. 'NSInvalidArgumentException'이라는 캐치되지 않은 예외로 인해 앱이 종료됩니다. '[__NSDictionaryI isEqualToString :] : 인스턴스가 0x8887670으로 전송 된 인식 할 수없는 선택자'입니다. 그러나 indexPathrow의 결과는 nslog : 0 또는 1 또는 무엇이든지 선택됩니다. 그것은 uilabel 배열의 배달 문제가 있어야합니다,하지만 그것을 알아낼 수 없습니다! 나는 그것이 오류의 원인이 아니기 때문에 사용자 정의 셀의 코드를 생략하고 잘 작동한다 (더하기 간단하다). 이것은 나의 이전 질문 인 UITableView refusing to go to detailViewController에 대한 후속 조치입니다. 그러나 아래에서 볼 수 있듯이 내 코드가 크게 변경 되었기 때문에이 코드는 더 이상 적합하지 않습니다.색인 경로와 관련된 인터넷상의 Xcode에서 오류가 발생했습니다.
ViewController.h
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import "Player.h"
@interface ViewController : UIViewController<UITableViewDelegate, UITableViewDataSource,
CLLocationManagerDelegate,NSXMLParserDelegate, UISearchBarDelegate> {
IBOutlet UISearchBar *searchBar;
CLLocationManager *locationManager;
NSMutableArray *coolarray;
float latitude;
float longitude;
}
@property(nonatomic,strong) IBOutlet UITableView * tableView;
@property (nonatomic, retain) CLLocationManager *locationManager;
@end
ViewController.m
#import "ViewController.h"
#import "LoadingViewController.h"
@interface ViewController()
@end
@implementation ViewController
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)dealloc
{
[super dealloc];
[self.locationManager release];
if (coolarray)
[coolarray release];
}
- (void)viewDidLoad
{
[super viewDidLoad];
coolarray = NULL;
self.locationManager = [[[CLLocationManager alloc] init] autorelease];
self.locationManager.delegate = self;
[self.locationManager startUpdatingLocation];
[[self navigationController] setNavigationBarHidden:YES];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
// Table data delegate
- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section {
if (coolarray != NULL) {
return [coolarray count];
}
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
Player *cell = [_tableView dequeueReusableCellWithIdentifier:@"Player"];
if (cell == nil)
{
cell = [[[Player alloc] initWithFrame:CGRectZero reuseIdentifier:@"Player"] autorelease];
}
NSDictionary *itemAtIndex =(NSDictionary *)[coolarray objectAtIndex:indexPath.row];
cell.nameLabel.text = [itemAtIndex objectForKey:@"name"];
return cell;
}
// XML request and parsing
- (void)updateLocation:(CLLocation *)newLocation {
if (coolarray) {
[coolarray release];
}
coolarray = [[NSMutableArray alloc] init];
if (newLocation) {
latitude = newLocation.coordinate.latitude;
longitude = newLocation.coordinate.longitude;
}
NSString *urlString = [NSString stringWithFormat:@"(censored)"];
NSXMLParser *locationParser = [[[NSXMLParser alloc] initWithContentsOfURL:[NSURL URLWithString:urlString]] autorelease];
[locationParser setDelegate:self];
[locationParser parse];
[_tableView reloadData];
}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
if ([elementName isEqualToString:@"location"]) {
[coolarray addObject:[[NSDictionary alloc] initWithDictionary:attributeDict]];
}
}
// GPS handling
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
[self updateLocation:newLocation];
}
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error
{
}
// Search bar handling
- (void)searchBarSearchButtonClicked:(UISearchBar *)sb {
[self updateLocation:NULL];
[searchBar resignFirstResponder];
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)sb
{
[searchBar resignFirstResponder];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if([segue.identifier isEqualToString:@"showDetail"])
{
NSIndexPath * indexPath=[self->_tableView indexPathForSelectedRow];
LoadingViewController* destViewController= segue.destinationViewController;
destViewController.myProgLang=[coolarray objectAtIndex:indexPath.row];
NSLog(@"indexPathrow:%d",indexPath.row);
}
}
@end
LoadingViewController.h (내 상세보기)
#import <UIKit/UIKit.h>
@interface LoadingViewController : UIViewController
{
}
@property (nonatomic, retain) IBOutlet UILabel *myLabel;
@property (nonatomic, retain) NSString *myProgLang;
@end
LoadingViewController.m (내 상세보기)
#import "LoadingViewController.h"
@interface LoadingViewController()
@end
@implementation LoadingViewController
@synthesize myLabel, myProgLang;
- (void)viewDidLoad {
[super viewDidLoad];
myLabel.text = myProgLang;
[[self navigationController] setNavigationBarHidden:YES];
}
- (void)dealloc {
[myLabel release];
[myProgLang release];
[super dealloc];
}
@end
감사를 다시! 네가 나를 위해 해결 한 # 4이다. 정말 고마워요! – user1776234
괜찮습니다. 다행이야! :) –