- (void)setID :( long long) 是方法,我想检索传递的参数(整数)在警报视图中显示它。我是新手,请帮助我。如果可能的话,如何将这个论点传递给另一种方法
- (void)setSelectedID :( long long) ,如果这是我想传递参数的方法,我将如何在 Tweaks中执行此操作。 xm 文件。
任何帮助将不胜感激,谢谢
这也可以使用Cycript吗?
答案 0 :(得分:0)
此代码未经测试但我希望它可以提供帮助(假设setSelectedID:
是您制作的方法):
// Use parenthesis to avoid creating a duplicate definition of TheClassToHook
@interface TheClassToHook ()
// Put your new method definitions here
- (void)setSelectedID:(long long)passedID;
@end
%hook TheClassToHook
// This is the original method from TheClassToHook
- (void)setID:(long long)passedID {
// Call your new method
[self setSelectedID:passedID];
// Create an NSString from the passed id,
// it will be used to show it in the alert as a message
NSString *msg = [NSString stringWithFormat:@"%lld", passedID];
// Show an alert using UIAlertView, note that TheClassToHook should implement UIAlertViewDelegate
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"The passed id is..."
message:msg
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
// Optional: Make sure the memory used to allocate the alert and its message are released,
// this may be unnecessary
[alert release];
[msg release];
/* NOTE:
UIAlertView is deprecated since iOS 8,
if you don't want to target older iOS versions,
you should consider using UIAlertController instead
*/
// Call the original method with the original arguments
%orig;
}
// Use the "%new" logos directive to implement a new method
%new
- (void)setSelectedID:(long long)passedID {
// Your code
}
%end // close %hook
如果setSelectedID:
是默认情况下存在的方法,您只需从@interface
块中删除其定义及其在%hook
块中的实现。
另外,由于我不使用Cycript,我不知道是否可以使用Cycript,抱歉。