Dealing with async calls and block.

Hi All There are always disadvantages of retaining “self” in side block we can work around it using __block or __weak ref of self. but the ideal way is as we call it strong weak dance. it goes like this __weak typeOf(self)ref=self;  //making weak ref of self ^( ){ __strong typeOf(ref)strongSelf=ref;   // converting it back … Read more

Block for excuting task after fixed interval give NSTimer a miss

Hi, If ever you feel the need to repeat a task after say 5 seconds and you feel nastimer is too clumsy to use then you can use…   void runBlockEveryMinute(int *breakCondition, dispatch_block_t block) { if(*breakCondition==0) { return; } block(); // initial block call // get the current time struct timespec startPopTime; gettimeofday((struct timeval *) … Read more

Gate2Play and iOS integration.

HI, If you are making an application which targets middle east then you will come across a payement gateway  provider gate2play .The apis mentioned are al for web portal and FAQ states that it can be used on mobile platform  but Ok so i spend my whole day and finally integrated it and now i … Read more

File Upload using AFNetworking in iOS application.

Hi If developing a app at times you are required to upload files. As i got stuck many times so i thought about writing most common way of uploading. UpDate for AFNetworking 3.0 AFNetworking 3.0 is NSURLSession based. NSMutableURLRequest *upload_request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@”POST” URLString:@”<path_URL>” parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { [formData appendPartWithFileData:data name:@”upload_file” fileName:@”<your_filename>” mimeType:@”text/plain”] // you … Read more

Using recursion without its hassels

Hi We all know how recursion can simplify code.It gives further more control when used through blocksBut the disadvantage of recursion is the memory keeps piling up till the very end. recently i implemented recursion using blocks in an iOS project but i placed the call to the function in performselectorinbackground    the result was … Read more

How to use varargs….

Hi Ever wondered how we give multiple button names in alert view other buttons section…and in many more scenarios.. Ok so how we define a function with varargs.. -(void)getMultipleString:(NSString*)firstString ,… NS_REQUIRES_NIL_TERMINATION; Now the definition -(void)getMultipleString:(NSString*)firstString ,… NS_REQUIRES_NIL_TERMINATION { va_list  t; va_start(t, firstString); id obj; for (obj = firstString; obj != nil; obj = va_arg(t, id)) … Read more