Reputation: 63
Basically what I'm trying to do is call the attemptDeviceUnlockWithPassword
method from SBDeviceLockScreenViewController
's lockScreenView
method. What is the proper way to call an instance method from a different class?
%hook SBLockScreenViewController
-(void)lockScreenView:(id)view didScrollToPage:(int)page
{
if (page==0)
{
//call attemptDeviceUnlockWithPassword:@"0000" appRequested:NO
}
%orig;
}
%end
%hook SBDeviceLockController
- (BOOL)attemptDeviceUnlockWithPassword:(NSString *)passcode appRequested:(BOOL)requested
{
return %orig;
}
%end
Upvotes: 1
Views: 900
Reputation: 55594
In order to be able to call an instance method you need an instance of a class. You can see from the SBDeviceLockController header that there is a class method +(id)sharedController
. This method will return an instance which you can call instance methods on.
There are quite a few classes in SpringBoard that follow this pattern of having a class method return the a singleton instance (this is called the Singleton pattern).
You need to learn more about the basics of Objective-C before doing tweak development, try just creating a simple app. The Apple documentation is pretty good (try starting here), and there are many other resources on the internet (such as the Stanford CS193P course).
Upvotes: 3