Tag: block

Return value for function inside a block

I am using AFNetworking to get data from a server: -(NSArray)some function { AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success: ^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { NSArray *jsonArray =[JSON valueForKey:@”posts”]; } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {} } So what I am trying to do here is to return the jsonArray to […]

iPhone Block SMS using xcoding,Private Frameworks whatever

this is Nsr.. I need some help about using private frameworks, i have checked almost all the links and articles about PF, but it didn’t help me whatsoever. Iv also looked into Github but didn’t get the required answer/result. I want to build an app regarding iPhone messaging. i want my phone not to recieve […]

how to return result after OpenWithCompletionHandler: is complete

Want to query a photo in the Coredata database this is my code this is the NSObjectSubclass category //Photo+creak.h #import “Photo+creat.h” @implementation Photo (creat) +(Photo *)creatPhotoByString:(NSString *)photoName inManagedObjectContext:(NSManagedObjectContext *)context{ Photo *picture = nil; NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@”Photo”]; request.predicate = [NSPredicate predicateWithFormat:@”name = %@”, photoName]; NSArray *matches = [context executeFetchRequest:request error:nil]; if (!matches || [matches […]

access the control inside the synchronous block in xcode 5.0 iPhone

I am new to blocks programming.I am trying to download an image and display it on an image view whose property i have already made in my .h file.as far as i know the class property can only be accessed in the form of getter/setter inside the block.So i have created an imageView “imgVw” in […]

Xcode 7 GM – not able to call enumerateObjectsUsingBlock

I just downloaded xcode 7 GM and trying to call the method enumerateObjectsUsingBlock of NSArray with iOS 9 but it shows the following error at build time. Incompatible block pointer types sending ‘void (^)(SKSpriteNode *__strong, NSUInteger, BOOL *)’ to parameter of type ‘void (^ _Nonnull)(SKNode * _Nonnull __strong, NSUInteger, BOOL * _Nonnull)’ This is the […]

Completion Blocks ? Asynchronous processes embedded in synchronous workflow

Long time lurker, first time poster. I’m relatively new to objective-C so my apologies if I’m asking something fairly simple. My google & stack overflow-fu has let me down here, so I figured somebody could maybe help. I have a synchronous process executing, say, three functions in a row – call it A -> B-> […]

Wait until animation block finishes before segue

I’m implementing some simple animations to my cards app. Everything is working great so far but I have just one more detail to fix before I can say it is done. The scenario is pretty simple: Three cards must exit the screen with an animation before segue modally brings up the new screen. Up until […]

Changing an instance variable in a block

I am quite confused about how to change an instance variable inside of a block. The interface file (.h): @interface TPFavoritesViewController : UIViewController { bool refreshing; } The implementation: __weak TPFavoritesViewController *temp_self = self; refreshing = NO; [myTableView addPullToRefreshWithActionHandler:^{ refreshing = YES; [temp_self refresh]; }]; As you might guess, I get a retain cycle warning […]

How to use nonnull and nullable Objective-C keywords in block-based API method

Consider the following method – (void)methodWithArg:(NSString *)arg1 andArg:(NSString *)arg2 completionHandler:(void (^)(NSArray *results, NSError *error))completionHandler; With the new nonnull and nullable annotation keywords we can enrich it as follows: – (void)methodWithArg:(nonnull NSString *)arg1 andArg:(nullable NSString *)arg2 completionHandler:(void (^)(NSArray *results, NSError *error))completionHandler; but we also get this warning: Pointer is missing a nullability type specifier (__nonnull or […]

How to pass a completion block to another class in Swift

In Objective-C, I used this handling of a completion-block that now must be transformed to Swift: in DetailDisplayController.h typedef void (^AddedCompletitionBlock)(BOOL saved, NSString *primarykey, NSUInteger recordCount); @interface DetailDisplayController : UITableViewController @property (nonatomic, copy) AddedCompletitionBlock completionBlock; @property (strong, nonatomic) Details *detail; in DetailDisplayController.m – (void) saveClicked:(id)sender { // retrieve PK NSString *objectId = [[[_detail objectID] URIRepresentation] […]