#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
@interface CustomAnnotation : NSObject <MKAnnotation>
{
CLLocationCoordinate2D coordinate;
NSString *title;
NSString *subTitle;
}
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *subtitle;
- (id)initWithLocation:(CLLocationCoordinate2D)coords title:(NSString *)aTitle andSubtitle:(NSString*)aSubtitle;
@end
我正在做一個具有上述代碼的教程。iOS /目標C:代碼說明
我的問題:
- 是什麼在支撐與@property定義一個變量之間的區別?
- 爲什麼我們需要在兩個地方定義變量?
- 在.h和.m文件中聲明#import有什麼區別?
請回答所有三個問題。
1st ...爲了訪問其他類中的變量,我們使用@property ...如果你沒有,那麼你不能在其他類中使用....第二,如果你聲明與'財產'你不需要再次聲明他們...... 3rd--無法讓你 – 2013-04-10 15:15:44