Category Archives: Apple

Download an image with ProgressBar in iOS

Hi all,

Today I will show you how you can download an image showing complete progress.

Make sure that you have an interface like the below image.

Download Image IOS Progress

You should link all the interface views with the corresponding variables in ViewController.h

ViewController.h


#import <uikit /UIKit.h>

@interface ViewController : UIViewController <nsurlconnectiondatadelegate>

@property (weak, nonatomic) IBOutlet UIProgressView *progressView;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (nonatomic, weak) IBOutlet UIButton   *btn_download;
@property (nonatomic, weak) IBOutlet UILabel   *lbl_download;

@end


ViewController.m



#import "ViewController.h"

@interface ViewController ()

@property (strong, nonatomic) NSURLConnection *connectionManager;
@property (strong, nonatomic) NSMutableData *downloadedMutableData;
@property (strong, nonatomic) NSURLResponse *urlResponse;

@end

@implementation ViewController{
    
#define IMAGE_URL @"http://img1.wikia.nocookie.net/__cb20111229061816/lego/images/b/b8/Ws-space-apple-logo.jpg"
}

- (void)viewDidLoad
{
    [super viewDidLoad];   
}

-(IBAction)downloadImage :(id)sender{
    
    self.btn_download.enabled = NO;
    self.downloadedMutableData = [[NSMutableData alloc] init];
    NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:IMAGE_URL]
                                                cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
                                            timeoutInterval:60.0];
    self.connectionManager = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

#pragma mark - Delegate Methods
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
    NSLog(@"%lld", response.expectedContentLength);
    self.urlResponse = response;
}

-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    [self.downloadedMutableData appendData:data];
    self.progressView.progress = ((100.0/self.urlResponse.expectedContentLength)*self.downloadedMutableData.length)/100;
    
    float per = ((100.0/self.urlResponse.expectedContentLength)*self.downloadedMutableData.length);
    self.lbl_download.text = [NSString stringWithFormat:@"%0.f%%", per];
    
    if (self.progressView.progress == 1) {
        self.progressView.hidden = YES;
        self.btn_download.enabled = YES;
    } else {
        self.progressView.hidden = NO;
    }
    
}

-(void)connectionDidFinishLoading:(NSURLConnection *)connection {
    self.imageView.image = [UIImage imageWithData:self.downloadedMutableData];
    self.lbl_download.text = @"Download Complete";
}

@end

You can download the complete source code from here.

Creating a Custom Alert or PopUp in iOS

Custom PopUp IOS

First we will write a class that extends UIView to create a Custom PopUp

Create a Cocoa file and name it CustomPopUp

You should get two files CustomPopUp.h and CustomPopUp.m

CustomPopUp.h


#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@protocol ClickDelegates;

@interface CustomPopUp : UIView{
    
      UIView *childPopUp;
      id<ClickDelegates> _click_delegate;
      UIViewController *_parent;
    
}

@property (nonatomic, retain) id<ClickDelegates> _click_delegate;
@property (nonatomic, retain) UIViewController *_parent;

-(void) initAlertwithParent : (UIViewController *) parent withDelegate : (id<ClickDelegates>) theDelegate;

-(IBAction)OnOKClick :(id) sender;

-(void) hide;

-(void) show;

@end


// Delegate

@protocol ClickDelegates<NSObject>

@optional

-(void) okClicked;
-(void) cancelClicked;

@end

CustomPopUp.m



#import "CustomPopUp.h"
#import "Util.h"

@implementation CustomPopUp{
    
    float popUpX;
    CGRect popUpRect;
}

@synthesize _click_delegate, _parent;


