我已经建立了一个对象数组,从一个类创建,我之前写过。我只是想在遍历数组时访问一些类变量:
- (void)viewDidLoad
{
[super viewDidLoad];
NSMutableArray *medicalCenters = [(AppDelegate *)[[UIApplication sharedApplication] delegate] medicalCenters];
for (MedicalCenter *row in medicalCenters){
NSString *latitude = row.MCLatitude;
NSLog(@"%@", latitude);
}
}
我创建的类文件如下所示:
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
@interface MedicalCenter : NSObject
{
CLLocationCoordinate2D _coordinate;
}
@property (nonatomic, strong) NSString *medicalCenter;
@property (nonatomic, assign) NSString *MCLatitude;
@property (nonatomic, assign) NSString *MCLongitude;
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
- (id)initWithName:(NSString *)medicalCenter coordinate:(CLLocationCoordinate2D)coordinate;
@end
每当我建立 时NSString *latitude = row.MCLatitude
,我都会收到消息:Bad_excess Code:1
但是当我只列出数组medicalCenters 中的对象时,我可以看到它们全部............我错过了什么重要的东西吗?
谢谢塞巴斯蒂安