iphone学习感悟

来源:互联网 发布:2016开淘宝店铺流程图 编辑:程序博客网 时间:2024/06/11 00:52

以下的文章可能不一定正确,如果大家发现了不正确的地方,还希望大家能够指正,谢谢!!

在springboard下有一个函数,貌似可以点亮屏幕调用另外一个应用,不过没有经过验证,详见网址 http://networkpx.googlecode.com/svn-history/r335/trunk/hk.kennytm.grip/src/GriPServer.m和http://iphonedevwiki.net/index.php/SpringBoard.app/MIG_subsystem

[SpringBoard applicationOpenURL:publicURLsOnly:]




@synthesize window=_window; 怎么理解? 


我们在xocde中建立一个向导工程(比如基于视图的工程),经常会看到有下面的语句


// .h
#import <UIKit/UIKit.h>
@class HelloWorldMailViewController;
@interface HelloWorldMailAppDelegate : NSObject <UIApplicationDelegate> {
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet HelloWorldMailViewController *viewController;
@end


// .m
// ...
@implementation HelloWorldMailAppDelegate
@synthesize window=_window;
@synthesize viewController=_viewController;

// ...
@end


在 32-bit 时,如果类的 @interface 部分没有进行 ivar 声明,但有 @property 声明,在类的 @implementation 部分有响应的 @synthesize,则会得到类似下面的编译错误:
Synthesized property 'xX' must either be named the same as a compatible ivar or must explicitly name an ivar
在 64-bit时,运行时系统会自动给类添加 ivar,添加的 ivar 以一个下划线"_"做前缀。
上面声明部分的 @synthesize window=_window; 意思是说,window 属性为 _window 实例变量合成访问器方法。


其实也就相当于以下的代码

// .h
#import <UIKit/UIKit.h>
@class HelloWorldMailViewController;
@interface HelloWorldMailAppDelegate : NSObject <UIApplicationDelegate> {

UIWindow *window;

 HelloWorldMailViewController *viewController; 

}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet HelloWorldMailViewController *viewController;
@end


// .m
// ...
@implementation HelloWorldMailAppDelegate
@synthesize window;
@synthesize viewController; 

// ...
@end

原创粉丝点击