-(void) initAlertwithParent : (UIViewController *) parent withDelegate : (id<ClickDelegates>) theDelegate{
    
    self._click_delegate = theDelegate;
    self._parent = parent;
    
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    CGFloat screenWidth = screenRect.size.width;
    CGFloat screenHeight = screenRect.size.height;
    
    CGRect rect = CGRectMake(0, 0, screenWidth, screenHeight);
    self.frame = rect;
    self.backgroundColor = [UIColor clearColor];
    
    childPopUp = [UIView new];
    float popUpHeight = screenHeight/3;
    
    popUpX = 20.0;
    
    popUpRect = CGRectMake(popUpX, (screenHeight - popUpHeight)/2, screenWidth - (popUpX * 2), popUpHeight);
    childPopUp.center = self.center;
    self.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);
    [self setBorderOnly:childPopUp withBGColor:[UIColor orangeColor] withCornerRadius:5.0 andBorderWidth:0.0 andBorderColor:[UIColor greenColor] WithAlpha:1];
    childPopUp.frame = popUpRect;
    [self addSubview:childPopUp];
  
    [self addLabel];
    
    [self addButton];
    
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.2];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(bounce1AnimationStopped)];
    self.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
    [UIView commitAnimations];
    
}

-(void) show{

    [self._parent.view addSubview:self];
}

-(void) addLabel{
    
    // Add Label
    UILabel *lblForDisplay=[[UILabel alloc]initWithFrame:CGRectMake(popUpX, popUpX, popUpRect.size.width - popUpX, popUpX)];
    lblForDisplay.backgroundColor=[UIColor clearColor];
    lblForDisplay.textColor=[UIColor blackColor];
    lblForDisplay.text=@"This is a custom Alert";
    [childPopUp addSubview:lblForDisplay];
    
}


-(void) addButton{
    
    // Add Button
    UIButton *okBtn = [[UIButton alloc]initWithFrame:CGRectMake(popUpX, childPopUp.frame.size.height - 50, popUpRect.size.width - 40, 40)];
    okBtn.backgroundColor=[UIColor blueColor];
    [self setBorderOnly:okBtn  withBGColor:[UIColor greenColor] withCornerRadius:5.0 andBorderWidth:0.0 andBorderColor:[UIColor greenColor] WithAlpha:1];
    [okBtn setTitle:@"OK" forState:UIControlStateNormal];
    [okBtn addTarget:self action:@selector(OnOKClick:) forControlEvents:UIControlEventTouchDown];
    [childPopUp addSubview:okBtn];
    
}

-(IBAction)OnOKClick :(id) sender{
    
    [_click_delegate okClicked];
    
}

-(void) show : (UIViewController *) parent{
    
}

-(void) hide{
    
    [self removeFromSuperview];
    
}

- (void)bounce1AnimationStopped {
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:.2];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(bounce2AnimationStopped)];
    self.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);
    [UIView commitAnimations];
}

- (void)bounce2AnimationStopped {
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:.2];
    self.transform = CGAffineTransformIdentity;
    [UIView commitAnimations];
}


-(void) setBorderOnly:(UIView *) theView withBGColor:(UIColor *) color withCornerRadius :(float) radius andBorderWidth :(float) borderWidth andBorderColor :(UIColor *) bgColor WithAlpha:(float) curAlpha
{
    theView.layer.borderWidth = borderWidth;
    theView.layer.cornerRadius = radius;
    theView.layer.borderColor = [color CGColor];
    UIColor *c = [color colorWithAlphaComponent:curAlpha];
    theView.layer.backgroundColor = 1;
}

@end

I have a sample interface like this.

Custom PopUp IOS

Now the ViewController.m



#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController{

    CustomPopUp *mPopUp;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //create delegate    
    mPopUp = [CustomPopUp new];
    [mPopUp initAlertwithParent:self withDelegate:self];
    
    
}

-(void) okClicked{

    [mPopUp hide];
    
}

-(void) cancelClicked{
    NSLog(@"Cancel");
}

-(IBAction)showAlert :(id)sender{
    [mPopUp show];
}

