I’m an objective-c programmer and I’m wondering how low should I go (methods wise).
For example, there’s NSURL then CFURL (which is lower). I’m not sure whether using lower or higher levels will add more functionality, or are faster.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
Foundation(NSURL) framework classes are often based on the code inCoreFoundation(CFURL).With
CFtypes you generally work with opaque structs, operating on the data by using related functions. If you needed to write pure c code then you would need to useCF. Otherwise these can be a bit clunky and difficult to use in places.Objective-C classes also allow you to do additional thing like add categories etc.
Toll-Free bridging
There are times when you may need to mix and match your code slightly and it’s handy to know that a lot of types can simply be cast. e.g. an
NSStringcould be used instead of anCFStringRefAn example of when I had to do this recently was when I needed to do some url encoding (the
NSStringstringByAddingPercentEscapesUsingEncoding:didn’t quite cut it) . The function requiredCFStringRef‘s, but with a simple cast I could use myNSString‘sGenerally you can get away with and you should where possible use the
Foundationclasses (higher level of abstraction) as they will most likely provide the same functionality. There will of course be different scenarios where this is not the case, like the url encoding I had to do.