Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone @合成干扰遗传_Iphone_Objective C - Fatal编程技术网

Iphone @合成干扰遗传

Iphone @合成干扰遗传,iphone,objective-c,Iphone,Objective C,最终编辑 所有生活问题的解决方案: 将xcode的“编译器版本”设置切换到“LLVM编译器2.0”可以解决此问题,非常感谢Firoze Lafeer提供的协调一致、建设性的帮助 其目的是通过将NSObject和UIViewController子类化,在我的所有类中构建一些真正基本的功能,以获取应用程序委托,稍微扩展ViewDidAspect机制,等等。我有一个类似这样的基类(仅包括相关行): @接口PHView:UIViewController{ id appDelegate; } -(id)

最终编辑

所有生活问题的解决方案:

将xcode的“编译器版本”设置切换到“LLVM编译器2.0”可以解决此问题,非常感谢Firoze Lafeer提供的协调一致、建设性的帮助

其目的是通过将NSObject和UIViewController子类化,在我的所有类中构建一些真正基本的功能,以获取应用程序委托,稍微扩展ViewDidAspect机制,等等。我有一个类似这样的基类(仅包括相关行):

@接口PHView:UIViewController{
id appDelegate;
}
-(id)init;
//其他一些方法原型
@属性(非原子,保留)id委托;
@结束
@实现视图
@综合代表;
-(id)init{
self=[super init];
appDelegate=(id)[[UIApplication sharedApplication]委托];
可见=假;
初始化=假;
回归自我;
}
//其他一些方法
@结束
编辑我应该在这里提到,属性“delegate”并不意味着指向ivar“appDelegate”或任何东西。。。我留下来只是为了说明这个超类使用@synthesis。因为这不是一个相关的用途,我认为这无关紧要,但我不会说我知道这一点

子类的接口:

@interface PinMap : PHView <MKMapViewDelegate> {
//@interface PinMap : UIViewController <MKMapViewDelegate> {
//    NSObject<PHAppDelegate>* appDelegate;
}
-(id)init;
-(void)zoomToUser;
@property (nonatomic, retain) IBOutlet MKMapView* map;
@end
@接口PinMap:PHView{
//@接口PinMap:UIViewController{
//NSObject*appDelegate;
}
-(id)init;
-(空)动物园传送带;
@属性(非原子,保留)IBMMapView*map;
@结束
这包括:

@implementation PinMap
//@synthesize map;

-(PinMap*) init{
    self = [super init];
    //appDelegate = (NSObject<PHAppDelegate>*)[[UIApplication sharedApplication] delegate];    
    return self;
}

-(void)zoomToUser {
    //MKCoordinateRegion region = map.region;
    MKCoordinateRegion region = MKCoordinateRegionMake(CLLocationCoordinate2DMake((CLLocationDegrees)300, (CLLocationDegrees)300), MKCoordinateSpanMake((CLLocationDegrees)20,(CLLocationDegrees)20)); //random region
    region.center = [[appDelegate location] coordinate];
    region.span.longitudeDelta /= 50.0;
    region.span.latitudeDelta /= 50.0;
//    [map setRegion:region animated:NO];
}
@实现PinMap
//@综合地图;
-(PinMap*)初始化{
self=[super init];
//appDelegate=(NSObject*)[[UIApplication sharedApplication]委托];
回归自我;
}
-(无效)zoomToUser{
//MKCoordinateRegion region=map.region;
MKCoordinateRegion=MKCoordinateRegionMake(CLLocationCoordinate2DMake((CLLocationDegrees)300,(CLLocationDegrees)300),MKCoordinateSpanMake((CLLocationDegrees)20,(CLLocationDegrees)20));//随机区域
region.center=[[appDelegate位置]坐标];
region.span.longitudeDelta/=50.0;
region.span.latitudeDelta/=50.0;
//[地图设置区域:区域动画:否];
}
这不会编译:

@implementation PinMap
@synthesize map;

-(PinMap*) init{
    self = [super init];
    //appDelegate = (NSObject<PHAppDelegate>*)[[UIApplication sharedApplication] delegate];    
    return self;
}

