0

嗨,我有一个 cydia 调整的问题,即在 iOS 6 上挂钩 SBSearchModel 和 SBSearchController 但是在我写在聚光灯字段后它崩溃了这里是代码

#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 回答