objective c - How to change this so that it returns arrays -


The following code works perfectly and shows the correct output:

  - ( Zero) viewDidoadload [[Super Viewedload]; [Self expansion_compression: @ "ABCD" arg2: @ "" arg3: 3]; } - (zero) extension_compos: (NSString *) remaining_string arg2: (NSString *) s arg3: (int) remains_depth {if (remains_depth == 0) {printf ("% s \ n", [UTF8String]); Return; } NSString * str = [[NSString alloc] initWithString: s]; (Int k = 0; k & lt; [left_strand length]; ++ k) {str = [stringbapping string: [[remaining_string subfringredindexx: k] substringtoxedx: 1]]; [Self-expansion_combing: [remaining_string substreamfram index: K + 1] arg2: RR RG3: stay_district-1]; } Return; }  

However, instead of outputting results, I want to return them to NSArray. How can this code be changed to do this? I need to use the information that this function generates in other parts of my program.

There are many things -expand_combinations: its method to do something more explicit and meaningful than arg2 Consider renaming: arg2:

    Arg3 .
  • Second - You have a memory leak to set an allocation memory and start with Not required because you change its value immediately in the loop without releasing the old vairoo. Take a look at
  • Third - NSMutableArray . At the beginning of the method, create an array with [NSMutableArray array] , and in every line you have printf , instead, add the string to the array. Then return it.

Comments