It looks like you're new here. If you want to get involved, click one of these buttons!
#import <UIKit/UIKit.h>
#import \"ASIHTTPRequest.h\"
#import \"ASIFormDataRequest.h\"
#import \"AppDelegate.h\"
@interface ViewController : UIViewController
{
NSMutableArray *photoTitles;
}
@property (nonatomic, strong) NSMutableArray *photoTitles;
@end
#import \"ViewController.h\"
#import \"SBJson.h\"
@implementation ViewController
@synthesize photoTitles;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
}
*/
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
// [self setupArray];
[super viewDidLoad];
photoTitles = [[NSMutableArray alloc] init];
NSURL *url = [NSURL URLWithString:@\"http://localhost/test.php\"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setDelegate:self];
[request startAsynchronous];
}
- (void)requestFinished:(ASIFormDataRequest *)request
{
NSString *responseString = [request responseString];
NSDictionary *dictionary = [responseString JSONValue];
NSArray *photos = [[dictionary objectForKey:@\"photos\"] objectForKey:@\"photo\"];
for (NSDictionary *photo in photos) {
NSString *title = [photo objectForKey:@\"title\"];
[photoTitles addObject:title];
}
// Use when fetching text data
// Use when fetching binary data
NSData *responseData = [request responseData];
NSLog(@\"Data: %@\", responseData);
}
-(NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
return [photoTitles count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *SimpleTableIdentifier = @\"SimpleTableIdentifier\";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:
SimpleTableIdentifier];
if(cell == nil){
cell = [[UITableViewCell alloc] initWithFrame:CGRectZero
reuseIdentifier: SimpleTableIdentifier];
}
NSUInteger row = [indexPath row];
cell.textLabel.text = [photoTitles objectAtIndex:row];
return cell;
}
- (void)requestFailed:(ASIFormDataRequest *)request
{
NSError *error = [request error];
NSLog(@\"error: %@\", error);
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
Replies
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeSlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeSlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeSlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeWhen I make mistakes like this it tells me I need to walk away for a few minutes.
Thanks again.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome