小编Yll*_*ier的帖子

iPhone:NSFilemanager fileExistsAtPath:isDirectory:无法正常工作?

我正在为越狱的iPhone开发应用程序.我正在尝试只获取文件夹的目录.所以我这样做:

NSArray *contentOfFolder = [[NSFileManager defaultManager] directoryContentsAtPath:path];
NSLog(@"contentOfFolder: %@", contentOfFolder);
directoriesOfFolder = [[NSMutableArray alloc] initWithCapacity:100];
for (NSString *aPath in contentOfFolder) {
    NSLog(@"apath: %@", aPath);

    BOOL isDir;
if ([[NSFileManager defaultManager] fileExistsAtPath:aPath isDirectory:&isDir] &&isDir)
    {
        [directoriesOfFolder addObject:aPath];
        NSLog(@"directoriesOfFolder %@", directoriesOfFolder);
    }
}
NSLog(@"dirctories %@", directoriesOfFolder);
Run Code Online (Sandbox Code Playgroud)

但看看我得到了什么.当我得到文件夹的内容一切都很好:

2009-07-28 23:23:35.930 Drowser [573:207] new path/private/var 2009-07-28 23:23:35.945 Drowser [573:207] contentOfFolder :( Keychains,"Managed Preferences",MobileDevice,备份,缓存,数据库,ea,空,文件夹,lib,本地,锁,日志,日志,移动,消息,首选项,根,运行,后台打印,藏匿,tmp,虚拟机

但是之后:

2009-07-28 23:23:35.950 Drowser [573:207] apath:Keychains 2009-07-28 23:23:35.954 Drowser [573:207] apath:Managed Preferences 2009-07-28 23:23:35.959 Drowser [573:207] apath:MobileDevice 2009-07-28 23:23:35.984 Drowser [573:207] apath:backups …

iphone objective-c nsfilemanager

7
推荐指数
1
解决办法
2万
查看次数

iPhone:RegexKit vs. RegexKit lite - 通过数组需要很长时间

对于我的应用程序,我需要查看url是否与正则表达式字符串匹配.所以我创建了一个包含所有正则表达式字符串(大约1000多个字符串)的数组,并使用RegexKit lite检查它们:

for (NSString * aString in mainDelegate.whiteListArray) {

if (![urlString isMatchedByRegex:aString]) {
Run Code Online (Sandbox Code Playgroud)

它很有效,但遗憾的是这个操作需要很长时间.像google.com这样的网页至少需要20秒

我已经尝试使用"普通"RegexKit.framework,因为它有一个名为(BOOL)的方法isMatchedByAnyRegexInArrayNSArray*)regexArray,速度要快得多.我可以构建应用程序,但每当我尝试启动它时崩溃都会出现以下错误:

dyld:未加载库:@executable_path /../ Frameworks/RegexKit.framework/Versions/A/RegexKit引用自:/ Users/Reilly/Library/Application Support/iPhone Simulator/User/Applications/7E057EA8-5CD1-465B-8102 -38A53A9B5F5B/Drowser.app/Drowser原因:未找到图像

我想这是因为RegexKit不适合手臂?(包括RegexKit我跟着文档中的内容)

所以我的问题是:

  1. 如果字符串被1000个正则表达式中的任何一个匹配,您知道检查字符串的任何更快的方法吗?

  2. 或者你知道如何在iPhone或任何其他正则表达框架上使用"普通"RegexKit,这将在一秒钟内完成我需要的工作吗?

提前致谢

regex iphone objective-c

2
推荐指数
1
解决办法
2069
查看次数

?检查webView时的响应:shouldStartLoadWithRequest:naviagiontType ...等待?

iPhone/objC

我真的被困在这里,我可以帮忙.

我先解释一下:

我有一个UIWebView加载网址.一旦用户点击的链接 - (BOOL)web视图:shouldStartLoadWithRequest:navigationType:获得消息(根据协议).在这个方法中,我可以决定是否应该在webView中加载url或者使用它做其他事情.我正在建立NSURLConnection,所以我可以检查响应.

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request
 navigationType:(UIWebViewNavigationType)navigationType {

    NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
    if (theConnection) {
        NSLog(@" Connection established");
        receivedDataFromConnection = [[NSMutableData data] retain];
        }
    else {
        NSLog(@"Connection failed");
    }   


    if (downloadYESorNO == YES) {
        NSLog(@"Do the download");
        return NO;
    }
    else {
        NSLog(@"will show in webView");
        return YES;
    }
}
Run Code Online (Sandbox Code Playgroud)

一旦应用程序得到响应 - (void)连接:didReceiveResponse:获取一条消息(根据协议),我可以在那里分析响应.

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{      
        NSString *MIME = response.MIMEType;
        NSString *appDirectory = [[NSBundle mainBundle] bundlePath];
        NSString *pathMIMETYPESplist = [appDirectory stringByAppendingPathComponent:@"MIMETYPES.plist"]; …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c nsurlconnection

1
推荐指数
1
解决办法
5958
查看次数