好吧,我想我正式正在疯狂...尝试在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问题。 –