-
Notifications
You must be signed in to change notification settings - Fork 63
Closed
Labels
A-frameworkAffects the framework crates and the translator for themAffects the framework crates and the translator for themdocumentationImprovements or additions to documentationImprovements or additions to documentation
Milestone
Description
I recently used 2 crates from this repository: icrate and objc2. Intitially I've seen the README in this repository which looked like I may have finally found a crate which will do the heavy-lifting of interacting with most Foundation types and provide Objective-C interoperability, however I've got a LOT of issues which makes me re-consider using the objc crate instead which was much lower-level and certainly has more unsafe. Nevertheless, I have found workarounds for now, I just wanted to leave a list of what I felt very unintuitive and undocumented and where I spent a considerable amount of time:
- The
Foundationfeature oficrateisn't really a feature it's about 1% of one. Intuitively this looked like the Apple framework of the same name containing all base objects likeNSString,NSDictionary, etc; this was however not the case. To get the actual feature you needFoundation_all, that's highly unintuitive and totally undocumented. - The
NSMutableDictionarywrapper inicratehas a broken un-callable function namedinsert, only theinsert_idfunction is callable, that's also very unintuitive and undocumented as well, considering the example for that function usesinsert_idinstead ofinsert. - Use of
AnyObjectandNSObject. I found these wrappers mostly unintuitive as you can't do anything with them (i.e: no way to turn another object intoNSObjectas everything requires full specified type name), theintoand most other built-in trait function are not implemented or not easily usable and I couldn't find a direct way to easily.into()aNSStringto turn it into aNSObjector aAnyObject. To do this one needs to callId::<NSObject>::cast(mystring), the documentation for this behavior is nowhere to be found and I lost nearly 30 minutes figuring out how to do this by reading the very large code base as I was expecting to see a trait which would do the conversion between any wrapper struct andAnyObject/NSObject. I was nearly at giving up on this crate and returning to the good oldobjccrate which I know is working and wouldn't have caused such a pain to crate and fill a simpleNSMutableDictionary. - It is impossible to turn an
Id<NSError>into a*mut NSError, at least not easily, more on that later. That means you cannot easily call into other functions implemented in XCode/Objective-C. In order to do that I had to use a function I feel shouldn't be necessary:std::mem::transmute(Id::as_ptr(&obj)). Again I was looking for a.into_raw_ptror.as_mut_ptrinside theNSErrorwrapper.
reneleonhardt
Metadata
Metadata
Assignees
Labels
A-frameworkAffects the framework crates and the translator for themAffects the framework crates and the translator for themdocumentationImprovements or additions to documentationImprovements or additions to documentation