-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMUSShareManager.m
43 lines (31 loc) · 1.1 KB
/
MUSShareManager.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
40
41
42
43
//
// MUSShareManager.m
// Muse
//
// Created by Leo Kwan on 10/15/15.
// Copyright © 2015 Leo Kwan. All rights reserved.
//
#import "MUSShareManager.h"
@implementation MUSShareManager
+(UIActivityViewController *)returnShareSheetWithEntry:(Entry *)entry {
//SHARE IMAGE IF THERE IS ONE
UIImage *entryImage = [[UIImage alloc] init];
if (entry.coverImage != nil) {
entryImage = [UIImage imageWithData:entry.coverImage];
}
//SHARE CONTENT IF THERE IS
NSString *entryTitle = entry.titleOfEntry;
NSString *entryBody = entry.content;
if (entryTitle == nil)
entryTitle = @"";
if (entryBody == nil) {
entryBody = @"";
}
NSString *completeEntry = [NSString stringWithFormat:@"%@ \n \n %@", entryTitle, entryBody];
NSArray *postItems = @[entryImage, completeEntry];
UIActivityViewController *shareSheet = [[UIActivityViewController alloc]
initWithActivityItems:postItems
applicationActivities:nil];
return shareSheet;
}
@end