好吧,我想我正式正在瘋狂...嘗試在iOS 5.0模擬器上運行xcode 4.2上的此代碼並獲取各種錯誤。在這個應用程序中,我試圖做的就是運行核心位置API。編譯Xcode 4.2的錯誤
我的位置 「控制器」 類:
.H:
#import Foundation/Foundation.h
#import CoreLocation/CoreLocation.h
@protocol locationReceiverDelegate
@required
- (void)locationUpdate:(CLLocation *)location;
- (void)locationError:(NSError *)error;
@end
@interface locationReceiver : NSObject <CLLocationManagerDelegate> {
CLLocationManager *locMgr;
id delegate;
}
@property (nonatomic, retain) CLLocationManager *locMgr;
@property (nonatomic, assign) id delegate;
@end
.M:
#import "locationReceiver.h"
@implementation locationReceiver
@synthesize locMgr, delegate;
- (id)init
{
self = [super init];
if(self != nil) {
self.locMgr = [[CLLocationManager alloc] init];
self.locMgr.delegate = self;
}
return self;
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
// if([self.delegate conformsToProtocol:@protocol(locationReceiverDelegate)]) {
[self.delegate locationUpdate:newLocation];
// }
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
// if([self.delegate conformsToProtocol:@protocol(locationReceiverDelegate)]) {
[self.delegate locationError:error];
// }
}
@end
我得到一個錯誤的.m文件是「@synthesize locMgr ,代表;「 ,「對於指派屬性‘代表’現有伊娃‘代理’必須_unsafe_unretained」
這可能不是你的問題,但是ivar和屬性之間存在類型不匹配:ivar是一個'id',但屬性是'id'。 –
zneak
在Apple開發人員論壇上提問,Xcode 4.2未發佈,我們無法在這裏回答ARC問題。 –