Tag Archives: iPhone App Developer for Hire

A stepwise guideline on developing core data applications for beginners

17 Oct

Image 1Ever since iOS came into existence, developers have been keenly awaiting the core data applications that can enable them to design the perfect data model for their applications. These data applications have served as the best E/R tools and have been effectively used for storage in both OSX and iOS empowered Apple products. Through this blog, I’ll be sharing a refined collection of steps that would allow you to develop core data applications for beginners in the field of iOS app development. So, let’s get going!

A closer look at the Basic Architecture

Image 3Even iPhone Application Development Company in India manage the core data which is being organized into NSManagedObjects that correspond to tables used in the SQLite database. These objects are further broken down into entities that can be associated with a table included within the database. Entities can further include Attributes along with a “Select” operation that can be performed using the NSFetchedManagedObject with the help of Predicates.

The list of code samples that I would be including in this guideline are:

Image 2

And now, the steps involved with the process of developing the core data applications:

  • NSFetchedManagedObject
  • NSManagedObjectContext

  • NSManagedObjectModel

  • NSManagedObject

Step 1- Create a new project

Here, I’ll be using the Utility application template with the Core data enabled. Start off by naming the project.

Step 2- Now, create the Core Data Schema

After having created the project, you’ll find an auto-generated file with the extension as “xcdatamodeld”. This is the core data schema file where you’ll be defining the attributes, entities, relationships and predicates. Start with selecting the Entity node and clicking on the “Add Entity” button. Here, I’ll create two entities viz: Continent and Country. After this, click on the “Add Attribute” button for a specific entity and add an attribute name of string data type. Lastly, add the relationship for each entity. For example, the entity ‘Continent’ can have a relationship name as ‘continents’ with the destination as the ‘Country’ entity.

Step 3- Create the Input screen

As per the third step, open the storyboard file and add two labels, two text fields and a button. Now, with the storyboard file open, opt for clicking on the Assistant Editor for opening the related header file. Next, create IBOutlets for each of the two text fields using the left mouse button. Finally, click on the “Connect” button to add the code, followed by creating the connection. Repeat the process for the second text field as well. Also, for the single button, repeat the process but just change the connection type to “IBAction”.

Step 4- Add the input logic

Now, add the below mentioned code to the SaveData method:

– (IBAction)saveData:(id)sender {
NSManagedObjectContext *cxt = [self managedObjectContext];
NSManagedObject *newContinent = [NSEntityDescription insertNewObjectForEntityForName:@”Continent” inManagedObjectContext:cxt];
[newContinent setValue:self.continentNameFld.text forKey:@”name”];
_continentNameFld.text = @””;

NSManagedObject *newCountry = [NSEntityDescription insertNewObjectForEntityForName:@”Country” inManagedObjectContext:cxt];
[newCountry setValue:self.countryNameFld.text forKey:@”name”];
_countryNameFld.text = @””;

NSError *err;
if (![cxt save:&err]) {
NSLog(@”An error has occured: %@”, [err localizedDescription]);
}

}

Step 5- Test the application

In order to test the developed app you may opt to Hire iPhone App Developer or simply click on the run button and launch the iOS5 simulator. Try testing the app functionality by entering a continent and country in the appropriate fields, followed by clicking on the ‘Save’ button. Keep a check over the log to see if any errors crop up. If no errors are detected, it shows that the app is functioning accurately.

Final Words

Novice web developers find working with core data applications very simple. I’m sure the details covered above would assist you in building a brilliant core data app for building outstanding web solutions.

NOW READ: iPhone Jailbreaking – Why you shouldn’t go for it?

5 Step process to passing data from UITableView to Detail View Controller

19 Sep

Image 1The incredible performance of iOS devices has encouraged developers to get engaged in iOS programming avenues. As someone who’s new to the field of iOS programming, there might be situations wherein you may want to pass the data from UITableView to Detail View Controller. In this article, I’ll walk you through the steps that are involved with the process of passing data from UITableView to Detail View Controller.

Here, I’ll be using a NSMutableArray that will be loaded with data fetched from Wikipedia. If you find it convenient to use SQLite data for populating the array or Core Data, you may opt for the same. And now, the steps involved in passing data from UITableView to Detail View Controller:

Step 1- Create the SampleData and Project NSObject Subclass

For such iPhone Application Development Services, simply create a Single View Application project and once you’re done with it, add a new NSObject subclass called SampleData. Next, in the header file, add three instance variables to represent the data as explained below:

#import <Foundation/Foundation.h>

@interface SampleData : NSObject

@property(nonatomic,strong) NSString * treeName;

@property(nonatomic,strong) NSString * treeDescription;

@property(nonatomic,strong) UIImage * treePicture;

@end

After this, synthesize the aforementioned three variables.

Step 2- Add the SampleDataDAO Subclass

Image 2

For this, create the SampleDataDA class and load the data in the data source. In the header file, define a NSMutableArray for the data source as shown below:

#import <Foundation/Foundation.h>

#import "SampleData.h"

@interface SampleDataDAO : NSObject

@property(nonatomic, strong) NSMutableArray * someDataArray;

-(NSMutableArray *)PopulateDataSource;

@end

Step 3- Build UITableViewController

For this, all you need to do is simply open the storyboard and add a new UITableViewController from the Object Library. With the UITableViewController selected, right click on the Cell Prototype and drag the connection to the DetailViewController. Further, with the Cell Prototype selected, open the Attributes inspector and name the Call in the identifier field. Once you’re done with the creation of segue, select it and open the Attributes inspector, followed by entering the “treeCell” identifier field.

Step 4- Configure the cellForRowAtIndexPath method

Image 3This is done for adding the data source to the cells. Here, you’ll need to change the value of the CellIdentifier to the name that has been defined in the storyboard’s Cell Prototype. Here’s the listing for the complete implementation of the cellForRowAtIndexPath method:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    static NSString *CellIdentifier = @"treeCell";

    

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

    }

    

   

    SampleData * sample = [self.ds objectAtIndex:indexPath.row];

    cell.textLabel.text = sample.treeName;

    NSLog(@"Cell Value %d %@",indexPath.row,  cell.textLabel.text);

      

    return cell;

}

Step 5- Develop the kIViewController Class

You can either avail iPhone App Developer for Hire or start this by simply opening the storyboard and adding a UITextField and an UIImageView to the view controller that has already been created with the initial project. After this, create IBOutlets for both; UITextField and UIImageView by control dragging connections to the header file and naming them as treeInfo and treePicture respectively. Next, define a SampleData instance variable called treeData which will contain the SampleData information that needs to be selected in the kIListViewController. See the listing below:

#import <UIKit/UIKit.h>

#import "SampleData.h"

@class SampleData;

@interface klViewController : UIViewController

@property (strong, nonatomic) IBOutlet UITextView *treeInfo;

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

@property (nonatomic, strong) SampleData * treeData;

@end

ALSO READ: Security Alerts- A brand new offering for iCloud Users

Conclusion

So, those were the five simple-to-follow steps that enable an iOS developer to pass data from UITableView to DetailViewController. Hope you’d have found the steps interesting and worthy enough to implement in the best possible manner.