July 16, 2014

Why do we use NSNumber in iOS?

NSNumber is an Objective-C class, a subclass of NSValue . It’s main work is to store and retrieve primitive data. We can store NSNumber object in collection. such as NSArray where an object is need to set the value. For example, if you need to insert a int into an NSArray, So create an NSNumber object from the int: int number = 12; NSNumber *intNum = [NSNumber numberWithInt:number]; ...

Read more
July 16, 2014

How to set wallpaper programmatically in Android ?

/* To get Bitmap from your res folder */ Bitmap bitmap = BitmapFactory.decodeResource(getResources(), flag[position]); WallpaperManager wallpaperManager = WallpaperManager.getInstance(getApplicationContext()); try { DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); /*To get the screen height & width */ int height = displayMetrics.heightP ...

Read more
July 16, 2014

What is protocol in Objective C ?

Protocol is used for declaring methods (optional or required), and these method will be implemented by a class (which will adopt this protocol). For example : Here we have defined a signature of protocol implementation. @protocol ConnectToWebDelegate @optional - (void)didReceivedResponse:(NSString*)response; - (void)errorFailure: (NSError*)error; @required -(void)didReceiveResponseCode:(NSInteger*)responseC ...

Read more
July 16, 2014

How to open a website in webview in iOS ?

/* Create a UIWebView in Storyboard or XIB or by code */ #import "UIKit/UIKit.h" @interface ViewController : UIViewController @property (retain, nonatomic) IBOutlet UIWebView *webView; @end #import "ViewController.h" @interface ViewController () { UIAlertView *alert; } @end @implementation ViewController @synthesize webView; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading ...

Read more
July 14, 2014

How to send HTTP Request in iOS ?

- (void) httpRequestExample { NSError *requestError; NSURLResponse *urlResponse = nil; NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; //Seting url here [request setURL:[NSURL URLWithString:@"url"]]; NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&requestError]; //Converting response from NSData value to NSString. ...

Read more
July 10, 2014

Write a program for matrix multiplication in C?

#include"stdio.h" #include"conio.h" #include"malloc.h" void main() { textcolor(115); textbackground(77); clrscr(); int i,j,k,r,c,r1,c1; int **a,**b,**f; printf("\n\n\t\tHow many row is require for the First Array\n\n"); scanf("%d",&r); printf("\n\n\t\tHow many colomn is require for the First Array\n\n"); scanf("%d",&c); printf("\n\n\t\tHow many row is require for the second Array\n\n"); scanf("%d",&r1); pri ...

Read more
July 10, 2014

Write a program to add two polynomials in C?

#include "stdio.h" #include "conio.h" #include "malloc.h" struct poly{ int coeff; int exp; struct poly *next; }; struct poly *p1=NULL,*p2=NULL,*newpoly=NULL; void insert(struct poly *node) { char ch; do { printf("\n\t Coeff:-"); scanf("%d",&node->coeff); printf("\n\t Exp:-"); scanf("%d",&node->exp); node->next=(struct poly*)malloc(sizeof(struct poly)); node=node->next; node->next=NULL; printf("\n More(y/n): ...

Read more
Scroll to top