我從QuickLook的框架協議:落實內部監督網絡協議 - 只讀屬性
/*!
* @abstract The QLPreviewItem protocol declares the methods that a QLPreviewController instance uses to access the contents of a given item.
*/
@protocol QLPreviewItem <NSObject>
@required
/*!
* @abstract The URL of the item to preview.
* @discussion The URL must be a file URL.
*/
@property(readonly) NSURL * previewItemURL;
@optional
/*!
* @abstract The item's title this will be used as apparent item title.
* @discussion The title replaces the default item display name. This property is optional.
*/
@property(readonly) NSString * previewItemTitle;
@end
/*!
* @abstract This category makes NSURL instances as suitable items for the Preview Controller.
*/
@interface NSURL (QLPreviewConvenienceAdditions) <QLPreviewItem>
@end
我試圖創建爲只讀屬性previewItemTitle getter和setter,所以我可以添加我的自定義瓷磚:
.H
#import <Foundation/Foundation.h>
#import <QuickLook/QuickLook.h>
@interface QLPreviewItemCustom : NSObject <QLPreviewItem> {
NSURL * previewItemURL;
NSString *previewItemTitle;
}
@property(readonly) NSURL * previewItemURL;
@property (readonly) NSString *previewItemTitle;
@end
.M
#import "QLPreviewItemCustom.h"
@implementation QLPreviewItemCustom
@synthesize previewItemTitle;
@synthesize previewItemURL;
@end
這樣,據我所知,我將創建合成方法的getter。我如何創建二傳手?
爲什麼你只需要使用只讀屬性的setter? – Antigluk 2012-03-12 20:16:22
因爲這是Quick Look框架的文檔所要做的事情,所以當您需要設置自定義標題時。 – Benites 2012-03-12 21:59:53