(NSString *)
getApplicationUsage{
double directorySizeInBytes = 0.0f;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationDirectory, NSUserDomainMask, YES);
NSString *pathStr = [paths objectAtIndex:0];
pathStr = [pathStr stringByDeletingLastPathComponent]; //REMOVE THE LAST PATH COMPONENT i.e /Applications
NSDirectoryEnumerator *enumrator = [[NSFileManager defaultManager] enumeratorAtPath:pathStr];
for (NSString *itemPath in enumrator) {
itemPath = [pathStr stringByAppendingPathComponent:itemPath];
NSDictionary *attr = [[NSFileManager defaultManager] attributesOfItemAtPath:itemPath error:nil];
directorySizeInBytes = directorySizeInBytes + [[attr objectForKey:NSFileSize] doubleValue];
}
NSString *applicationUsage = [NSString stringWithFormat:@"%0.0f MB",directorySizeInBytes /1000000];
return applicationUsage;
}
Run Code Online (Sandbox Code Playgroud) 我从几个博客中看到了有关此问题的混合答案.我听说此功能仅在Xcode 7在秋季发布时才可用,但同样有人说你现在可以在自己的设备上进行测试.如果可能的话,非常感谢任何指向优秀教程的链接.
我使用Objective-C代码在GameCenter中更新了排行榜和成就.但问题是每当我使用代码打开GameCenterController时它会显示Facebook Like unavailable.我该如何解决?我还在电话设置中登录了Facebook.我该怎么办?
我想在用户选择记住我复选框时保存密码.我有这样的代码:这是正确的吗?
在Appdelegate.m
@property(strong,nonatomic)NSString *savedno;
Run Code Online (Sandbox Code Playgroud)
在.m文件中
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
self.navcontrol =[[UINavigationController alloc]initWithRootViewController:self.viewController ];
self.window.rootViewController = self.navcontrol;
[self.window makeKeyAndVisible];
self.savedno=[[NSUserDefaults standardUserDefaults]objectForKey:@"pass"];
if(savedno==nil)
{
NSDictionary *saveDict=[NSDictionary dictionaryWithObject:savedno forKey:@"pass"];
[[NSUserDefaults standardUserDefaults]registerDefaults:saveDict];
}
return YES;
}
- (void)applicationWillTerminate:(UIApplication *)application
{
/*
Called when the application is about to terminate.
Save data if appropriate.
See also applicationDidEnterBackground:.
*/
NSUserDefaults *userdefault=[NSUserDefaults …Run Code Online (Sandbox Code Playgroud)