English 中文(简体)
1. 财产与点人之间的区别,而不是客观的区别
原标题:Differences between properties with pointer and not in objective-c

I m attending the course of IOS development on itunesU (from Stanford University).
And i got a big doubt about an attribute of a class created in one of this lectures. Let me explain with some code :

我有“面对面意见”这一类,其使命是求取一面,该类的一个属性是“替代”,这是必须执行面对面意见的一个目标。

这里是接口守则:

#import <UIKit/UIKit.h>
@class FaceView;

@protocol FaceViewDelegate
-(float)smileForFaceView:(FaceView *)requestor;
@end

@interface FaceView : UIView {
    id <FaceViewDelegate> delegate;
    CGFloat scale;
}

@property CGFloat scale;
@property (assign) id <FaceViewDelegate> delegate;

@end

I can t understand why delegate is not a pointer to object, but directly an object. Someone could kindly tell me more about this implementation choiche? is this correct ? why ? Thank you so much!

最佳回答

这是物体的指点。 <代码>id已经成为一个点。 因此,当你宣布“<代码>id”的变数时,就不需要点数。 因此,这些声明基本相同(即你可以完全以同样的方式使用我的IDObj和我的Obj):

// myIDObj and myObj are both pointers to objects
id myIDObj = [[NSObject alloc] init];
NSObject* myObj = [[NSObject alloc] init];
问题回答

www.un.org/Depts/DGACM/index_french.htm <代码>id 类型定义为:

typedef struct objc_object {
    Class isa;
} *id;

因此,它已经成为一个要点。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签