2012-11-16 20 views
0

喜掛鉤SBSearchModel和SBSearchController我有一個蘋果蠹的調整,在iOS 6掛鉤SBSearchModel和SBSearchController 但它崩潰後,我就在這裏聚光燈場寫的代碼有問題遇到錯誤,當我試圖在iOS 6上

#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試過了eveything,但是它仍然會崩潰,當我把它裏面的東西塞進它裏面時呢? NSString有什麼問題?任何想法

+0

它在哪裏崩潰?什麼是錯誤? – twodayslate

+0

你正在具體談論'return [NSURL URLWithString:[NSString stringWithFormat:@「cydia:// search /%@」,[queryString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];'? – twodayslate

回答

相關問題