小编imn*_*lly的帖子

带有URL内容的字符串?

所以在我下载最近的更新之前,以下代码对我有用:

var g_home_url = String.stringWithContentsOfURL(NSURL(string: url_string), encoding: NSUTF8StringEncoding, error: nil) // Gives me an error: "String.Type does not have a member names stringWithContentsOfUrl"
Run Code Online (Sandbox Code Playgroud)

我很迷惑.在swift中采用以下Objective-c方法的正确方法是什么?

NSString * g_home_url = [[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:home_url] encoding:NSUTF8StringEncoding error:nil];
Run Code Online (Sandbox Code Playgroud)

ios swift

17
推荐指数
2
解决办法
3万
查看次数

在swift中解压缩文件

如何在swift中解压缩文件?在Objective-C中,我使用了SSZipArchive,我喜欢它.如下面的代码所示.我怀疑如果我决定保留SSZipArchive,我将不得不将Objective-C文件桥接到我的Swift文件.是否有任何更新的第三方,或更好的Apple文档在Swift中解压缩文件?

NSString *zipPath = [self.globalFileStrucure stringByAppendingPathComponent:@"zipfile.zip"];

[data writeToFile:zipPath options:0 error:&error];

BOOL unZipped = 0;

unZipped = [SSZipArchive unzipFileAtPath:zipPath toDestination:self.globalFileStrucure];
Run Code Online (Sandbox Code Playgroud)

objective-c unzip ios swift ssziparchive

8
推荐指数
2
解决办法
1万
查看次数

标签 统计

ios ×2

swift ×2

objective-c ×1

ssziparchive ×1

unzip ×1