I've been trying to find Swift examples for FMDatabaseQueue.
All I have been able to find is Objective-C here: https://ccgus.github.io/fmdb/html/Classes/FMDatabaseQueue.html
Im not familiar with Objective-C and I'm new to Swift so I'm not sure how to port the code.
I've found what I was looking for here https://github.com/ccgus/fmdb/issues/291
There exists Swift wrappers for SQLite that may be a better fit that fmdb which can run in Swift but does not use Swift features such as type safety or error handling. See for example my GRDB.swift https://github.com/groue/GRDB.swift which was heavily influenced by ccgus/fmdb.
Related
I am working in a old project that mixes Objective-C and Swift, there is a lot of legacy code in Objective-C, so migrating everything to Swift is not realistic. New code is written in Swift but Objective-C needs to be mantained with small updates.
And I have been working with RxSwift recently and I want to start using in this old project too.
The problem is the Objective-C <-> Swift interoperability.
e.g. I can't write this:
#objc let int = BehaviorSubject<Int>(value: 42)
Because I get Property cannot be marked #objc because its type cannot be represented in Objective-C
How can I deal with this situation? Is anyone using RxSwift in a mixed objc/swift project?
The core of RxSwift is the Event enum with associated values. This enum cannot be ported into Objective-C.
The answer to your question is... You can't use RxSwift in Objective-C code.
An alternative would be use ReactiveObjC in your Objective-C code and map from RxSwift Observables to ReactiveObjC Signals.
First coding question ever!
So I'm totally new at coding and I'm taking a course in Lynda.com
The course is for swift 4 but there are certain commands that are not working or I have to write it different in order for it to work.
For example
Course says: activeQuest.sorted() Does not work
activeQuest.sort() Does work
Course says: activeQuest.intersection(completedQuests) Does not work
activeQuest.intersect(completedQuests) Does work
.symmetricDifference does not work and couldn't find any other way to write it
Why is this? Thank you!
Why is this?
It’s because the course is for Swift 4 but you are using an earlier version of Swift.
I am learning Swift by myself on MacOS. When following the tutorial and practicing the array function: <array_name>.sort(), I can get it executed but I always wonder how it works and what is the actual algorithm inside it.
So is there any way to check the certain function definitions?
If you want to check the declaration of the function/class, you can command-click on it. If you want the documentation, you can either option-click it or check it on the API reference page. If you want to see the implementation details of the Swift standard library, check the source code here at GitHub. If the implementation you are checking is in a non open-source APIs though, you can't quite check it.
I'm new to Swift and is trying to understand how to use Swift Standard Library Reference. I have past experience in Java and if I want to find a class or a class's method, I simply type e.g. String.charAt() Java SE8 in Google and the first result shown is the latest offical Oracle documentation on String class. However, if I want to find a class or method in Swift, when I type in e.g. pow() Swift Standard Library Reference, google only shows the main page to Swift Standard Library Reference, not the page of the class that actually contain the method. Could someone please tell me how to actually search the Swift Library? It would help me a great deal! Thanks in advance for any help!
if you are using Xcode just go to Help > Documentation and API Reference
I was just wondering if there is any written documentation on realm swift for iOS 7, since it is combination of objective c and swift.
Just to be clear, I'm not looking for official documentation, just some guidelines so I have a clearer view of what to use.
Thank you for any help.
You should refer to Realm Objective-C's documentation guide (https://realm.io/docs/objc/latest) and API documentation (https://realm.io/docs/objc/latest/api), which is applicable even when used from Swift.
As our installation instructions recommend (https://realm.io/docs/objc/latest/#installation), you should also be using RLMSupport.swift which adds some useful helpers to use Realm Objective-C from Swift. That file's source is its best documentation, it's pretty small and should be fairly readable.
Finally, to determine the exact Swift syntax when calling Objective-C methods, I recommend you either use autocomplete, or command-click a Realm.framework token from Swift, which should display Xcode's auto-generated Swift interface for the Realm module.