Created
August 19, 2014 02:19
-
-
Save nakiwo/c7c8d56cfb1c64c8617e to your computer and use it in GitHub Desktop.
embedded.mobileprovisionにあるplistを取得
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSDictionary *)embeddedMobileprovisionPlist | |
{ | |
NSString *path = [[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"]; | |
if (!path) { | |
return nil; | |
} | |
NSData *profileData = [NSData dataWithContentsOfFile:path]; | |
if (!profileData) { | |
return nil; | |
} | |
NSData *startData = [@"<?xml" dataUsingEncoding:NSUTF8StringEncoding]; | |
NSData *endData = [@"</plist>" dataUsingEncoding:NSUTF8StringEncoding]; | |
NSDictionary *plist; | |
NSRange startRange = [profileData rangeOfData:startData options:0 range:NSMakeRange(0, profileData.length)]; | |
if (startRange.location != NSNotFound) { | |
NSRange endRange = [profileData rangeOfData:endData options:0 range:NSMakeRange(0, profileData.length)]; | |
if (endRange.location != NSNotFound) { | |
NSRange plistRange; | |
plistRange.location = startRange.location; | |
plistRange.length = NSMaxRange(endRange) - startRange.location; | |
NSData *plistData = [profileData subdataWithRange:plistRange]; | |
plist = [NSPropertyListSerialization propertyListWithData:plistData | |
options:0 | |
format:NULL | |
error:NULL]; | |
} | |
} | |
return plist; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment