ios - How to Pass NSArray Parameter to Completion Block -


i want pass nsarray parameter , completion block method ,as new concept, can not understand how it.currently passing 1 array, want pass second nsarray , in second array want pass array value can use on there

typedef void(^completion)(nsarray *list);  -(void) getmoredata:(completion) completion  

calling method

[magento.service getmoredata:^(nsarray *list ) {         if(list){                  } 

in above method want pass nsarray , method in different class , calling different . array using in method .

you can call c function, example, have declared new class myclass. content of interface file is:

typedef void(^completion)(nsarray *list);  @interface myclass : nsobject  - (void)getmoredata:(completion)completionblock;  @end 

and in implementation

- (void)getmoredata:(completion)completionblock {     // fullfil array     nsarray *array = @[@1, @2, @3];      // call completion block     completionblock(array); } 

and using follow:

myclass *myclassinstance = [[myclass alloc] init]; [myclassinstance getmoredata:^(nsarray *list) {     if (list) {         nslog(@"%@", list);     } else {         nslog(@"nil array");     } }]; 

and output is:

2013-05-09 16:29:00.676 test[823:11303] (     1,     2,     3 ) 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -