How costly performance-wise are these actions in iPhone objective-C?
Posted
by Alex Gosselin
on Stack Overflow
See other posts from Stack Overflow
or by Alex Gosselin
Published on 2010-03-13T17:11:07Z
Indexed on
2010/03/13
17:15 UTC
Read the original article
Hit count: 163
This is really a few questions in one, I'm wondering what the performance cost is for these things, as I haven't really been following a best practice of any sort for these. The answers may also be useful to other readers, if somebody knows these.
(1) If I need the core data managed object context, is it bad to use
#import "myAppDelegate.h"
//farther down in the code:
NSManagedObjectContext *context = [(myAppDelegate.h*)[[UIApplication sharedApplication] delegate] managedObjectContext];
as opposed to leaving the warning you get if you don't cast the delegate?
(2) What is the cheapest way to hard-code a string? I have been using
return @"myString";
on occasion in some functions where I need to pass it to a variety of places, is it better to do it this way:
static NSString *str = @"myString";
return str;
(3) How costly is it to subclass an object i wrote vs. making a new one, in general?
(4) When I am using core data and navigating through a hierarchy of some sort, is it necessary to turn things back into faults somehow after I read some info from them? or is this done automatically?
Thanks for any help.
© Stack Overflow or respective owner