performselector

SKAction repeatActionForever not spawning entity

会有一股神秘感。 提交于 2019-12-11 12:50:13
问题 Basically I have a spawn entity function that should in theory, spawn a random balloon onto the screen with certain properties. I have designed the method as such: -(void)spawnBalloon { int a = arc4random_uniform(self.frame.size.width); int b = self.frame.size.height - 50; CGPoint loc = CGPointMake(a, b); [self spawnBalloonAtPoint:loc]; } And this method works. When I call it in the init function, it works. When I call it in the touchesMoved() function it works. However, when I try and call

How to check if there's a performSelector: waiting to be executed?

萝らか妹 提交于 2019-12-09 17:12:26
问题 In my iPhone app I got several places where I can do a [object performSelector: withObject: afterDelay:] call. All lead to the same method. Now, in that method I want to execute some code only on the latest call of it. If it was the first, I could just do [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(thisMethod) object:nil] and be sure it gets called once. But, is there a way to tell if there are any other method calls waiting to be executed? I could use a counter

Selector with completion, 2 variables and time interval

纵然是瞬间 提交于 2019-12-08 13:26:32
Continuing this question I have this function func getSearch(completed: @escaping DownloadComplete, searchString: String) { let parameters: Parameters = [ "action" : "search", "subaction" : "get", "product_name" : searchString, "limit" : "0,30" ] Alamofire.request(baseurl, method: .get, parameters: parameters).responseJSON { (responseData) -> Void in if((responseData.result.value) != nil) { let result = responseData.result if let dict = result.value as? Dictionary<String, AnyObject>{ if let list = dict["products_in_category"] as? [Dictionary<String, AnyObject>] { if self.filteredData.isEmpty =

Set UIView backgroundColor with drawRect:

冷暖自知 提交于 2019-12-08 10:26:37
问题 I am trying to set a custom UIView class's background color. The class also does quartz drawing in the drawRect: method. Since background color change does not take place until the next redraw of the view, I change the UIView's backgroundColor property before calling setNeedsDisplay . I have set a UIActivityIndicatorView to animate while the view is redrawing. self.backgroundColor = theColor; [indicator startAnimating]; [self performSelectorInBackground:@selector(setNeedsDisplay) withObject

Selector with completion, 2 variables and time interval

不羁的心 提交于 2019-12-08 08:06:02
问题 Continuing this question I have this function func getSearch(completed: @escaping DownloadComplete, searchString: String) { let parameters: Parameters = [ "action" : "search", "subaction" : "get", "product_name" : searchString, "limit" : "0,30" ] Alamofire.request(baseurl, method: .get, parameters: parameters).responseJSON { (responseData) -> Void in if((responseData.result.value) != nil) { let result = responseData.result if let dict = result.value as? Dictionary<String, AnyObject>{ if let

How to resolve “no known instance method for selector 'performSelector:withObject:afterDelay:'” when migrating to ARC?

不打扰是莪最后的温柔 提交于 2019-12-06 17:58:32
问题 The ARC migration tool is refusing to accept this code prior to starting with migration: [self.delegate performSelector:@selector(overlayDismissed:) withObject:self afterDelay:0]; The delegate is forced to implement this method with a protocol, and it should work fine: @protocol OverlayDelegate <NSObject> - (void)overlayDismissed:(Overlay*)overlay; @end @interface Overlay : UIImageView { id<OverlayDelegate> delegate; } @property (nonatomic, assign) id<OverlayDelegate> delegate; What's wrong

scheduledTimerWithTimeInterval vs performselector with delay with iOS 5.0

纵饮孤独 提交于 2019-12-05 18:15:55
问题 i am doing function call with scheduledTimerWithTimeInterval. i am just checking that xml parsing is completed or not for particular web services and invalidating timer in didEndElement method after getting successful response. timerForStopWebService = [NSTimer scheduledTimerWithTimeInterval:30.0 target:self selector:@selector(stopWS) userInfo:nil repeats:NO]; now i am facing problem with iOS 5.0 and its working fine in other iOS versions. in iOS 5.0, a function stopWS call anytime even if i

How to resolve “no known instance method for selector 'performSelector:withObject:afterDelay:'” when migrating to ARC?

痞子三分冷 提交于 2019-12-05 01:03:53
The ARC migration tool is refusing to accept this code prior to starting with migration: [self.delegate performSelector:@selector(overlayDismissed:) withObject:self afterDelay:0]; The delegate is forced to implement this method with a protocol, and it should work fine: @protocol OverlayDelegate <NSObject> - (void)overlayDismissed:(Overlay*)overlay; @end @interface Overlay : UIImageView { id<OverlayDelegate> delegate; } @property (nonatomic, assign) id<OverlayDelegate> delegate; What's wrong with ARC? Why is it telling me that there is "no known instance method for selector 'performSelector

pass block as parameter in my case

情到浓时终转凉″ 提交于 2019-12-04 22:06:27
I have a function which takes a block as parameter: typedef void (^ MyBlock)(int); -(void)doTask:(MyBlock)theBlock{ ... } I need to run above function on another thread, I want to use - performSelector:onThread:withObject:waitUntilDone: , my current code: NSThread *workerThread = [[NSThread alloc] init]; [workerThread start]; [self performSelector:@selector(doTask:) onThread:workerThread withObject:??? waitUntilDone:NO]; BUT, How can I pass MyBlock parameter with this approach? (Please don't suggest GCD, I am wondering how can I do with my current code, is it possible?) This answer assumes you

how to indicate to main UI thread when background task has completed? (performSelectorInBackground)

自古美人都是妖i 提交于 2019-12-04 18:44:40
How can I get an indication to main UI thread in an iPhone app IOS program, when background task has completed? Background I'm trying to setup a loading indicator per the concept at How to add a UIActivityIndicator to a splash screen in a iphone application? was going to in AppDelete use "performSelectorInBackground" to load up the model data what I need therefore is in the RootViewController some way of telling when the data has finished loading in the background so that it can (a) update the tableview with the data and (b) remove any activity indicator I'm assuming way to do things here is