Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSDictionary *tweet = [self.tweets objectAtIndex:indexPath.row];
- NSString *text = [tweet objectForKey:@"text"];
- NSError *error;
- NSRegularExpression *reg = [NSRegularExpression regularExpressionWithPattern:@"\\bhttps?://[a-zA-Z0-9\\-.]+(?:(?:/[a-zA-Z0-9\\-._?,'+\\&%$=~*!():@\\\\]*)+)?" options:0 error:&error];
- __block NSUInteger count = 0;
- __block NSMutableSet *links = [[NSMutableSet alloc] initWithCapacity:100];
- [reg enumerateMatchesInString:text
- options:0
- range:NSMakeRange(0, [text length])
- usingBlock:^(NSTextCheckingResult *result, NSMatchingFlags flags, BOOL *stop) {
- [links addObject:[text substringWithRange:result.range]];
- if ( ++count >= 100 ) {
- *stop = YES;
- }
- }];
- NSMutableArray *items = [NSMutableArray new];
- [items addObject:[NSString stringWithFormat:@"%@'s Twitter Stream",[tweet objectForKey:@"from_user"]]];
- for (NSString *string in links) {
- [items addObject:string];
- }
Add Comment
Please, Sign In to add comment