user408952
user408952

Reputation: 932

Theos/Logos hook set of ivar/property

I'm trying to hook the setting of CLLocationManager's delegate property using logos. My current code looks like this:

%hook CLLocationManager
-(void)startUpdatingLocation
{
    %orig;

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"test"
        message:@"hello!"
        delegate:nil
        cancelButtonTitle:@"Bye"
        otherButtonTitles:nil];
    [alert show];
    [alert release];
}
%end

I want to override the setting of the delegate property so I can create a proxy class that can filter the location that's sent to the app. Is there any nifty way to do that using logos?

Thanks!

Upvotes: 1

Views: 1991

Answers (1)

Andrew R.
Andrew R.

Reputation: 943

Yep. Seeing as a property setter is just a regular method, you can do this:

%hook CLLocationManager
- (void) setDelegate:(id<CLLocationManagerDelegate>)delegate {
    // set up your proxy / whatever you're looking to do

    %orig;
}
%end

Upvotes: 4

Related Questions