-(void)zoomToUser {
    MKCoordinateRegion region = map.region;
    //MKCoordinateRegion region = MKCoordinateRegionMake(CLLocationCoordinate2DMake((CLLocationDegrees)300, (CLLocationDegrees)300), MKCoordinateSpanMake((CLLocationDegrees)20,(CLLocationDegrees)20)); //random region
    region.center = [[appDelegate location] coordinate]; // <-- ERROR HERE
    region.span.longitudeDelta /= 50.0;
    region.span.latitudeDelta /= 50.0;
    [map setRegion:region animated:NO];
}
@实现PinMap
@综合地图;
-(PinMap*)初始化{
self=[super init];
//appDelegate=(NSObject*)[[UIApplication sharedApplication]委托];
回归自我;
}
-(无效)zoomToUser{
MKCoordinateRegion region=map.region;
//MKCoordinateRegion=MKCoordinateRegionMake(CLLocationCoordinate2DMake((CLLocationDegrees)300,(CLLocationDegrees)300),MKCoordinateSpanMake((CLLocationDegrees)20,(CLLocationDegrees)20));//随机区域

region.center=[[appDelegate location]coordinate];//首先,PinMap没有名为“map”的实例变量(ivar)

它有一个名为“map”的属性,您可以这样访问:

region = self.map.region;
或者它有一个叫做_map的ivar。所以你可以这样做:

region = _map.region;
但建议使用前者。您创建了一个属性,因此可能希望使用它(在initXXX和dealloc之外)

编辑

此外,UIViewController的指定初始值设定项是initWithNibName:bundle:

所以,只要确保您将UIViewController子类化,并调用其指定的初始值设定项即可

再次编辑

在这些情况下,在你的评论中,你可能有一个ivar和一个同名的属性。如果你只做@synthesis propname,那就是你得到的。但是在这种情况下,你做了@synthesis map=\u map

当您直接访问ivar而不是属性时,花点时间了解一下是值得的。否则很多事情都没有意义,还会发生其他错误。要访问属性,您必须执行“self.propertyName”(或[self-propertyName]或[self-setPropertyName:something])

如果您没有使用self,那么您就没有使用getter/setter(例如,如果getter/setter正在为您进行内存管理或初始化,这通常是一件坏事)。如果您不打算使用该属性,您还必须使用实际的ivar名称

再次编辑

我认为更改编译器是有帮助的。我建议做两件事:仔细检查所有@synthesis语句,以确保您没有要求编译器在已经存在于超类中的子类中合成ivar。在进行排序时,我建议您将ivar命名为variable_u或variable,这样您就可以轻松地查看您使用ivar与属性的位置


更重要的是,您应该真正升级到LLVM 3.0,它包含在Xcode 4.2.1中。

@synthesis
为属性创建setter和getter方法,但是它需要一些地方来存储该对象,因此您必须添加某种ivar,以便在属性中使用@synthesis

你能行

@interface ... : ... {
    Something* smth;
}

@property (nonatomic, retain) Something *smth;

@end

@implementation ...
@synthesize smth;
@end


(at)属性(非原子,保留)IBOutlet UIButton*leftButton;(at)属性(非原子,保留)IBOutlet UIButton*rightButton;…buttons=[NSArray arrayWithObjects:leftButton,rightButton,nil];这以前从来都不是问题。这是我第一次看到self在范围外的名称之外是非可选的。请参阅我的编辑。实例变量和属性是两个不同的东西,即使您有时给它们取相同的名称。好的,这对“self”很有指导意义我从未真正注意到这一点,因为我从未在自己的对象中使用getter/setter方法。正在消失的“appDelegate”ivar是我一直担心的问题,但我仍然不清楚这到底是怎么回事。更新了我的答案,加入了一些其他的东西。好吧,我只是让ivar通过\@synthesis隐式设置,作为“public”的一种速记因为我觉得复杂的setter函数是一种极端消极的模式。作为一个为什么这是一种聪明的方法的例子,我知道我没有事后考虑
region = _map.region;
@interface ... : ... {
    Something* smth;
}

@property (nonatomic, retain) Something *smth;

@end

@implementation ...
@synthesize smth;
@end
@interface ... : ... {
    Something* _smth;
}

@property (nonatomic, retain) Something *smth;

@end

@implementation ...
@synthesize smth=_smth;
@end