retain

does something need to hold a reference to a singleton objective-c object in order to preserve it through the life of an IOS app?

会有一股神秘感。 提交于 2019-12-24 04:05:23
问题 does something need to hold a reference to a singleton objective-c object in order to preserve it through the life of an IOS app? For example if if AppDelegate you created/instantiated a singleton object but didn't retain it, would this instance (with instance variable data) be available later on in the iPhone app? In other words to ensure data in the singleton remains intact, in the App Delegate where it was initially created, would the App Delegate need to retain it to one of it's instance

Rearranging variables in a sas dataset- alphabetical order

我怕爱的太早我们不能终老 提交于 2019-12-24 03:26:12
问题 I have like 500 columns of dataset, and I want to rearrange all the variables in an alphabetical order. How can I do that in any other way than using retain statement before set statement? 回答1: You can generate the list of variable names dynamically, and create a new dataset using PROC SQL . proc sql ; select name into :VARLIST separated by ', ' from dictionary.columns where libname = 'SASHELP' and memname = 'CLASS' order by name ; quit ; proc sql ; create table ordered as select &VARLIST

UIDocument never calling dealloc

旧巷老猫 提交于 2019-12-23 19:45:24
问题 I have an issue where I can't seem to dealloc UIDocument (used in iCloud) After running an NSMetaDataQuery to look for the document as follows.. NSMetadataQuery *query = [[NSMetadataQuery alloc] init]; _query = query; [query setSearchScopes:[NSArray arrayWithObject: NSMetadataQueryUbiquitousDocumentsScope]]; NSPredicate *pred = [NSPredicate predicateWithFormat: @"%K == %@", NSMetadataItemFSNameKey, kFILENAME]; [query setPredicate:pred]; [[NSNotificationCenter defaultCenter] addObserver:self

How to keep a strong reference inside of a block without having a retain cycle

一世执手 提交于 2019-12-23 02:19:06
问题 I have a block attached to a button (using this category): __unsafe_unretained typeof(UIImage) *weakPic = originalPic; [button addEventHandler:^{ switch (state) { case state1: { UIViewController *vc = //some VC vc.pic = weakPic; // weakPic is nil at this point // putting originalPic here would solve my problem // but then I would have a retain cycle } case state2: { // other stuff } } }]; the action associated with the button is different depending on the state. Here is the problem: I must

Will self retain within block?

末鹿安然 提交于 2019-12-22 17:58:59
问题 Before/After call the block, the retaincount is always 1. From apple block doc we know that the self should retain. Can anyone know why? NSLog(@"Before block retain count: %d", [self retainCount]); void (^block)(void) = ^(void){ UIImage* img = [UIImage imageNamed:@"hometown.png"]; [self setImage:img]; NSLog(@"After block retain count: %d", [self retainCount]); }; block(); 回答1: First, retainCount is useless. Don't call it. . Blocks only retain captured objects when the block is copied. Thus,

Is NSObject's retain method atomic?

旧街凉风 提交于 2019-12-21 07:55:38
问题 Is NSObject's retain method atomic? For example, when retaining the same object from two different threads, is it promised that the retain count has gone up twice, or is it possible for the retain count to be incremented just once? Thanks. 回答1: NSObject as well as object allocation and retain count functions are thread-safe — see Appendix A: Thread Safety Summary in the Thread Programming Guide. Edit : I’ve decided to take a look at the open source part of Core Foundation. In CFRuntime.c, _

iOS ARC - weak and strong properties

孤街醉人 提交于 2019-12-21 05:05:19
问题 I'm trying to understand the way ARC works, and as far as I know, I should be doing something wrong here. This is the code I'm using: Interface: @interface ViewController : UIViewController{ } @property (strong, nonatomic) NSString * myString ; @property (weak, nonatomic) NSString * myPointer ; Implementation: - (void)viewDidLoad{ [super viewDidLoad]; self.myString = @"Hello world!" ; // myString is strong self.myPointer = self.myString ; // myPointer var is weak [self performSelector:

NSZombies are eating my app's brain!

喜欢而已 提交于 2019-12-21 04:56:08
问题 I've got a retain/release problem. My View is pretty complicated so I've set NSZombieEnabled to YES and am trying to locate which, exactly, object is causing me grief. To speed this process along I'm wondering if there hints or tricks to tracking the Zombies back to the grave they dug their way out of (sorry, had to) or, back to the object they're associated with? The cryptic console message doesn't appear to offer much insight: NSInvocation: warning: object 0x1076850 of class '_NSZombie

Assigning retained object to weak property

北战南征 提交于 2019-12-20 14:43:12
问题 I am using Xcode 6 and I have created my app with a UITableView and a custom Cell in it. This is my custom cell @interface SuggestingTableViewCell : UITableViewCell @property (nonatomic, weak) IBOutlet SuggestedSeriesView *seriesOne; @property (nonatomic, weak) IBOutlet SuggestedSeriesView *seriesTwo; @property (nonatomic, weak) IBOutlet SuggestedSeriesView *seriesThree; @property (nonatomic, weak) IBOutlet SuggestedSeriesView *seriesFour; @end As you can see I have four IBOutets to a

NSArray property: copy or retain?

喜夏-厌秋 提交于 2019-12-20 10:38:23
问题 According to this: NSString property: copy or retain? For NSString/NSMutableString, copy is recommended. How about NSArray/NSMutableArray? 回答1: choose copy , unless you have a very specific reason not to, as well as all the supporting code/interface to back that up. i detailed the rationale and several implications here: NSMutableString as retain/copy that example is based on NSString s, but the same applies for NSArray s. 回答2: Since you're asking about NSArray (rather than NSMutableArray),