This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Build the string to search against the twitter search api | |
NSString *urlString = [NSString stringWithFormat:@"http://search.twitter.com/search.json?q=&ands=%@&phrase=&rpp=50",searchTerm]; | |
NSURL *url = [NSURL URLWithString:urlString]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Create the regular expression to match against whitespace or % or ^ | |
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(\\s|%|^)" options:NSRegularExpressionCaseInsensitive error:&error]; | |
//Create the regular expression to match against hash tags | |
NSRegularExpression *regexHash = [NSRegularExpression regularExpressionWithPattern:@"#" options:NSRegularExpressionCaseInsensitive error:&error]; | |
// create the new string by replacing the matching of the regex pattern with the template pattern(whitespace) | |
NSString *tempString = [regex stringByReplacingMatchesInString:searchTerm options:0 range:NSMakeRange(0, [searchTerm length]) withTemplate:@"%20"]; | |
// create the new string by replacing the matching of the regex pattern with the template pattern(whitespace) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface SearchTwitter : NSObject { | |
NSMutableData *tweetBlob; | |
} | |
- (void)grabData:(NSString *)searchTerm; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (void)initialize | |
{ | |
//configure iRate | |
[iRate sharedInstance].appStoreID = 355313284; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)touchesEnded: (NSSet *)touches withEvent: (UIEvent *)event { | |
for (UIView* view in self.view.subviews) { | |
if ([view isKindOfClass:[UITextField class]]) | |
[view resignFirstResponder]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString *)grabData:(NSString *)searchTerm { | |
// Setup an error to catch stuff in | |
NSError *error = NULL; | |
//Create the regular expression to match against | |
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\\s" options:NSRegularExpressionCaseInsensitive error:&error]; | |
// create the new string by replacing the matching of the regex pattern with the template pattern(whitespace) | |
NSString *newSearchString = [regex stringByReplacingMatchesInString:searchTerm options:0 range:NSMakeRange(0, [searchTerm length]) withTemplate:@"%20"]; | |
NSLog(@"New string: %@",newSearchString); | |
return newSearchString; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString *)stripOutHttp:(NSString *)httpLine { | |
// Setup an NSError object to catch any failures | |
NSError *error = NULL; | |
// create the NSRegularExpression object and initialize it with a pattern | |
// the pattern will match any http or https url, with option case insensitive | |
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"https?://([-\\w\\.]+)+(:\\d+)?(/([\\w/_\\.]*(\\?\\S+)?)?)?" options:NSRegularExpressionCaseInsensitive error:&error]; | |
// create an NSRange object using our regex object for the first match in the string httpline | |
NSRange rangeOfFirstMatch = [regex rangeOfFirstMatchInString:httpLine options:0 range:NSMakeRange(0, [httpLine length])]; | |
// check that our NSRange object is not equal to range of NSNotFound | |
if (!NSEqualRanges(rangeOfFirstMatch, NSMakeRange(NSNotFound, 0))) { |
NewerOlder