基于iOS的APP“好妈妈”开发日志二——解决老版本leancloud.framework中的语法错误和leancloud登陆问题

基于iOS的APP“好妈妈”开发日志二

老版本leancloud.framework中的语法错误

由于我在xcodeproj文件外又错误添加了一个文件夹,删不掉,可能导致后来程序运行经常出现“app无法在这个时候打开”的错误,我就干脆删掉了之前的xcodeproj文件以及上层目录,但幸运的是,Pods目录里的文件没有丢失,这次拿来做一下对比,是关于老版本leancloud的framework包里的语法错误。

文件目录

 这是文件的目录,都是oc语法的应用问题,点击自动fix就可以了。

像这样

接下来是比较关键,不能fix解决的东西。
文件目录

关于类型转换的错误

解决方法如下
let namedata = typeEncoding[typeEncoding.characters.index(typeEncoding.startIndex, offsetBy: 2)..<typeEncoding.characters.index(typeEncoding.endIndex, offsetBy: -1)]
        let name = String(namedata)
        //let name = newname.data(using: String.Encoding.utf8)!
        if let subclass = objc_getClass(name) as? AnyClass {
            if let type = subclass as? LCValue.Type {
                return type
            }
        }

下一个在文件目录

报错

解决方法如下
let classes = AutoreleasingUnsafeMutablePointer<AnyClass>(UnsafeMutablePointer<UInt8>.allocate(capacity: MemoryLayout<AnyClass>.size * Int(count)))
        
        for i in 0..<Int(objc_getClassList(classes, count)) {
            guard let someclass:AnyClass = classes[i] else {
                continue
}

最后一个
错误

解决方法如下
for i in 0..<Int(count) {
            if let property: objc_property_t? = properties[i] {
                result.append(property!)
            }
}

leancloud的登陆问题

按照官网写出来的敲是这样的

LCApplication.default.set(
    id:  "你项目leancloud生成的id",
    key: "你项目leancloud生成的密码"
)

但这样的话会出现报错

Use of unresolved identifier 'LCApplication'

需要改成

AVOSCloud.setApplicationId("你项目leancloud生成的id", clientKey: "你项目leancloud生成的密码")
LeanCloud.initialize(applicationID: "你项目leancloud生成的id", applicationKey: "你项目leancloud生成的密码")

努力!奋斗!⛽️luhh

猜你喜欢

转载自blog.csdn.net/qq_39463598/article/details/87975405