美好的一天,
我正在尝试将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.请帮我解决目标函数的问题.我很难过!
我正在尝试更新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) 我在使用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)
知道应该怎么做吗?
我通过cocoapods安装了Realm的快速项目.我不小心通过rm path/to/realm/database终端删除了realm数据库.每当我运行应用程序时,我都会收到以下错误:
'RLMException', reason: 'open() failed: No such file or directory'
Run Code Online (Sandbox Code Playgroud)
我的问题是,如何重建领域数据库?