0

こんにちは、iOS 6 で SBSearchModel と SBSearchController をフックする cydia の微調整に問題がありますが、スポットライト フィールドに書き込むとクラッシュします。コードは次のとおりです。

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#define LOCAL_SEARCH NSLocalizedStringFromTable(@"SEARCH_BAR_PLACEHOLDER", @"SpringBoard", @"")
#define SEARCH_STRING [NSString stringWithFormat:LOCAL_SEARCH, @"Cydia"]

@interface SBSearchModel : NSObject
+ (id)sharedInstance;
- (BOOL)sectionIsWebSearch:(NSInteger)section;
@end

@interface SBSearchTableViewCell : UITableViewCell
@property (retain, nonatomic) NSString *title;
@end

NSInteger cydiaCellIndex = -1;

%hook SBSearchController

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if ([[%c(SBSearchModel) sharedInstance] sectionIsWebSearch:section])
    {
        cydiaCellIndex = %orig;
        return cydiaCellIndex + 1;
    }

    return %orig;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{
    if ([[%c(SBSearchModel) sharedInstance] sectionIsWebSearch:indexPath.section] && indexPath.row == cydiaCellIndex)
    {
        SBSearchTableViewCell *cell = (SBSearchTableViewCell *)%orig(tableView, [NSIndexPath indexPathForRow:cydiaCellIndex - 1 inSection:indexPath.section]);
        cell.title = SEARCH_STRING;
        return (UITableViewCell *)cell;
    }
    return %orig;

}

%end

%hook SBSearchModel

- (NSURL *)launchingURLForWebSearchRow:(NSInteger)row queryString:(NSString *)queryString

{
    if (row == cydiaCellIndex)
{
        return [NSURL URLWithString:[NSString stringWithFormat:@"cydia://search/%@", [queryString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
}

    return %orig;
}

%end

私は NSString ですべてを試しましたが、その中に何かを入れるとまだクラッシュしますか? NSString の何が問題なのですか?! 何か案が

4

1 に答える 1

0

iostream の SearchLoader をご覧ください: https://github.com/theiostream/SearchLoader

于 2013-09-30T16:45:39.280 に答える