小编wee*_*Pee的帖子

苦苦挣扎将Objective C选择器和目标签名转换为Swift

美好的一天,

我正在尝试将Objective C片段转换为Swift.我理解选择器可以通过将其放在一个字符串中直接翻译,但我无法理解Objective C签名:

Objectice C选择器(第二个参数):

UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
Run Code Online (Sandbox Code Playgroud)

目标:

- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{
Run Code Online (Sandbox Code Playgroud)

我的问题是:1.我可以简单地将选择器传递给:

UIImageWriteToSavedPhotosAlbum(image, self, "image:didFinishSavingWithError:contextInfo:", nil);
Run Code Online (Sandbox Code Playgroud)

2.请帮我解决目标函数的问题.我很难过!

objective-c selector ios swift

3
推荐指数
1
解决办法
2060
查看次数

更新RLMObject是Swift/IOS

我正在尝试更新Realm中RLMObject的现有实例.

我找不到这样做的方法..

请举个例子.

我可以保存和删除对象,但无法弄清楚如何使用以下方法更新对象:

//Find Existing 
let predicate = NSPredicate(format: "formname = %@",formname)
var localTypes = FormTypeLocal.objectsWithPredicate(predicate)
if (localTypes.count == 1 ){
var existingForm : FormTypeLocal = localTypes[0] as FormTypeLocal     
existingForm.customProp = "newVal"
//Now I need to update?????

let realm = RLMRealm.defaultRealm()
//
// Add to the Realm inside a transaction
realm.beginWriteTransaction()
realm.addObject(newForm)
realm.commitWriteTransaction()
//Delete
realm.beginWriteTransaction()
realm.deleteObject(newForm)
realm.commitWriteTransaction()
Run Code Online (Sandbox Code Playgroud)

realm ios swift

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

Swift:将UIImageOrientation转换为ALAssetOrientation

我在使用ENUMS时遇到了问题,尤其是对于ALAssetOrientation的UIImageOrientation

我试过了 :

  var orientation : ALAssetOrientation = image.imageOrientation.toRaw()
Run Code Online (Sandbox Code Playgroud)

  var orientation : ALAssetOrientation = image.imageOrientation as ALAssetOrientation
Run Code Online (Sandbox Code Playgroud)

知道应该怎么做吗?

enums ios swift

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

重建领域数据库

我通过cocoapods安装了Realm的快速项目.我不小心通过rm path/to/realm/database终端删除了realm数据库.每当我运行应用程序时,我都会收到以下错误:

'RLMException', reason: 'open() failed: No such file or directory'
Run Code Online (Sandbox Code Playgroud)

我的问题是,如何重建领域数据库?

realm ios swift

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

标签 统计

ios ×4

swift ×4

realm ×2

enums ×1

objective-c ×1

selector ×1