Tôi có một giao thức từ khuôn khổ QuickLook:Triển khai iOS procotol - tài sản readonly
/*!
* @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
Tôi đang cố gắng để tạo ra các phương thức getter và setter cho các tài sản previewItemTitle readonly vì vậy tôi có thể thêm gạch tùy chỉnh của tôi:
.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
Bằng cách này, như tôi hiểu, tôi sẽ tạo ra chỉ getter với phương pháp tổng hợp. Làm thế nào tôi có thể tạo setter?
Tại sao bạn cần setter cho tài sản chỉ đọc? – Antigluk
Bởi vì đây là những gì tài liệu hướng dẫn của khung nhìn Quick Look nói, khi bạn cần đặt tiêu đề tùy chỉnh. – Benites