Author Archive

Validating Email Address in Objective C

- (BOOL) validateEmail: (NSString *) emailVal {

    NSString *emailregex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailregex];
    return [emailTest evaluateWithObject:emailVal];
}

you can make a function call like this.

[self validateEmail:@"xyz@example.com"];

take picture in corona

media.show( media.Camera, postCaptureAction )

will open the device camere. ‘postCaptureAction’ will get called when we select the image from camera.

get length of a string in corona

local length = string.len(myString)  gives the length of a string in corona.

change separator color of a tableView

The following code changes the default color of the tableviewcell separator to the specified color.

self.table.separatorColor=[UIColor whiteColor];

convert nsstring to char*

const char *c = [s UTF8String];
where s is my NSString

Creating MySql Database in XCode

       
sqlite3 *database;
	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	NSString *documentsDirectory = [paths objectAtIndex:0];
	NSString *myPathDocs =  [documentsDirectory stringByAppendingPathComponent:DB_NAME];
	
	const char* pathChar = [myPathDocs UTF8String];
	
	int result = sqlite3_open(pathChar, &database);
	if(result != SQLITE_OK)
	{
		sqlite3_close(database);
		NSLog(@"Failed to open Database");
		return;
	}
    else
    {
        NSLog(@"Database Created Succesfully");
    }
sqlite3_close(database);

Using Global View Controller in XCode

[[[[[UIApplication sharedApplication] delegate] window] rootViewController] presentModalViewController:myViewController animated:YES]

Segmented Control in Sencha

var App = new Ext.Application({         

name: ‘TestApp’,

useLoadMask: true,

launch: function () {

var segmentedButton = new Ext.SegmentedButton({

allowMultiple: true,

items: [

{

text: 'Option 1',

pressed: true

},

{

text : 'Option 2'

 
 

},

{

text: 'Option 3'

}

],

listeners: {

toggle: function(container, button, pressed){

//console.log(button.txt);

//console.log(“User toggled the ‘” + button.text + “‘ button: ” + (pressed ? ‘on’ : ‘off’));

if (button.text == ‘Option 1′)

{

panel.setActiveItem(0, { type: ‘slide’, direction: ‘left’ });

}

 
 

else if (button.text == ‘Option 2′)

{

panel.setActiveItem(1, { type: ‘slide’, direction: ‘left’ });

}

 
 

else if (button.text == ‘Option 3′)

{

panel.setActiveItem(2, { type: ‘slide’, direction: ‘left’ });

}

}

}

});

 
 

 
 

var panel = new Ext.Panel({

fullscreen: true,

dockedItems: [segmentedButton],                        

layout:’card’,

items:[{

html: 'Option 1 Button Toggle!'

},

{

html: 'Option 2 Button Toggle!'

},{

html: 'Option 3 Button Toggle!'

}]

 
 

 
 

});                

}

});

Simple Slider in Sencha

var App = new Ext.Application({         

name: ‘TestApp’,

useLoadMask: true,

launch: function () {        

new Ext.Panel({

fullscreen: true,                                

items: new Ext.form.Slider({

value: 5,

minValue: 0,

maxValue: 10

}),

html: ‘Testing Form Element – Slider’

});                

}

});

Simple Action Sheet in Sencha

var App = new Ext.Application({         

name: ‘TestApp’,

useLoadMask: true,

launch: function () {

var actionSheet = new Ext.ActionSheet({

items: [

{

text: 'Delete draft',

ui : 'decline'

},

{

text: 'Save draft'

},

{

text: 'Cancel',

ui : 'confirm'

}

]

});

actionSheet.show();

 
 

}

});

Page 2 of 4212345...102030...Last »
We Can Build Your App for You. Lets Get Started !