小编Dea*_*Lee的帖子

Swift 3.0 FileManager.fileExists(atPath :)总是返回false

当我使用方法.fileExists(atPath:)来判断文件是否存在于文件系统中时,该方法总是向我返回false.我检查了文件系统,文件确实存在.这是我的代码:

let filePath = url?.path
var isDir : ObjCBool = false
if(self.fileManager.fileExists(atPath: filePath!, isDirectory: &isDir)){
     let result = NSData(contentsOfFile: filePath!)
}
Run Code Online (Sandbox Code Playgroud)

要么

let filePath = url?.path
if(self.fileManager.fileExists(atPath: filePath!)){
     let result = NSData(contentsOfFile: filePath!)
}
Run Code Online (Sandbox Code Playgroud)

始终会跳过if子句.

nsfilemanager ios swift

32
推荐指数
5
解决办法
2万
查看次数

rxSwift中的observable和subject之间有什么区别

观察和主题之间有什么区别.当我定义一个可观察的类型变量时.它可以发出onNext,onComplete,onDispose.但是主题也可以这样做.什么时候应该使用observable,在什么情况下我应该使用subject?

ios swift rx-swift

12
推荐指数
1
解决办法
3875
查看次数

属性'self.title'未在swift中的super.init调用中初始化

我有一个派生自UIView的类,但我初始化它总是显示错误说"属性'self.title'未在swift中的super.init调用中初始化"

这是我的代码

class A: UIView
{

var title : String
var recordUrl : String
var content : String

required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") }

init(frame :  CGRect ,title : String, recordUrl : String  , content : String)
{
    super.init(frame: frame)

    self.title = title
    self.recordUrl = recordUrl
    self.content = content
}
}
Run Code Online (Sandbox Code Playgroud)

initialization uikit ios swift

6
推荐指数
1
解决办法
7706
查看次数

标签 统计

ios ×3

swift ×3

initialization ×1

nsfilemanager ×1

rx-swift ×1

uikit ×1