Thursday, 21 February 2013

HI THIS TOUTORIAL WILL HELP FULL FOR STARTUP IN IOS CREATED BY NAVEENRAJU



IOS BASICS EXPLINATIONS BY NAVEENRAJU


Retrive Json Data FromDatabase




















Code For Above Demo

MasterViewController.h


////  MasterViewController.h//  JsonDemo_DbSelect////  Created by apple on 20/02/13.//  Copyright (c) 2013 apple. All rights reserved.//
#import <UIKit/UIKit.h>
@class DetailViewController;
@interface MasterViewController : UITableViewController@property(nonatomic,retain)NSMutableArray *mydata;@property (strong, nonatomic) DetailViewController *detailViewController;
@end

MasterViewController.m


////  MasterViewController.m//  JsonDemo_DbSelect////  Created by apple on 20/02/13.//  Copyright (c) 2013 apple. All rights reserved.//
#import "MasterViewController.h"
#import "DetailViewController.h"
@interface MasterViewController () {    NSMutableArray *_objects;}@end
@implementation MasterViewController@synthesize mydata;
-(void)getJsonData:(NSData *)data{    NSError *error;    mydata=[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];    NSLog(@"%@",mydata);    [self.tableView reloadData];
}
-(void)parseJson{        NSString *str=[NSString stringWithFormat:@"http://localhost/App1/json_select.php"];    NSURL *url=[NSURL URLWithString:str];    NSData *data=[NSData dataWithContentsOfURL:url];    [self getJsonData:data];
}



- (void)viewDidLoad{    [super viewDidLoad];// Do any additional setup after loading the view, typically from a nib.    self.title=@"Db Json Retrive";    [self parseJson];        }



- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{    return 1;}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{    return [mydata count];}
// Customize the appearance of table view cells.- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{    static NSString *CellIdentifier = @"Cell";        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];    if (cell == nil) {        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;    }

    //NSDate *object = _objects[indexPath.row];    //cell.textLabel.text = [object description];                NSDictionary *d=[mydata objectAtIndex:indexPath.row];    cell.textLabel.text=[d objectForKey:@"name"];        cell.detailTextLabel.text=[d objectForKey:@"sex"];        return cell;}

- (void)didReceiveMemoryWarning{    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}

@end




MasterViewController.xib









json_select.php

<?php



$host = "localhost"; $user = "root"; $pass = ""; $database = "IosProj"; 
$con = mysql_connect($host, $user, $pass) or die("Could not connect to host."); mysql_select_db($database, $con) or die("Could not find database."); 


$sql = mysql_query("SELECT * FROM Register");$rows = array();while($row = mysql_fetch_assoc($sql)) {   $rows[] = $row;}//print json_encode($rows);echo(json_encode($rows));

?>


phpMyadmin:





HI THIS TOUTORIAL WILL HELP FULL FOR STARTUP IN IOS CREATED BY NAVEENRAJU



IOS BASICS EXPLINATIONS BY NAVEENRAJU


Print JSON Values In  Command Line










code for Above Demo:


ViewController.h



//
//  ViewController.h
//  JsonDemo
//
//  Created by apple on 19/02/13.
//  Copyright (c) 2013 apple. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController{}
@property(nonatomic,retain)NSString *jsonData;@property(nonatomic,retain)NSURL *jsonUrl;@property(nonatomic,retain)NSMutableArray *jsonArray;



@end







ViewController.m


//
//  MasterViewController.m
//  JSONDEMO
//l
//  Created by appe on 08/02/13.
//  Copyright (c) 2013 apple. All rights reserved.
//


#import "ViewController.h"
#import "SBJson.h"
#import "JsonDemo-Prefix.pch"
@interface ViewController () {    NSMutableArray *_objects;
}
@end
@implementation ViewController
@synthesize jsonUrl;@synthesize jsonArray;
@synthesize jsonData;
- (void)viewDidLoad
{
    [super viewDidLoad];  
    self.title=@"JsonDemo";  
    jsonUrl=[NSURL URLWithString:@"http://localhost/App1/rac.php"];    jsonData =[[NSString alloc]initWithContentsOfURL:jsonUrl];    self.jsonArray=[jsonData JSONValue];    NSLog(@"%@",jsonArray);  
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [jsonArray count];
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];  
  
    cell.textLabel.text = [self.jsonArray objectAtIndex:indexPath.row];
  
    return cell;
}
@end



MainStoryboard.storyboard











Wednesday, 20 February 2013





