我仍然在用objective-c找到自己的脚,并想知道是否可以在下面的两个对象上使用@property。@属性,在这种情况下可以吗?
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@interface MapViewController : UIViewController <MKMapViewDelegate, CLLocationManagerDelegate> {
CLLocationManager *locationManager;
IBOutlet MKMapView *googleMapView;
}
@property(nonatomic, retain) CLLocationManager *locationManager;
@property(nonatomic, retain) MKMapView *googleMapView;
@end
我的一个原因,用起来,这样我可以用我的viewDidUnload的制定者,我似乎可以用@property了很多,只是想知道,如果在这种情况下使用是可以接受的?
-(void)viewDidUnload {
[self setLocationManager:nil];
[self setGoogleMapView:nil];
[super viewDidUnload];
}
大加赞赏
加里
我可以问一下,如果这两个变量未被声明为@property,viewDidUnload将如何显示?你会[locationManager发布]; locationManager = nil;和googleMapView一样? – fuzzygoat 2010-06-02 15:40:34
@fuzzygoat这可以清理,但你会如何设置它? – hooleyhoop 2010-06-02 15:51:30
我想你将不得不直接设置它们(即)locationManager = [[CLLocationManager alloc] init]; – fuzzygoat 2010-06-02 15:58:32