2012-05-02 107 views
0

我试图从一个导航嵌入式视图控制器的NSMutableArray发送到另一个的ViewController该方法的ios5从calloutAccessoryControlTapped将数据传递到另一个控制器

- (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 

我得到当我试图打印数组元素的大小空值。 可能是什么原因?

回答

1

而不是

NSLog(@"%@",[self.detailArray count]); 

试试这个

NSLog(@"%d",[self.detailArray count]); 

数是一个整数,而不是一类

相关问题