HI THIS TOUTORIAL WILL HELP FULL FOR STARTUP IN IOS CREATED BY NAVEENRAJU




IOS BASICS EXPLINATIONS BY NAVEENRAJU


JSon IN Table View






















Code For Above Demo:


MasterViewController.h

//
//  MasterViewController.h
//  Table_JsonDemo
//
//  Created by apple on 19/02/13.
//  Copyright (c) 2013 apple. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface MasterViewController : UITableViewController
{



}
@property(nonatomic,retain)NSURL *jsonUrl;
@property(nonatomic,retain)NSString *jsonData;
@property(nonatomic,retain)NSMutableArray *jsonArray;

@end



MasterViewController.m


//
//  MasterViewController.m
//  Table_JsonDemo
//
//  Created by apple on 19/02/13.
//  Copyright (c) 2013 apple. All rights reserved.
//

#import "MasterViewController.h"

#import "DetailViewController.h"
#import "SBJson.h"
@interface MasterViewController () {
    NSMutableArray *_objects;
}
@end

@implementation MasterViewController
@synthesize jsonArray;
@synthesize jsonData;
@synthesize jsonUrl;


- (void)viewDidLoad
{
    [super viewDidLoad];
    
    
    self.title=@"Jon Data IN TableView";
    jsonUrl=[NSURL URLWithString:@"http://localhost/App1/rac.php"];
    jsonData=[[NSString alloc]initWithContentsOfURL:jsonUrl];
    self.jsonArray=[jsonData JSONValue];
    NSLog(@"%@",jsonArray);
    
}




- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}









- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return jsonArray.count;
}







- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];

    //NSDate *object = _objects[indexPath.row];
    cell.textLabel.text = [self.jsonArray objectAtIndex:indexPath.row];
    return cell;
}

@end

ViewController.xib






HI THIS TOUTORIAL WILL HELP FULL FOR STARTUP IN IOS CREATED BY NAVEENRAJU

DataBase Insertion























code For Above Demo:



  ViewController.h



//
//  ViewController.h
//  InsertMysql_Registration
//
//  Created by apple on 19/02/13.
//  Copyright (c) 2013 apple. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UITextField *t1;
@property (strong, nonatomic) IBOutlet UITextField *t2;
@property (strong, nonatomic) IBOutlet UITextField *t3;
- (IBAction)Register:(id)sender;

- (IBAction)delete:(id)sender;


@end


 ViewController.m


//
//  ViewController.m
//  InsertMysql_Registration
//
//  Created by apple on 19/02/13.
//  Copyright (c) 2013 apple. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController



@synthesize t1;
@synthesize t2;
@synthesize t3;

- (void)viewDidLoad
{
    [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
    
    
    
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)Register:(id)sender {
    
    
    NSString *url=[NSString stringWithFormat:@"http://localhost/App1/Registration.php?name=%@&age=%@&sex=%@",t1.text,t2.text,t3.text];
    
    //To exicute php code
    
    NSData *dataUrl=[NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
    
    

    
}

- (IBAction)delete:(id)sender {
    
    NSString *url1=[NSString stringWithFormat:@"http://localhost/App1/Delete.php"];
    
    //To exicute php code
    
    NSData *dataUrl1=[NSData dataWithContentsOfURL:[NSURL URLWithString:url1]];
    
    

    
    
}
@end














 ViewController.xib




Registration.php



<?php

//create data base connections
$user='root';
$pswd='';
$db='iosproj';

$conn=mysql_connect('localhost',$user,$pswd);
mysql_select_db($db,$conn);

//if name,age,sex are seted then only values are inserted
if (isset($_GET['name']) && isset($_GET['age']) && isset($_GET['sex']))
{

$name=$_GET['name'];
$age=$_GET['age'];
$sex=$_GET['sex'];


$result=mysql_query("insert into Register(name
,age,sex)values('$name','$age','$sex')");
}


?>


Delete.php


<?php

//create data base connections
$user='root';
$pswd='';
$db='iosproj';


$conn=mysql_connect('localhost',$user,$pswd);
mysql_select_db($db,$conn);



$result=mysql_query("delete from Register");



?>







PHPMYADMIN:









Monday, 18 February 2013



IOS BASICS EXPLINATIONS BY NAVEENRAJU


Responsive Design By Using "Media Quaries" in IOS

->Responsive web Design is possible by using css3 Media Quaries->We can have 1 style sheet for large diplays and diff styles specify for mobiles based on resulution,pixelsizes->it will allow diff resolutions with out changing the content






CODE FOR MediaQuaryDemos:




MediaQuaryDemo.html

<!Doctype Html><head>
<link rel="stylesheet" type="text/css" href="Media.css" />



</head><body>

<div id="naveen"><img src="grails.jpg"></div>



<div id="left">
Android Blog
</div>




<div id="right">IOs Blog
</div>
</body></html>


Media.css


#container{
width: :600px;margin-right: automargin-left:auto;}
#left {
width:70%;height: 200px;float:left;background:red;}


