-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathBasicPreviewItem.m
executable file
·39 lines (35 loc) · 1.03 KB
/
BasicPreviewItem.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//
// BasicPreviewItem.m
// Coding_iOS
//
// Created by Ease on 14/11/20.
// Copyright (c) 2014年 Coding. All rights reserved.
//
#import "BasicPreviewItem.h"
@implementation BasicPreviewItem
@synthesize previewItemTitle = _previewItemTitle;
@synthesize previewItemURL = _previewItemURL;
+ (BasicPreviewItem *)itemWithUrl:(NSURL *)itemUrl{
if (!itemUrl) {
return nil;
}
NSString *itemTitle = itemUrl.absoluteString;
itemTitle = [itemTitle stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
itemTitle = [[itemTitle componentsSeparatedByString:@"/"] lastObject];
itemTitle = [[itemTitle componentsSeparatedByString:@"|||"] firstObject];
return [[BasicPreviewItem alloc] initWithUrl:itemUrl title:itemTitle];
}
- (instancetype)initWithUrl:(NSURL *)itemUrl title:(NSString *)title{
self = [super init];
if (self) {
_previewItemURL = itemUrl;
_previewItemTitle = title;
}
return self;
}
-(void)dealloc
{
_previewItemURL = nil;
_previewItemTitle = nil;
}
@end