mirror of
https://github.com/samsonjs/samhuri.net-ios.git
synced 2026-04-27 15:07:44 +00:00
improved handling of new posts from the pasteboard
This commit is contained in:
parent
7283329410
commit
24161559a9
1 changed files with 8 additions and 2 deletions
|
|
@ -19,6 +19,7 @@
|
|||
#import "PostCollection.h"
|
||||
#import "ModelStore.h"
|
||||
#import "UIImage+FontAwesome.h"
|
||||
#import "NSString+marshmallows.h"
|
||||
|
||||
@interface PostsViewController ()
|
||||
|
||||
|
|
@ -273,9 +274,14 @@ static const NSUInteger SectionPublished = 1;
|
|||
}
|
||||
|
||||
- (IBAction)insertNewObject:(id)sender {
|
||||
NSString *title = [UIPasteboard generalPasteboard].string;
|
||||
NSURL *url = [UIPasteboard generalPasteboard].URL;
|
||||
// TODO: image, anything else interesting
|
||||
NSString *title = [[UIPasteboard generalPasteboard].string mm_stringByTrimmingWhitespace];
|
||||
if ([title hasPrefix:@"http"]) {
|
||||
if (!url) {
|
||||
url = [NSURL URLWithString:title];
|
||||
}
|
||||
title = nil;
|
||||
}
|
||||
Post *post = [Post newDraftWithTitle:title body:nil url:url];
|
||||
[self.drafts insertObject:post atIndex:0];
|
||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:SectionDrafts];
|
||||
|
|
|
|||
Loading…
Reference in a new issue