NSUserDefaults to save and retrieve the data in iPhone

In many applications we need to save the state of the application, in that case we can use NSUserDefaults.

Lets start with saving the data into NSUserDefaults. We can save small amount of data in NSUserDefaults such as username, high scrore, etc.

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

[defaults setObject:@”username” forKey:@”UserName”];

This is to save the NSString. Also integer, float, double can be saved.

e. g. [defaults setInteger:100 forKey:@”HighScore”];

Now how to retrieve the data by using the keys which we have assigned…

NSString *myUserName = [defaults stringForKey:@”UserName”];

int  highScore = [defaults integerForKey:@”HighScore”];

Thats it…

Happy coding………!!!:)

Weird movment of character in Unity3D

Question:I imported a simple 3d model from which I construtected a terain. For a test I use box(mesh), but movment is really weird like that models would be realy bumpy. Because of that I also tryed to switch my models with unity meshes but it’s same


Answer:In ur game select cube in that u have added rigidbody.

In Rigidbody select the constraints in that u will see freeze rotation and freeze position. in which all are uncheck.

now check the freeze rotation in which all should be ticked.

by doing this they will not be any flickers in your game.

  игровые автоматы играть онлайн бесплатно без регистрации и смс 777

CActive Object in Symbian C++

Active Object provides a support for asynchronous process.

let’s see example of Timer using CActive :- Active Object can be implemented by deriving from the CActive class

void CTestTimerAO::RunL()//RunL-The handler function to be invoked by the active scheduler when the request completes
iTimeString = _L(“”);
iMs = iMs + 1;
TUint64 minute;
TUint64 second;
TUint64 millisecond;
second = (iMs – iMs%100) / 100;
millisecond = iMs – 100 * second;
minute = (second – second % 60) / 60;
second = second – 60 * minute;
if(minute < 10)
iTimeString.AppendNum(minute, EDecimal);

if(second < 10)
iTimeString.AppendNum(second, EDecimal);

if(millisecond < 10)
iTimeString.AppendNum(millisecond, EDecimal);
TInt sec = (int)second;
STATIC_CAST(CdemoAppUi *,CEikonEnv::Static()->EikAppUi())->newSeconds = sec;

void CTestTimerAO::Start()
iTimer.After(iStatus, 1000);//iStatus-A data member representing the status of the request


void CTestTimerAO::After(TTimeIntervalMicroSeconds32 aInterval)
iTimer.After(iStatus, aInterval);//iTimer – Object of RTimer

void CTestTimerAO::DoCancel()
iTimer.Cancel();//The function to cancel an outstanding request

How to dial phone number programatically in iPhone / xCode?

UIDevice *device = [UIDevice currentDevice];

if ([[device model] isEqualToString:@”iPhone”] ) {

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@”tel:130-032-2837″]]];

} else {

UIAlertView *Notpermitted=[[UIAlertView alloc] initWithTitle:@”Alert” message:@”Your device doesn’t support this feature.” delegate:nil cancelButtonTitle:@”OK” otherButtonTitles:nil];

[Notpermitted show];

[Notpermitted release];



“how to find Image size for a url in iPhone”

float size =  [UIImageJPEGRepresentation(Image,0.9) length]/1024.0/1024.0;

//in above line  Image is your image name

//NSLog(@”File Size : %f”, size);


if (size == 0)


UIImage *imagenew = [UIImage imageNamed”img-not-available.jpg”];

[ImageButton setImage:imagenew forState:UIControlStateNormal];



[ImageButton setImage:Image forState:UIControlStateNormal];


Charset in php

For Example to support Chinese Language web site

<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″ />

//Inserting & Retrieving data from database
mysql_query (“set character_set_results=’gb2312′”);  or
mysql_set_charset(“gb2312”); or
mysql_query(“SET NAMES gb2312”);

Please follow below link you will get all charset which is use in php.


Switching Views In Symbian C++

Switching view code in Symbian c++

CEikonEnv* tEikonEnv=CEikonEnv::Static();

((CdemoAppUi*)(tEikonEnv->EikAppUi()))->ActivateLocalViewL(TUid::Uid(EStopwatchViewId));//EStopwatchViewId- enum uid



Need more help?

Hi there, was your problem or query resolved? If not & need more assistance, please do reach out to us at info@nanostuffs.com, we'll be more than delighted to help. Nanostuffs has 7+ years of extensive Salesforce & iOS/Android experience.
Holler Box