-2

I use a class that returns array as the following :

%hook firstHeader
-(void)firstMethod:(id)array{
    NSLog(@"Array %@", array);

   return %orig;
}
%end

the nslog result :

array (
  "<secondHeader: 0x17a2f3c0>",
  "<secondHeader: 0x17a2f530>",
  "<secondHeader: 0x17a2f5b0>",
  "<secondHeader: 0x17a2f720>"
)

Bear with me but I may sound dumb here; how can i use the result's array object with secondHeader, As secondHeader ( or secondClass ) contains methods

Summary : First class's method returns array with objects, it wants me to use those objects with another class/header which is secondHeader

osx
  • 27
  • 1
  • 2
  • 4

1 Answers1

0

As per your comment "First class's method returns array with objects, it wants me to use those objects with another class/header which is secondHeader". Simply declare a property in secondHeader class as:

@property (nonatomic, retain) NSMutableArray * yourArray;

Synthesize it in .m File as:

@synthesize yourArray

And in your First class simple initialize the instance of secondHeader as set the value for yourArray as:

-(void)firstMethod:(id)array
{
    NSLog(@"Array %@", array);

    secondHeader * secondClass = [[secondHeader alloc] init];
    secondClass.yourArray = array;

    return %orig;
}

Once array contents are passed to secondClass, you can access the array contents by Index as:

id obj = [yourArray objectAtIndex:1];   //id is Generic data type. You should set the right data type.

Hope this will help. Ofcourse there can be other ways to pass the data, but this is the simplest way.

Jamal Zafar
  • 2,179
  • 2
  • 27
  • 32