2012-05-20 62 views
1

我試圖掛鉤使用徽標的CLLocationManager's delegate屬性的設置。我當前的代碼如下所示:Theos/Logos掛鉤設置的ivar/property

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

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

我要重寫委託屬性的設置,所以我可以創建一個代理類,可以過濾在發送到應用程序的位置。有沒有任何使用徽標的好辦法?

謝謝!

回答

3

是的。看作是一個財產二傳手只是一個常規的方法,你可以這樣做:

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

    %orig; 
} 
%end 
+0

完美的作品,謝謝! – user408952