nsobject

What is the significance of WaitUntilDOne in performSelectorOnMainThread?

白昼怎懂夜的黑 提交于 2019-12-03 12:42:42
What is the significance of WaitUntilDOne in performSelectorOnMainThread ? IN what way the YES or NO set to WaitUntilDone can have on the App? UPDATE: My Question should have been: In what scenarios do they make difference? Sergio's answer was the one I was expecting. From Apple docs about waitUntilDone : A Boolean that specifies whether the current thread blocks until after the specified selector is performed on the receiver on the main thread. Specify YES to block this thread; otherwise, specify NO to have this method return immediately. If the current thread is also the main thread, and you

How to call a method a.s.a.p. but at earliest in the next run loop iteration?

一笑奈何 提交于 2019-12-03 11:30:57
问题 I need a save way to say: "iOS, I want this method to be executed a.s.a.p., but NOT in THIS run loop iteration. At the earliest in the next, but please not in this one. Thank you." Right now I am always doing it like this: [self performSelector:@selector(doSomethingInNextRunLoop) withObject:nil afterDelay:0]; [self doSomeOtherThings]; With the assumption that -doSomeOtherThings will always be performed BEFORE -doSomethingInNextRunLoop . The documentation says: Specifying a delay of 0 does not

isKindOfClass doesn't work as expected

99封情书 提交于 2019-12-03 03:04:46
i'm working on a iOS5+ project (xcode 4.4.1 SDK 5.1) i have this code inside a unit test: [_appDelegate application:nil didFinishLaunchingWithOptions:nil]; UITabBarController *tabBarController = (UITabBarController*)_appDelegate.window.rootViewController; NSArray *viewControllers = [tabBarController viewControllers]; UINavigationController *nc_1 = [viewControllers objectAtIndex:0]; UIViewController *vc_1 = nc_1.topViewController; STAssertTrue([vc_1 isKindOfClass:[ScheduleViewController class]]==YES, @"UITabBarController first tab should be a ScheduleViewController class"); If i run the test,

How to call a method a.s.a.p. but at earliest in the next run loop iteration?

人走茶凉 提交于 2019-12-03 01:54:39
I need a save way to say: "iOS, I want this method to be executed a.s.a.p., but NOT in THIS run loop iteration. At the earliest in the next, but please not in this one. Thank you." Right now I am always doing it like this: [self performSelector:@selector(doSomethingInNextRunLoop) withObject:nil afterDelay:0]; [self doSomeOtherThings]; With the assumption that -doSomeOtherThings will always be performed BEFORE -doSomethingInNextRunLoop . The documentation says: Specifying a delay of 0 does not necessarily cause the selector to be performed immediately. The selector is still queued on the thread

Scalar type in Managed Object only works for IPhone 5

馋奶兔 提交于 2019-12-03 00:32:20
Property 'Latitude' is a scalar type on class 'LatitudeLongitude'. Cannot generate a setter method for it. When I generated codes for my managed object, I got a message whether I want scalar properties for primitive data type. should I use it? I want to make this application compatible with iPhone 3 - 5 is there any issues with this problem? When you use scalar properties you have to provide implementations of getters and setters for those properties by yourself, as described in documentation: "You can declare properties as scalar values, but for scalar values Core Data cannot dynamically

Calling dealloc in init?

谁说胖子不能爱 提交于 2019-12-02 19:30:41
问题 I am writing a framework and I have an object with a custom init method: @implementation OSDatabase @synthesize database; // MEM - (void)dealloc { sqlite3_close(database); [super dealloc]; } // INIT - (id)initWithDatabasePath:(NSString *)path error:(NSError **)error { if (self = [super init]) { if (!sqlite3_open_v2([path UTF8String], &database, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL)) { error = [NSError errorWithDomain:@"OSDatabaseErrorDomain" code:1 userInfo:nil]; [self dealloc];

'isMemberOfClass' returning 'NO' when custom init [duplicate]

廉价感情. 提交于 2019-12-02 18:48:10
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: isMemberOfClass returns no when ViewController is instantiated from UIStoryboard I recently stumbled over a weird problem: I was implementing simple Testcases and using the NSObject isMemberOfClass method to check for class equality. Additionally I implemented a custom init: -(id)initWithMessage:(NSString *)message If I replace id with the right class name the isMemberOfClass will return 'YES'. Otherwise it will

Swift: Can't insert NSObject into Array as it wants a [String] instead

别来无恙 提交于 2019-12-02 11:58:41
问题 I have a model object called Hashtag. This simply contains a optional String variable called hashtagName. I fetch the data from my Firebase Database and append the hashtags to my fashionHashtags, which is a [Hashtag] . The issue I have is that I want to append that to my other categoriesArray by using the insertElementAtIndexPath function. I cannot do this as it wants an array of Strings and not an array of Hashtag. When I autocorrect it, it replaces it with fashionHashtags as! [String] but

Calling dealloc in init?

主宰稳场 提交于 2019-12-02 11:39:06
I am writing a framework and I have an object with a custom init method: @implementation OSDatabase @synthesize database; // MEM - (void)dealloc { sqlite3_close(database); [super dealloc]; } // INIT - (id)initWithDatabasePath:(NSString *)path error:(NSError **)error { if (self = [super init]) { if (!sqlite3_open_v2([path UTF8String], &database, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL)) { error = [NSError errorWithDomain:@"OSDatabaseErrorDomain" code:1 userInfo:nil]; [self dealloc]; return nil; } } return self; } @end Is it safe to call dealloc inside of an init method if an error

How to make NSURLConnection file download work?

不打扰是莪最后的温柔 提交于 2019-12-02 10:23:47
问题 I have a ViewController declared as: @interface DownloadViewController : UIViewController <UITableViewDataSource, UITableViewDelegate> and I want to use NSURLConnection to download files. NSURLConnection simply "doesn't start", the delegate methods don't work (for example connection:didReceiveResponse is never called) . I noticed in some sample code that the class was subclassing NSObject instead of UIViewController . How do I combine it? I want to use ViewController methods but then I can't