在此方法之后,我正在尝试将 nsmutablearray 从一个导航嵌入式视图控制器发送到另一个视图控制器
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control{NSLog(@"tapped %@ %d",view.annotation.title,[res count]);
gpDetailViewController *gpDetailView = [[gpDetailViewController alloc] init];
gpDetailView.title = @"Details";
gpDetailView.detailArray = res;
[self.navigationController pushViewController:gpDetailView animated:YES];
}
被执行。这是 gpDetailViewController 的接口和实现文件。
//
// gpDetailViewController.h
// livewell prototype
//
// Created by MyOxygen Mobile on 02/05/2012.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface gpDetailViewController : UIViewController{
NSMutableArray *detailArray;
}
@property (nonatomic,retain) NSMutableArray *detailArray;
@end
和 gpDetailViewController.m
//
// gpDetailViewController.m
// livewell prototype
//
// Created by MyOxygen Mobile on 02/05/2012.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import "gpDetailViewController.h"
@interface gpDetailViewController ()
@end
@implementation gpDetailViewController
@synthesize detailArray;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
detailArray = [[NSMutableArray alloc]init];
NSLog(@"%@",[self.detailArray count]);
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
当我尝试打印数组元素大小时,我得到一个空值。可能是什么原因?