我仍然在用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