Skip to content

Instantly share code, notes, and snippets.

@Adam0101
Adam0101 / UIAlertViewStyleLoginAndPassword.m
Created November 6, 2011 21:36
UIAlertViewStyleLoginAndPassword
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
NSLog(@"Username:%@",[[alertView textFieldAtIndex:0] text]);
NSLog(@"Password:%@",[[alertView textFieldAtIndex:1] text]);
}
}
@Adam0101
Adam0101 / UIAlertViewStylePlainTextInput.m
Created November 6, 2011 21:32
UIAlertViewStylePlainTextInput
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1)
NSLog(@"TextField contents:%@",[[alertView textFieldAtIndex:0] text]);
}
@Adam0101
Adam0101 / FilltheCells.m
Created May 19, 2011 16:44
FilltheCells
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [[self tweets]count];
@Adam0101
Adam0101 / notificationsTweetResults.m
Created May 19, 2011 16:40
notificationsTweetResults
- (void)viewDidLoad
{
[super viewDidLoad];
// Setup NSNotification center to listen for response back from Asynch twitter search
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
// Listen for call to twitterSearchDone, and then run function recvTwitterResults
[nc addObserver:self selector:@selector(recvTwitterResults:) name:@"twitterSearchDone" object:nil];
[nc addObserver:self selector:@selector(twitterError:) name:@"twitterFail" object:nil];
}
@Adam0101
Adam0101 / SearchResults.h
Created May 19, 2011 16:37
SearchResults.h
#import <UIKit/UIKit.h>
@interface SearchResults : UITableViewController {
NSMutableArray *tweets;
}
@property (nonatomic, retain) NSMutableArray *tweets;
@end
@Adam0101
Adam0101 / simpleTwitterViewController.m
Created May 19, 2011 16:29
simpleTwitterViewController.m
#import "SimpleTwitterSearchViewController.h"
#import "SearchTwitter.h"
@implementation SimpleTwitterSearchViewController
- (void)dealloc
{
[searchTheTweets release];
[super dealloc];
@Adam0101
Adam0101 / simpleTwitterViewController.h
Created May 19, 2011 16:27
search twitter vc header
#import <UIKit/UIKit.h>
#import "SearchTwitter.h"
#import "SearchResults.h"
@interface SimpleTwitterSearchViewController : UIViewController {
SearchTwitter *searchTheTweets;
IBOutlet UIButton *searchButton;
IBOutlet UITextField *searchTerm;
}
@Adam0101
Adam0101 / gotem.m
Created May 19, 2011 16:18
finishedTweets
// Once the data is complete, then we can parse it
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
// Store data blob we got back from twitter into a JSON string
NSString *jsonString = [[NSString alloc] initWithData:tweetBlob encoding:NSUTF8StringEncoding];
//Now use the Create a dictionary from the JSON string
NSDictionary *results = [jsonString JSONValue];
// Build an Array from the dictionary for easy access to each entry
// Gather up all the asynch data as it comes in and store it in the blob
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
// Check to see if this is a new search, if so it will be nil, so create an object
if(tweetBlob == nil) {
tweetBlob = [[NSMutableData alloc]init];
[tweetBlob appendData:data];
}
else {
[tweetBlob appendData:data];
@Adam0101
Adam0101 / dltweets.m
Created May 19, 2011 15:46
dl twitter search results
//Setup and start async download
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
[connection release];
[request release];