2009-12-14 47 views
2

Iam創建和無線電應用程序,其中我必須檢查身份驗證和成功登錄後,我得到.pls文件,其中有實際的網址必須播放 任何人都知道如何解析.pls文件並獲取.pls文件中的url。.Pls文件解析

回答

0

在我來說,我在主束一WWEMAC.pls文件。其中存在多個url,我只需提取這些URL並以字符串格式將它們添加到數組中。以下代碼爲我工作。

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"WWEMAC" ofType:@"pls"]; 
NSError *errorReading; 
NSArray *linesOfText = [[NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:&errorReading] componentsSeparatedByString:@"\n"]; 
NSLog(@"Reading error %@",errorReading); 
NSString *completeDataInStr = [linesOfText componentsJoinedByString:@" "]; 
NSDataDetector *detector = [NSDataDetector dataDetectorWithTypes:NSTextCheckingTypeLink error:nil]; 
NSArray *matches = [detector matchesInString:completeDataInStr options:0 range:NSMakeRange(0, [completeDataInStr length])]; 
for (NSTextCheckingResult *match in matches) 
{ 
    NSString *str = [NSString stringWithFormat:@"%@",match.URL]; 
    NSLog(@"URL str = %@",str); 
} 
return matches; 
+0

WWEMAC.pls文件包含有像這樣 [流列表] File1中= HTTP://stream.com:80/WWW_PC File1中= HTTP://stream.com:81/WWW_PC 文件2 = HTTP://stream.com:82/WWW_PC 文件3 = HTTP://stream.com:83/WWW_PC FILE4 = HTTP://stream.com:84/WWW_PC File5 = HTTP://stream.com :85/WWW_PC Title1 = WWEMAC_PC 長度1 = -1 NumberOfEntries = 5 版本= 5 並返回數組(命名爲matches here)co僅允許來自.pls文件的URL。 – 2015-09-23 13:39:04