Tag: 声明属性

属性不会在iOS 7中初始化

我正在开发iOS 7,但我仍然必须手动写getter,否则我的属性不会被初始化。 我尝试手动综合这些属性,即使不再需要这些属性,但是这样做不行。 在我的视图控制器下面,我使用属性motionTracker ,它永远不会被初始化。 我所有的项目都有同样的问题,所以我知道这是我的一个误解。 #import "ViewController.h" #import "TracksMotion.h" @interface ViewController () @property (weak, nonatomic) IBOutlet UIButton *startRecording; @property (weak, nonatomic) IBOutlet UIButton *stopRecording; @property (strong, nonatomic) TracksMotion *motionTracker; @end @implementation ViewController @synthesize motionTracker = _motionTracker; – (void)startMyMotionDetect { [self.motionTracker startsTrackingMotion]; } @end motionTracker拥有方法startsTrackingMotion的公共API,所以我不知道为什么这不起作用。 #import <Foundation/Foundation.h> #import <CoreMotion/CoreMotion.h> @interface TracksMotion : NSObject – (void)startsTrackingMotion; […]