小编Mee*_*eet的帖子

如何在iPhone中获取应用程序目录的大小?

(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)

iphone nsfilemanager

5
推荐指数
1
解决办法
1775
查看次数

我可以使用Xcode 6.4在我的iPhone上测试Swift应用程序吗?没有开发人员许可证?

我从几个博客中看到了有关此问题的混合答案.我听说此功能仅在Xcode 7在秋季发布时才可用,但同样有人说你现在可以在自己的设备上进行测试.如果可能的话,非常感谢任何指向优秀教程的链接.

iphone xcode ios swift

5
推荐指数
1
解决办法
1718
查看次数

如何在适用于iOS 8的GameCenter中启用Facebook?

我使用Objective-C代码在GameCenter中更新了排行榜和成就.但问题是每当我使用代码打开GameCenterController时它会显示Facebook Like unavailable.我该如何解决?我还在电话设置中登录了Facebook.我该怎么办?

ios game-center

5
推荐指数
1
解决办法
2244
查看次数

如何使用NSUserDefault在UserDefault中保存密码?

我想在用户选择记住我复选框时保存密码.我有这样的代码:这是正确的吗?

在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)

iphone

0
推荐指数
1
解决办法
585
查看次数

标签 统计

iphone ×3

ios ×2

game-center ×1

nsfilemanager ×1

swift ×1

xcode ×1