converting JSON data and displaying with dictionaries

dict=[NSJSONSerialization JSONObjectWithData:dat options:kNilOptions error:&error];

    NSLog(@”dict is %@ “,[dict objectForKey:@”profile”]);

    NSArray *arr1=[dict objectForKey:@”profile”];

    NSLog(@”array is %@”,arr1);

    NSDictionary *s1=[arr1 objectAtIndex:2];

    NSLog(@”object at 0 is %@”,s1);

    s1=[s1 objectForKey:@”id”];

    NSLog(@”object at 0 is %@”,s1);

 

converting the My_sql data into JSON

<?php
$host=”urhostname or localhost “;(if ur using a MAMP or Xampp server)
$username=”username”;
$password=”password”;
$database=”dbname”;
$table=”sample”;
mysql_connect($host,$username,$password) or die(mysql_error());
echo”connectd”;
mysql_select_db($database) or die(mysql_error());

$query=mysql_query(“SELECT * FROM $table”) or die(mysql_error());
echo”inserted”;
mysql_close();

$data=array();
while($d=mysql_fetch_assoc($query))
{

$data[]=$d;
}

echo json_encode($data);
?>

navigation_Controller

Things to remember while implementing a navigation controller

1) Take a navigation controller and allocate the  memory first.

navcontroller =[[UINavigationController alloc]init];

2) allocate the view controller with the nib name

_viewController = [[ViewController alloc] initWithNibName:@”ViewController” bundle:nil];

3)Add the ViewController to the Navigation Controller

[navcontroller pushViewController:_viewController animated:YES];

4)add the navigation controller as a subview

[self.window addSubview:navcontroller.view];

//now you just got ur view with a navigation controller

//still we have to implement the navigation from one view to another.

 

 

now we got the navigation for bar for the view..in order to get the navvigation to the another view use the [self.navigationController pushViewController : viewcontrolerobj];

 

sample code:

 

– (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

// Override point for customization after application launch.

self.viewController = [[[ViewController alloc] initWithNibName:@”ViewController” bundle:nil] autorelease];

nav=[[UINavigationController alloc]initWithRootViewController:self.viewController];

self.window.rootViewController = nav;

[self.window makeKeyAndVisible];

return YES;

}

 

nextview is a viewcontroller with a tableview

 

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

return 8;

}

 

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

subViewController *sub=[[subViewController alloc]initWithNibName:@”subViewController” bundle:Nil];

[self.navigationController pushViewController:sub animated:YES];

//[self presentModalViewController:nav animated:YES];

[sub release];

}

 

 

– (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

static NSString *cellIdentifier=@”CellIdentifier”;

UITableViewCell *cell=[table dequeueReusableCellWithIdentifier:cellIdentifier];

if (cell==Nil) {

cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];

}

cell.textLabel.text=@”abhii”;

return cell;

}

splash screen in iphone programming

//splash is my imageView

    splash=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];

    splash.image=[UIImage imageNamed:@”talent1.png”];

    

    activityindicator=[[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(110, 220, 30, 30)];

    [activityindicator startAnimating];

    activityindicator.activityIndicatorViewStyle=UIActivityIndicatorViewStyleGray;

    activityindicator.color =[UIColor blueColor] ;

    

 

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {

        self.viewController = [[[TalentViewController alloc] initWithNibName:@”TalentViewController_iPhone” bundle:nil] autorelease];

    } else {

        self.viewController = [[[TalentViewController alloc] initWithNibName:@”TalentViewController_iPad” bundle:nil] autorelease];

    }

        self.window.rootViewController = self.viewController;

    [self performSelector:@selector(splashmethod) withObject:splash afterDelay:3.0];

 

    [self.viewController.view addSubview:splash];

    [self.viewController.view addSubview:activityindicator];

 

    [self.window makeKeyAndVisible];

    return YES;

}

 

-(void)splashmethod

{

    

    [activityindicator removeFromSuperview];

    [splash removeFromSuperview];

    

}