-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMethodSwizzle.m
35 lines (27 loc) · 1019 Bytes
/
MethodSwizzle.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
//
// MethodSwizzle.m
// Salento Camping
//
// Created by Francesco Piero Paolicelli on 05/03/13.
// Copyright (c) 2013 Francesco Piero Paolicelli. All rights reserved.
//
#import "MethodSwizzle.h"
#import <MessageUI/MessageUI.h>
@implementation MFMailComposeViewController (force_subject)
- (void)setMessageBodySwizzled:(NSString*)body isHTML:(BOOL)isHTML
{
if (isHTML == YES) {
NSRange range = [body rangeOfString:@"<title>.*</title>" options:NSRegularExpressionSearch|NSCaseInsensitiveSearch];
if (range.location != NSNotFound) {
NSScanner *scanner = [NSScanner scannerWithString:body];
[scanner setScanLocation:range.location+7];
NSString *subject = [NSString string];
if ([scanner scanUpToString:@"</title>" intoString:&subject] == YES) {
NSLog(@"subject %@",subject);
[self setSubject:subject];
}
}
}
[self setMessageBodySwizzled:body isHTML:isHTML];
}
@end