Skip to content

Instantly share code, notes, and snippets.

@nakiwo
Created August 19, 2014 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nakiwo/c7c8d56cfb1c64c8617e to your computer and use it in GitHub Desktop.
Save nakiwo/c7c8d56cfb1c64c8617e to your computer and use it in GitHub Desktop.
embedded.mobileprovisionにあるplistを取得
- (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