編集:この質問は修正されましたが、新しいエラーが表示されたため、インデックスパスに関連するインターネット上にないXcodeからエラーを取得するに移動しました。
私はこれに4日間います!ログにエラーは記録されていませんが、mysql からダウンロードした動的配列が取り込まれたセルをクリックしても、遷移しません。興味深いことに、prepareForSegue に自己配置した nslogs から応答がありませんでした...
ViewController.h
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
@interface ViewController : UIViewController<UITableViewDataSource,
CLLocationManagerDelegate,NSXMLParserDelegate, UISearchBarDelegate> {
IBOutlet UISearchBar *searchBar;
IBOutlet UITableView *tableView;
IBOutlet UILabel *Label;
CLLocationManager *locationManager;
NSMutableArray *coolarray;
float latitude;
float longitude;
}
@property (nonatomic, retain) CLLocationManager *locationManager;
@end
解析された xml ダウンロード データを除外しましたが、実装ファイルの下に nsarray の値を残しました
#import "ViewController.h"
#import "DetailViewController.h"
#import "Player.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];
}
- (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];
UILabel *nameLabel =[cell textLabel];
[nameLabel setText:[itemAtIndex objectForKey:@"name"]];
return cell;
}
- (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];
UILabel *nameLabel =[cell textLabel];
[nameLabel setText:[itemAtIndex objectForKey:@"name"]];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *selectedLang = [coolarray objectAtIndex:indexPath.row];
DetailViewController *myDetViewCont = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:[NSBundle mainBundle]];
myDetViewCont.myDogLang = selectedLang;
[self performSegueWithIdentifier:@"showDogDetail" sender:nil];
[myDetViewCont release];
myDetViewCont = nil;
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showDogDetail"])
{
DetailViewController *detailViewController =
[segue destinationViewController];
NSIndexPath *indexPath = [self.tableView
indexPathForSelectedRow];
NSString *dogLang = [self.coolarray objectAtIndex:indexPath.row];
detailViewController.myDogLang = dogLang;
}
}
@end
DetailViewController.h
#import <UIKit/UIKit.h>
@interface DetailViewController : UIViewController
{
IBOutlet UILabel *myLabel;
NSString *myDogLang;
}
@property (nonatomic, retain) IBOutlet UILabel *myLabel;
@property (nonatomic, retain) NSString *myDogLang;
@end
DetailViewController.m
#import "DetailViewController.h"
@interface DetailViewController ()
@end
@implementation DetailViewController
@synthesize myLabel;
@synthesize myDogLang;
- (void)viewDidLoad {
[super viewDidLoad];
myLabel.text = myDogLang;
self.myLabel.text = [self.myLabel objectAtIndex:0];
}
- (void)dealloc {
[myLabel release];
[myDogLang release];
[super dealloc];
}
接続を示す写真も追加しました。