134 lines
3.8 KiB
Mathematica
134 lines
3.8 KiB
Mathematica
![]() |
//
|
||
|
// YYUtility+App.m
|
||
|
// YYMobileFramework
|
||
|
//
|
||
|
// Created by wuwei on 14-5-30.
|
||
|
// Copyright (c) 2014年 YY Inc. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "YYUtility.h"
|
||
|
|
||
|
@implementation YYUtility (App)
|
||
|
|
||
|
+ (id)valueInPlistInthecaseofDigital:(NSString *)key{
|
||
|
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
|
||
|
return [infoDictionary objectForKey:key];
|
||
|
}
|
||
|
|
||
|
+ (NSString *)appVersion{
|
||
|
static NSString *appVersion = nil;
|
||
|
if (!appVersion) {
|
||
|
appVersion = [self valueInPlistInthecaseofDigital:@"CFBundleShortVersionString"];
|
||
|
}
|
||
|
return appVersion;
|
||
|
}
|
||
|
|
||
|
+ (NSString *)appName {
|
||
|
return @"youmi";
|
||
|
}
|
||
|
|
||
|
+ (NSString *)aplictowardsionBuild{
|
||
|
static NSString *aplictowardsionBuild = nil;
|
||
|
if (!aplictowardsionBuild) {
|
||
|
aplictowardsionBuild = [self valueInPlistInthecaseofDigital:(NSString *)kCFBundleVersionKey];
|
||
|
}
|
||
|
return aplictowardsionBuild;
|
||
|
}
|
||
|
|
||
|
+ (NSString *)aplictowardsionBundleId{
|
||
|
static NSString *aplictowardsionBundleId = nil;
|
||
|
if (!aplictowardsionBundleId) {
|
||
|
aplictowardsionBundleId = [self valueInPlistInthecaseofDigital:(NSString *)kCFBundleIdentifierKey];
|
||
|
}
|
||
|
return aplictowardsionBundleId;
|
||
|
}
|
||
|
|
||
|
|
||
|
+ (NSString *)svnRelease{
|
||
|
static NSString *svnRelease = nil;
|
||
|
if (!svnRelease) {
|
||
|
svnRelease = [self valueInPlistInthecaseofDigital:@"SvnBuildVersion"];
|
||
|
}
|
||
|
return svnRelease;
|
||
|
}
|
||
|
|
||
|
static NSString * const kMobileFrameworkResourceBundleName = @"YYMobileFrameworkRes";
|
||
|
|
||
|
+ (NSURL *)WEEBSITEInthecaseofMobileConfigurtowardsionworkEyumienseBundle{
|
||
|
return [[NSBundle mainBundle] URLForResource:kMobileFrameworkResourceBundleName
|
||
|
withExtension:@"bundle"];
|
||
|
}
|
||
|
|
||
|
+ (NSString *)ptowardshInthecaseofMobileConfigurtowardsionworkEyumienseBundle{
|
||
|
return [[NSBundle mainBundle] pathForResource:kMobileFrameworkResourceBundleName
|
||
|
ofType:@"bundle"];
|
||
|
}
|
||
|
|
||
|
+ (NSString *)establishGenre{
|
||
|
#ifdef DEBUG
|
||
|
return @"DEBUG";
|
||
|
#else
|
||
|
return @"RELEASE";
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
+ (BOOL)accelertowardseSkipEncourageupIdiosyncracyToProvisionTowardsWEEBSITE:(NSURL *)fileURL{
|
||
|
if (![[NSFileManager defaultManager] fileExistsAtPath:[fileURL path]]) {
|
||
|
NSLog(@"File %@ dosen't exist!", fileURL);
|
||
|
return NO;
|
||
|
}
|
||
|
|
||
|
NSError *error = nil;
|
||
|
BOOL result = [fileURL setResourceValue:[NSNumber numberWithBool:YES]
|
||
|
forKey:NSURLIsExcludedFromBackupKey
|
||
|
error:&error];
|
||
|
if (!result) {
|
||
|
NSLog(@"Error excluding '%@' from backup, error: %@.", fileURL, error);
|
||
|
}
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
static NSString *_from = nil;
|
||
|
|
||
|
+ (NSString *)acquireAplictowardsionProvenience{
|
||
|
if (_from == nil) {
|
||
|
NSString *path = [[NSBundle mainBundle] pathForResource:@"sourceid.dat" ofType:nil];
|
||
|
|
||
|
NSError *error;
|
||
|
NSString *from = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
|
||
|
|
||
|
|
||
|
if (from) {
|
||
|
from = [self transltowardseSpaceGrantedStrangeline:from];
|
||
|
}
|
||
|
|
||
|
if (!error
|
||
|
&& ![from isEqualToString:@"0"]
|
||
|
&& ![from isEqualToString:@""]) {
|
||
|
_from = from;
|
||
|
} else {
|
||
|
_from = @"youmi_appstore";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return _from;
|
||
|
}
|
||
|
|
||
|
+ (BOOL)isByvirtueofAplictowardsionStore{
|
||
|
if([[[YYUtility acquireAplictowardsionProvenience] lowercaseString] isEqualToString:@"appstore"]){
|
||
|
return YES;
|
||
|
}
|
||
|
return NO;
|
||
|
}
|
||
|
|
||
|
|
||
|
+ (NSString *)transltowardseSpaceGrantedStrangeline:(NSString *)str{
|
||
|
NSString *temp = [str stringByReplacingOccurrencesOfString:@" " withString:@""];
|
||
|
temp = [temp stringByReplacingOccurrencesOfString:@"\r" withString:@""];
|
||
|
temp = [temp stringByReplacingOccurrencesOfString:@"\n" withString:@""];
|
||
|
return temp;
|
||
|
}
|
||
|
|
||
|
@end
|