-(IBAction)dummyClick :(id)sender{
    
    NSLog(@"Click Dummy");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end

MAKE SURE YOU HOOK UP THE BUTTONS TO THEIR CORRESPONDING FUNCTIONS.

You can download the complete source code from here.

Select an image from Gallery and show it in an ImageView in ios.

Hey all,

This is a simple post showing how you can open the “Gallery” or “Photos” application in iOS.

The Sample UI should look like this.

Select image from Gallery in ios

Screenshot selecting image from the Gallery.

Select image from gallery in ios

Now to the code.

ViewController.m

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController <UINavigationControllerDelegate,
UIImagePickerControllerDelegate>


@property (strong, nonatomic) IBOutlet UIImageView* imageView;

- (IBAction) pickImage:(id)sender;


@end

ViewController.m


#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}

- (IBAction) pickImage:(id)sender{
    
    UIImagePickerController *pickerController = [[UIImagePickerController alloc]
                                                 init];
    pickerController.delegate = self;
    [self presentViewController:pickerController animated:YES completion:nil];
}

#pragma mark -
#pragma mark UIImagePickerControllerDelegate

- (void) imagePickerController:(UIImagePickerController *)picker
         didFinishPickingImage:(UIImage *)image
                   editingInfo:(NSDictionary *)editingInfo
{
    self.imageView.image = image;
    [self dismissModalViewControllerAnimated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end

We add “UINavigationControllerDelegate,UIImagePickerControllerDelegate” to get the events after selecting the image from
the Gallery.

The below function is called after selecting image from Gallery

- (void) imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo

You can download the complete source code from here.

Open Camera, Take Photo, Save it, Load it – iOS Sample code

This example shows how to Open Camera, Take Photo, Save it, Load it in iOS.

Camera Functions in IOS


Before this make sure that you have two buttons and one imageview in the Interface (image above) and link them to appropriate actions
and variables

ViewController.h”


#import <UIKit/UIKit.h>

@interface ViewController : UIViewController <UIImagePickerControllerDelegate>
{
    UIImagePickerController *imagePicker;
    IBOutlet UIImageView *imageView;
}

- (IBAction)showCamera:(id)sender;
- (IBAction)loadImage:(id)sender;

@end


ViewController.m



#import "ViewController.h"

@interface ViewController ()
{
    #define FILE_EXTENSION    @".png"
    #define IMAGE_NAME        @"CameraImage"
}
@end

@implementation ViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {
        imagePicker = [[UIImagePickerController alloc]init];
        imagePicker.delegate = self;
        imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        imagePicker.allowsEditing = YES;
        
    }else{
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Camera Unavailable"
                                                       message:@"Unable to find a camera on your device."
                                                      delegate:nil
                                             cancelButtonTitle:@"OK"
                                             otherButtonTitles:nil, nil];
        [alert show];
        alert = nil;
    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

- (IBAction)showCamera:(id)sender {
    [self presentViewController:imagePicker animated:YES completion:nil];
}

+(NSString *)documentsPath:(NSString *)fileName {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:fileName];
    NSLog(@"%@", fullPath);
    
    return fullPath;
}

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    NSString *fileSavePath = [ViewController documentsPath:IMAGE_NAME];
    fileSavePath = [fileSavePath stringByAppendingString:FILE_EXTENSION];
    
    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
    if (image == nil) {
        image = [info objectForKey:UIImagePickerControllerOriginalImage];
    }
    
    //This checks to see if the image was edited, if it was it saves the edited version as a .png
    if ([info objectForKey:UIImagePickerControllerEditedImage]) {
        //save the edited image
        NSData *imgPngData = UIImagePNGRepresentation([info objectForKey:UIImagePickerControllerEditedImage]);
        [imgPngData writeToFile:fileSavePath atomically:YES];
        
        
    }else{
        //save the original image
        NSData *imgPngData = UIImagePNGRepresentation([info objectForKey:UIImagePickerControllerOriginalImage]);
        [imgPngData writeToFile:fileSavePath atomically:YES];
        
    }
    
    [self dismissViewControllerAnimated:YES completion:nil];
    
}

-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (IBAction)loadImage:(id)sender{
    NSString *path = [NSString stringWithFormat:@"%@%@",[ViewController documentsPath:IMAGE_NAME], FILE_EXTENSION];
    NSData *imgData = [NSData dataWithContentsOfFile:path];
    UIImage *thumbNail = [[UIImage alloc] initWithData:imgData];
    imageView.image = thumbNail;
}

@end

Customizing UITableView using “Prototype Cells” in iOS.

Hi all,

In today’s tutorial we will study how we can customize a UITableView using “Prototype Cells” in iOS which was introduced
in XCode 5.0.

First Create a new Project and Name it “CustomTBLView”.

Now you will get the Main.storyBoard file with other ViewController and Delegate Files.

Open Main.storyBoard and “Drag” a TableView on to it.

Now Drag a “UITableViewCell” on to it. This is the Prototype Cell.

Now our “Main.storyBoard” looks like this.

Prototype Cells in iOS

Now select the tableView cell from the Hierarchy and Go to the “Attributes Inspector” on the right side.

Select Style = ” Basic ”
Indentifier = “list_item_cell”

Now you will see that a “Label” will appear in the cell.
Click on the label and go to “Attributes Inspector” and give tag as “100”.

Prototype Cells in iOS

Here “list_item_cell” is the identifier for each prototype cell.
We will use this identifier to get the cell and populate the items.

[ Make sure you like the “delegate” and “datasource” to the ViewController, otherwise no data will be loaded in
the tableview ]

Our work in the Interface Builder is over.

Now Lets do the coding part

Go to the ViewController.h and paste the delegates and the array

ViewController.h

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
{
    
}

@property (strong, nonatomic) NSMutableArray *_tblData;

@end

Now go to ViewController.m and synthesize the array.

These are the delegate methods

- (NSInteger)numberOfSectionsInTableView: (UITableView *)tableView {
}
- (NSInteger)tableView: (UITableView *)tableView numberOfRowsInSection: (NSInteger)section {
}
- (UITableViewCell *)tableView: (UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath {
}

Now your ViewController.m will look like this.



#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

@synthesize _tblData;

- (void)viewDidLoad {
    [super viewDidLoad];
    
    if (!_tblData) {
        _tblData = [[NSMutableArray alloc] initWithObjects:@"iPhone", @"Android", @"Windows", @"Apple", @"Google", @"Microsoft", nil];
    }

}

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

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

}

- (UITableViewCell *)tableView: (UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath {
   
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"list_item_cell"];
    UILabel *lblName = (UILabel *)[cell viewWithTag:100];
    [lblName setText:[_tblData objectAtIndex:[indexPath row]]]; return cell;

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end

OK Done. Run the project.

Prototype Cells in iOS

Handling Files in iOS

Hi All,

In Todays article we will see how we can handle files in Objective C.

The list of the methods used for accessing and manipulating files are listed below. Here you have to replace the FilePath1, FilePath2 and FilePath strings to our required full file paths to get the desired action.

NSFileManager *fileManager = [NSFileManager defaultManager];
 //Get documents directory
 NSArray *directoryPaths = NSSearchPathForDirectoriesInDomains
 (NSDocumentDirectory, NSUserDomainMask, YES);
 NSString *documentsDirectoryPath = [directoryPaths objectAtIndex:0];
 if ([fileManager fileExistsAtPath:@""]==YES) {
           NSLog(@"File exists");
 } 

Comparing two file contents

 if ([fileManager contentsEqualAtPath:@"FilePath1" andPath:@" FilePath2"]) {
         NSLog(@"Same content");
 }

Check if writable, readable and executable

 
 if ([fileManager isWritableFileAtPath:@"FilePath"]) {
         NSLog(@"File isWritable");
 }

  if ([fileManager isReadableFileAtPath:@"FilePath"]) {
          NSLog(@"File isReadable");
 }


 if ( [fileManager isExecutableFileAtPath:@"FilePath"]){
          NSLog(@"File is Executable");
 }

Move file

 if([fileManager moveItemAtPath:@"FilePath1" toPath:@"FilePath2" error:NULL]){
          NSLog(@"File Moved successfully");
 }

Copy file

 
if ([fileManager copyItemAtPath:@"FilePath1" toPath:@"FilePath2" error:NULL]) {
          NSLog(@"File Copied successfully");
 }

Remove file

 if ([fileManager removeItemAtPath:@"FilePath" error:NULL]) {
          NSLog(@"File Removed successfully");
 }

Read file

 NSData *data = [fileManager contentsAtPath:@"Path"];

Write file

 [fileManager createFileAtPath:@"" contents:data attributes:nil];

Delegates in iOS – A Simple Example

Hi All,

Today I am going to talk about iOS Delagates.
This example shows how to write a common delegate for a mail composer in iOS.

First I am going to crate a seperate class for invoking the MailComposer Modal view controller.
The class is named “Common”.

So Create .m and .h files for Common.

Common.h

#import <Foundation/Foundation.h>
#import <MessageUI/MessageUI.h>

@interface Common : NSObject{
    
    MFMailComposeViewController *mailComposer;
    
}

@property (nonatomic, weak) id <MFMailComposeViewControllerDelegate> delegate;

-(void)sendMail:(UIViewController *) cont : (NSString *) mailSubject : (NSString *) mailBody;

-(void) setDelegate:(id <MFMailComposeViewControllerDelegate>)aDelegate;

@end

Now Go to Common.m and implement the methods.

#import "Common.h"

@implementation Common

@synthesize delegate;

-(void)sendMail:(UIViewController *) cont :(NSString *) mailSubject : (NSString *) mailBody{
    
    mailComposer = [[MFMailComposeViewController alloc]init];
    [mailComposer setSubject:mailSubject];
    mailComposer.mailComposeDelegate = delegate;
    [mailComposer setMessageBody:mailBody isHTML:NO];
    [cont presentViewController:mailComposer animated:YES completion:nil];
    
}

-(void) setDelegate:(id <MFMailComposeViewControllerDelegate>)aDelegate{
    if (delegate != aDelegate) {
        delegate = aDelegate;        
    }
}

@end

Now Go to ViewController.h

We don’t need any declarations inside this class, just need to add the delegate

#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>

@interface ViewController : UIViewController<MFMailComposeViewControllerDelegate>
{
    
}
@end

Now in the implementation class

ViewController.m

#import "ViewController.h"
#import "Common.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{

    Common *com = [Common new];
    [com setDelegate:self];   // Setting the Mail Composer delegate
    [com sendMail:self :@"Mail Subject" :@"Mail Body"];
    
}


#pragma mark - mail compose delegate
-(void)mailComposeController:(MFMailComposeViewController *)controller
         didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{
    if (result) {
        NSLog(@"Result : %d",result);
    }
    if (error) {
        NSLog(@"Error : %@",error);
    }
    [self dismissViewControllerAnimated:YES completion:nil];
    
}

Ok. Now our MailComposer Delegate is implemented. Go on and run the application.

Xcode 6 crashes when validating or submitting app archive.

Before somedays some people might have experienced this issue when you are trying to
validate or while submitting, the Xcode just crashes.

However its the problem with the XCode due to wrong programming practice or
not a professional approach from Apple. Apple could have warned the user about what is wrong.

There is a simple solution to this.

  • To check if you need to, you can go to the preferences -> accounts in XCode, Click “View details” of an account and
    attempt to refresh using the little button. Here, XCode will warn you that you need to accept new agreements in the
    Member Center before you can refresh.
  • if ther is any, then you have to go to the Member Center (https://developer.apple.com/devcenter/ios/index.action)
    and Accept all agreements.
  • Double click new provision profiles you downloaded to install them, and then XCode will never crash.

  • The problem is caused by XCode 6.0 does not handle provision profile migration properly.
    Developers should regenerate provision profiles for XCode 6+, but Xcode 6.0 fails to display this error message properly and crashes. (If you use XCode 6.1 Beta, it will display error messages for you, no crash.
    Then you will know that the problem is caused by “invalid”==”legacy” provision profile.)

    After that try again validating and submitting your app and it should Work successfully.

    Thanks for reading this post, if the above solution works, then please rate and comment below.

    How to add info button to right side or leftside of navigationbar in iPhone?

    
        UIButton* infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
        [infoButton addTarget:self action:@selector(showInfoView:) forControlEvents:UIControlEventTouchUpInside];
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:infoButton];
    
    

    Adding button action function.

    - (IBAction)showInfoView:(id)sender {
        
    }
    

    Random Integer array without repetition in Objective C Iphone

    This sample code generates a random number and checks whether its already present in the array.
    If yes then it will not add else it will add, thus generating a random array without duplicates.

    -(NSMutableArray *) generateRandomArray : (int) max{
        NSMutableArray *randArray = [NSMutableArray new];
        for (int k = 0; k < max; k++) {
           int r = arc4random() % max;
            if([randArray containsObject:[NSString stringWithFormat:@"%d", r]]){
                k--;
            }else{
                [randArray addObject:[NSString stringWithFormat:@"%d", r]];
            }
        }
        NSLog(@"RAND %@",randArray);
        return randArray;
    }
    

    Please leave your valuable comments if you found this post useful.

    How to split a string using a delimiter in iPhone and add it to a mutable array?

    Here is a simple code that does this..

    -(NSMutableArray *) getAnswers :(NSString *) yourstring{
        NSMutableArray *answers = [NSMutableArray new];
        NSArray *parts = [[yourstring componentsSeparatedByString:@","];
        for(NSString *str in parts){
            [answers addObject:str];
        }
        NSLog(@"RET answers %@", answers);
        return answers;
    }
    

    After splitting the string with “componentsSeparatedByString” the parts are added to a NSMutableArray using addObject.

    A 4.8 inch iPhone may be on the way

    Every iPhone user may be envious on seeing a bigger screen Android Phone.

    iPhone 5S

    But don’t worry Apple is said to be working on an iPhone with a 4.8-inch screen, a 20% increase in screen size from the iPhone 5S, iPhone 5C and iPhone 5.

    Jeffries analyst Peter Misek has issued a research note to investors where he cited supply chain sources in China claiming that Apple will unveil an iPhone with 4.8-inch screen. This model is scheduled to be launched in September next year and will be named iPhone 6, said Misek.

    You can read more about the story from here

    Apple iPhones may come up with as less as $99 in the future

    iPhone

    Yes,
    these are the rumours about the future iphone. Apple is reportedly looking at iPhones with bigger screens and will be releasing the low cost phone in
    a range of colors as soon as this year, the ABC News reports.

    According to the report, Apple declined to comment on the rumors,
    Cook also said the iPhone doesn’t have a larger screen right now for a few reasons.

    He said that a large screen today comes with a lot of tradeoffs, adding that people do look at the size, but they also look at things like if the photos show the proper color, the white balance, reflectivity, battery life, brightness, the longevity of the display.

    Read more from here

    Google’s Android will beat Apple’s iphone in total number of apps downloaded in next few months.

    Google Android

    Analysts are saying that Google play store will be the most popular platform for downloading mobile apps in the next few months.

    History of Google Play
    Google Play, formerly known as the Android Market, is a digital application distribution platform for Android and an online electronics store developed and maintained by Google. The service allows users to browse and download music, magazines, books, movies, television programs, and applications published through Google. Users can also purchase Chromebooks and Google Nexus–branded mobile devices through Google Play.
    Applications are available either for free or at a cost. They can be downloaded directly to an Android or Google TV device through the Play Store mobile app, or by deploying the application to a device from the Google Play website. These applications are generally targeted to users based on a particular hardware attribute of their device, such as a motion sensor (for motion-dependent games) or a front-facing camera (for online video calling).

    You can read more about Google Play Store from here

    Budget iPhone 5 Coming Soon

    iPhone 5

    The budget version of Apple’s latest iPhone will cost roughly $330 (£220), priced in order to appeal to young, middle class consumers in countries like China and India.
    The claims about the price and the imminent release were made on the Japanese website Macotakara, following on from earlier reports about Apple plans for a cheaper phone.
    In January it was reported that the planned new phone will resemble the iPhone 5 from the front but Apple will replace that handset’s aluminium body with a cheaper plastic casing.

    Read More from here
    http://www.telegraph.co.uk/technology/apple/9902864/Budget-iPhone-5-to-launch-soon.html

    iPhone Mini launch this summer

    iPhone Mini

    A low-priced iPhone makes a lot of sense, Morgan Stanley says, and it even could hit the market this summer.
    Katy Huberty, an analyst with the banking firm, noted that after her meetings with Apple Chief Financial Officer Peter Oppenheimer, she’s convinced that innovation remains a top priority for the Cupertino, Calif., electronics giant. She also believes that Apple will increase cash return to shareholders and expand carriers, distribution, and possibly price points to drive iPhone growth.
    She noted that a lower priced iPhone makes sense for several reasons:
    “iPad Mini is expanding Apple’s customer base with 50 [percent] of purchases in China/Brazil representing new customers to the ecosystem.”
    “Chinese consumers show a desire to purchase the latest version of iPhone (instead of discounted older generations).”
    “iPhone 4 demand surprised to the upside in the December quarter.”

    Read more from here

    http://news.cnet.com/8301-13579_3-57570715-37/iphone-mini-launch-this-summer-makes-sense-analyst-says/

    How to Change UIWebview’s background color in iPhone Xcode?

    Unlike other UIViews, the UIWebview’s opaque property is set to true by default. That should be set to false for changing the background color.

    [myWebView setOpaque:NO];
    
    myWebView.backgroundColor=[UIColor redColor];
    

    Samsung Year in Review: Galaxy Triumphs, Apple Losses

    Samsung produces a number of products – from kitchen appliances to PCs – but it was the company’s mobile division that made the most headlines in 2012.
    The Korea-based company dominated the mobile phone space, introducing several new Galaxy devices throughout the year. But it couldn’t shake one its biggest rivals, Apple, which proved to be a worthy opponent in the courtroom and in stores.
    Still, despite all the hysteria surrounding the launch of the iPhone 5 and iPad mini, it was Samsung and its Android-heavy lineup of devices like the Galaxy S III and Galaxy Note II that were the really mobile winners in 2012. Those two smartphones were only introduced in the second half of the year and they have already sold at least 30 million and 5 million worldwide, respectively.

    Read more from here..

    http://www.pcmag.com/article2/0,2817,2413529,00.asp

    Apple fined by China court for copyright violation

    A court in China has ordered Apple to pay compensation to eight Chinese writers and two companies for violating their copyrights.

    They had claimed that unlicensed electronic versions of their books had been sold on Apple’s online store.

    The court ordered Apple to pay them 1.03m yuan ($165,000; £100,000) in compensation, according to the official news agency Xinhua.
    … Read more from here.

    http://www.bbc.co.uk/news/business-20856199

    How to find your Google Plus ID

    This is so simple

    1. Go to your Google + account (https://plus.google.com/).

    2. Click on the Profile icon on the Left.

    3. If you look at the URL in the address bar, it should look something like this:

    https://plus.google.com/104653270154306099169/posts

    4. The long numerical string in the URL is your Google+ ID. Here is CoderzHeaven’s from the URL above:

    104653270154306099169/

    Google + CoderzHeaven

    Apple again the most valuable brand.

    Apple took the top spot for the second year in a row, beating out IBM, Google, and McDonald’s to assume the position of the world’s most valuable brand.

    At $183 billion, Apple is the world’s most valuable brand, according to Millward Brown Optimor’s annual BrandZ study. Apple was last year’s most valuable brand, as well, though the company’s value jumped 19 percent over last year’s $153.3 billion tally.

    Read more from here..

    http://news.cnet.com/8301-1001_3-57439046-92/apple-again-the-worlds-most-valuable-brand-google-third/

    Apple late in China – Samsung already has almost triple share.

    Apple Inc. (AAPL) got a partner to sell the iPhone in the world’s biggest mobile-phone market, China. The may be too late to catch Samsung with a market share that’s three times larger and growing.
    Samsung controlled 24.3 percent of the market for phones in China.
    “I don’t expect Apple to replace Samsung any time soon,” Gartner analyst Sandy Shen said in an interview. “China Telecom is the nation’s smallest carrier, so the extent to which they can help Apple is quite limited.”

    Read more about this story from here.
    http://www.bloomberg.com/news/2012-03-11/iphone-fails-to-gain-china-share-as-samsung-lead-triples-tech.html