#right{
width:30%;height: 200px;float:right;background:cyan;}
img{width: 30%;}





@media screen and (max-width: 590px) {



#container{
width: :600px;margin-right: automargin-left:auto;}
#left {
width:70%;height: 200px;float:left;background:orange;}


#right{
width:30%;height: 200px;float:right;background:blue;}
img{width: 30%;}
}

  

ViewController.h

////  ViewController.h//  MediaQuary////  Created by apple on 18/02/13.//  Copyright (c) 2013 apple. All rights reserved.//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController{
                IBOutlet UIWebView *webview;        IBOutlet UIWebView *web;}

@property(nonatomic,retain) UIWebView *webview;@property (strong, nonatomic) IBOutlet UIWebView *web;
//@property(nonatomic,retain) UIWebView *webview1
@end

ViewController.m

////  ViewController.m//  MediaQuary////  Created by apple on 18/02/13.//  Copyright (c) 2013 apple. All rights reserved.//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController@synthesize webview;- (void)viewDidLoad{    [super viewDidLoad];// Do any additional setup after loading the view, typically from a nib.                NSString *path=[[NSBundle mainBundle]pathForResource:@"MediaQuaryDemo" ofType:@"html"inDirectory:@""];    NSURL *url=[NSURL fileURLWithPath:path];    NSURLRequest *request=[NSURLRequest requestWithURL:url];    [webview loadRequest:request];
                    }
- (void)didReceiveMemoryWarning{    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.}
@end

ViewController.xib



HI THIS TOUTORIAL WILL HELP FULL FOR STARTUP IN IOS CREATED BY NAVEENRAJU



IOS BASICS EXPLINATIONS BY NAVEENRAJU


OBJECTIVE C

  • Introduction to Objective-c programming
  • Primitive Data Types and Operators
  • Flow Control Statements
  • Arrays and Structures
  • Classes, Objects, and Messaging
  • Memory Management and Properties
  • Inheritance, Polymorphism
  • Protocols and Categories
  • Introduction to Foundation Framework Classes
  • File Handling
  • Property Lists, NSCopy, and Archiving
  • Selectors and Targets
  • Dynamic Typing and Dynamic Binding






Arrays and Structures





Arrays 

In Single Variabule we can hold many diff values
They are two types of Array
1}ImmutabuleArray(NSArray)
2)MutableArray(NSMutabuleArray)


















code for Array:

//
//  ViewController.m
//  ArrayDemo
//
//  Created by apple on 16/02/13.
//  Copyright (c) 2013 apple. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
    [super viewDidLoad];// Do any additional setup after loading the view, typically from a nib.
  
    double name[2];
    //name[0],name[1],name[2]
  
    name[1]=200.00;
    name[0]=100.00;
    double MyVal=300.00;
  
  
    //NSLog(@"name[0])------>%.2f",name[0]);
  
   // NSLog(@"name[1])------->%.2f",name[1]);

    //NSLog(@"myValue)------->%.2f",MyVal);
  
  
    double MyVal1=300.00;
    double names[2]={100.0,200.0,MyVal1};
  
    NSLog(@"names[0])------>%.2f",names[0]);  
     NSLog(@"names[1])------->%.2f",names[1]);  
    NSLog(@"names[2])------>%.2f",names[2]);  
  
  
  
  
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];    // Dispose of any resources that can be recreated.
}
@end


1)NSArray:

It is a static Array
if we create obj once we cant remove obj
occupies less memory
add obj during initialigation









code for NSArray: 

