Friday 18 November 2011

Some well used codes

======= framework path as iAD game path
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk/System/Library/Frameworks/iAd.framework

Maybe you can reference it only by adding in the Build Setting -> Other Linker Flags the value -weak_framework and after that entrance add in another row iAD

=======alert view
UIAlertView    *alert = [[UIAlertView alloc] initWithTitle:@"Password Changed"
                                                        message:@"Successfully"
                                                       delegate:self
                                              cancelButtonTitle:@"Ok"
                                              otherButtonTitles:nil];
        [alert show];
        [alert release];
      
================ NAVIGATION CODE
SignInHomePage *detailViewController = [[SignInHomePage alloc] initWithNibName:@"SignInHomePage" bundle:nil];
detailViewController.name = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement,3)];
detailViewController.masterID = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement,0)];
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
  
================DB CODE
        sqlite3 *database;
  
   
        int result = sqlite3_open("abc.sql", &database);
      
        if(result != SQLITE_OK){
            sqlite3_close(database);
            UIAlertView *alert =
            [[UIAlertView alloc] initWithTitle:@"Database Connected"
                                       message:@"No"
                                      delegate:self
                             cancelButtonTitle:@"OK"
                             otherButtonTitles:nil];
          
            [alert show];   
            [alert release];          
        }
        else{  
            NSString *query = [[NSString alloc] initWithFormat:@"CREATE TABLE IF NOT EXISTS mainTable(mastersno INTEGER PRIMARY KEY AUTOINCREMENT,"
   "masterusername TEXT, masterpswd TEXT,mastername TEXT,securityq TEXT,securitya TEXT);"];
            NSLog(@"Query : %@",query);          
            if(sqlite3_exec(database,[query UTF8String],NULL, NULL, NULL)){// return 0 if succesfully inserted
                                   UIAlertView *alert =[[UIAlertView alloc] initWithTitle:@"Error :"
                                                                                  message:@"Database Table Problem."
                                                                                 delegate:self
                                                                        cancelButtonTitle:@"OK"
                                                                        otherButtonTitles:nil];
                                 
                                   [alert show];   
                                   [alert release];
                               }
                             
            query =[NSString stringWithFormat:@"INSERT INTO mainTable (masterusername,masterpswd,mastername,securityq,securitya) VALUES "
                            "('%@','%@','%@','%@','%@')",emailid.text,pass1.text,name.text,securityQ.text,securityA.text];
            NSLog(@"Query : %@",query);          
            if(sqlite3_exec(database,[query UTF8String],NULL, NULL, NULL)){// return 0 if succesfully inserted
                UIAlertView *alert =[[UIAlertView alloc] initWithTitle:@"Error :"
                                           message:@"Information has not been updated successfully."
                                          delegate:self
                                 cancelButtonTitle:@"OK"
                                 otherButtonTitles:nil];
              
                [alert show];   
                [alert release];
            }else {
                UIAlertView *alert =[[UIAlertView alloc] initWithTitle:@"Confirmation"
                                           message:@"Information has been updated successfully."
                                          delegate:self
                                 cancelButtonTitle:@"OK"
                                 otherButtonTitles:nil];
              
                [alert show];   
                [alert release];
            }          
          
        sqlite3_stmt *statement;
        NSString *query = [[NSString alloc] initWithFormat:@"SELECT *FROM InfoAll WHERE userID='1' AND (username LIKE '%RAM%' OR url  LIKE '%RAM%'"];
        NSLog(@"Query  :  %@",query);
        sqlite3_prepare_v2(database,[query UTF8String], -1, &statement, nil);
        while(sqlite3_step(statement) == SQLITE_ROW){
            NSLog(@"Query :%@",[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement,2)]);              
        }
        sqlite3_finalize(statement);
        sqlite3_close(database);
        }
===== validation code
-(BOOL)validation{
    NSString *errorString =[[NSString alloc] initWithString:@"Error :"];
    BOOL flag=NO;
    if ([name.text length]==0) {
        errorString = [errorString stringByAppendingFormat:@"Name"];
        flag=YES;
    }
    if ([emailid.text length]==0) {
        if (flag) {
            errorString = [errorString stringByAppendingFormat:@", email ID"];
        }
        else {
            errorString = [errorString stringByAppendingFormat:@"email ID"];
            flag=YES;
        }
    }
    if ([pass1.text length]==0) {
        if (flag) {
            errorString = [errorString stringByAppendingFormat:@", password"];
        }
        else {
            errorString = [errorString stringByAppendingFormat:@"password"];
            flag=YES;
        }
    }
    if ([pass2.text length]==0) {
        if (flag) {
            errorString = [errorString stringByAppendingFormat:@", Retype Password"];
        }
        else {
            errorString = [errorString stringByAppendingFormat:@"Retype Password"];
            flag=YES;
        }      
    }
    if ([securityQ.text length]==0) {
        if (flag) {
            errorString = [errorString stringByAppendingFormat:@", security Question"];
        }
        else {
            errorString = [errorString stringByAppendingFormat:@"Security Question"];
            flag=YES;
        }
    }
    if ([securityA.text length]==0) {
        if (flag) {
            errorString = [errorString stringByAppendingFormat:@", security answer"];
        }
        else {
            errorString = [errorString stringByAppendingFormat:@"security answer"];
            flag=YES;
        }
    }
  
    if (flag) {
        errorString = [errorString stringByAppendingFormat:@" cannot leave empty."];
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"ERROR"
                                                        message:errorString
                                                       delegate:self
                                              cancelButtonTitle:@"Ok"
                                              otherButtonTitles:nil];
        [alert show];
        [alert release];
      
        return NO;
    }
    else {
        if (![pass1.text isEqualToString:pass2.text]) {
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"ERROR"
                                                                message:@"Password and Retype Password not matched"
                                                               delegate:self
                                                      cancelButtonTitle:@"Ok"
                                                      otherButtonTitles:nil];
                [alert show];
                [alert release];
                return NO;
        }
        return YES;
    }  
}

1 comment:

  1. http://www.makebetterthings.com/iphone/introduction-to-version-control-system/
    VCS Saurabh Sharma

    ReplyDelete