//
//  main.m
//  NSAraayDemo
//
//  Created by apple on 16/02/13.
//  Copyright (c) 2013 apple. All rights reserved.
//
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
    @autoreleasepool {      
        // insert code here...
        NSLog(@"Hello, World!");      
     /*       NSArray *names=[[NSArray alloc]initWithObjects:@"naveen",@"Raja",@"Sandeep",nil];
      
        NSLog(@"%@",[names objectAtIndex:1]);
      
        for(int i=0;i<[names count];i++)
        {
            NSLog(@"%@",[names objectAtIndex:i]);
      
        }*/
      
      
      
      
      
      
        NSArray *Details = [NSArray arrayWithObjects:    [NSDictionary dictionaryWithObjectsAndKeys:    @"Naveen", @"name",[NSNumber numberWithInt: 21], @"age",[NSNumber numberWithInt: 23], @"num",nil],                           
    
                          
[NSDictionary dictionaryWithObjectsAndKeys:@"Raja", @"name",[NSNumber numberWithInt:23], @"age",[NSNumber numberWithInt: 2], @"num",nil],  
                          
                          
[NSDictionary dictionaryWithObjectsAndKeys:@"Sandeep", @"name",[NSNumber numberWithInt: 20], @"age",[NSNumber numberWithInt: 3], @"num",nil],                             nil];
      
      
      
   // NSLog(@"%@",[Details objectAtIndex:1]);
      
        for(int i=0;i<[Details count];i++){
      
        NSLog(@"%@",[Details objectAtIndex:i]);
      
        }
      
     
    }
    return 0;
}


2)NSMutabuleArray:

It is an Dynamic Array(Mutabule)
it changes the values inside existing Array Obj
occupies more mem


Mehods:

addObjectinsertObjectreplaceObjectAtIndexremoveObjectAtIndexremoveLastIndexremoveAllObjects







Code For NSMutabuleArray:


//
//  main.m
//  MutabuleArrayDemo
//
//  Created by apple on 17/02/13.
//  Copyright (c) 2013 apple. All rights reserved.
//
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
    @autoreleasepool {      
        // insert code here...
        NSLog(@"Hello, World!");      
       //NSMutsbule array Declaration1
      
        NSMutableArray *names=[[NSMutableArray alloc]init];      
        //adding names to an array
        [names addObject:@"Naveen"];
        [names addObject:@"Sandeep"];
        [names addObject:@"Raju"];
      
        for(NSString *name in names)
        {
            NSLog([NSString stringWithFormat:@"names--->%@",name]);        }
      
        //NSMutsbule array Declaration2
        NSMutableArray *names1=[[NSMutableArray alloc]initWithCapacity:23];        [names1 addObject:@"Hyderabad"];
        [names1 addObject:@"Bangalore"];
        [names1 addObject:@"Channai"];
        //replacing at index 1
        [names1 replaceObjectAtIndex:1 withObject:@"Delhi"];        //Removing Index
        [names1 removeObjectAtIndex:1];//Delhi removed      
      
        //removing Last Index
        [names1 removeLastObject];//Chennai Removed      
        //After Removing again Adding
        [names1 addObject:@"Bangalore"];
        [names1 addObject:@"Channai"];
        //remove All
        [names1 removeAllObjects];
      
for(NSString *State in names1)
{
    NSLog([NSString stringWithFormat:@"States----->%@",State]);}
 
      
      
      
      
      
      
    }
    return 0;
}



                        

Structures:

It is a user defined Data Type we can store diff data under unique name

typedef is to create a new type name for builtin type

Code for Structures:


//
//  main.m
//  StrctureDemo
//
//  Created by apple on 17/02/13.
//  Copyright (c) 2013 apple. All rights reserved.
//
#import <Foundation/Foundation.h>


typedef struct
{
  
    float Sal;
    double AnualSal;
    char *name;
}Details;

int main(int argc, const char * argv[])
{
    @autoreleasepool {      
        // insert code here...
        NSLog(@"Hello, World!");      
        Details det,det2,det3;
      
      
        //for Details 1
        det.Sal=25000;
        det.AnualSal=3.6;
        det.name="Naveen";
        NSLog(@"Employee Name  is %s",det.name);
        NSLog(@"Sal is %.2f",det.Sal);
        NSLog(@"Anual Sal IS %.2f",det.AnualSal);      
      
      
      
        //Details 2
        det2.Sal=15000;
        det2.AnualSal=2.1;
        det2.name="Sandeep";
        NSLog(@"Employee Name2  is %s",det2.name);      
        NSLog(@"Sal2 is %.2f",det2.Sal);
        NSLog(@"Anual Sal2 IS %.2f",det2.AnualSal);      
      
      
        //Details 3
      
        det3=det;
        NSLog(@"name3--->%s",det3.name);
        NSLog(@"Sal3---> %.2f",det3.Sal);
        NSLog(@"Anual Sal3 -->%.2f",det3.AnualSal);      
    }
    return 0;
}