Ignore "Failed to call designated initializer on NSManagedObject class - objective-c

A core database keeps track of user info. The goal is to login using the core data, simple enough.
Simulating the app and logging in works perfectly.
Xcode does not show any errors or warnings.
Console output shows:
Failed to call designated initializer on NSManagedObject class 'Login'
Can I ignore this output ??
Login.h and Login.m are created by Xcode itself from the data model.
Login.h
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#class User;
#interface Login : NSManagedObject {
#private
}
#property (nonatomic, retain) NSString * password;
#property (nonatomic, retain) User *user;
+ (User *)loginWithEmail:(NSString *)email withPassword:(NSString *)password inManagedObjectContext:(NSManagedObjectContext *)context;
#end
Login.m
#import "Login.h"
#import "User.h"
#interface Login ()
- (User *)isValidEmail:(NSString *)email inManagedObjectContext:(NSManagedObjectContext *)context;
#end
#implementation Login
#dynamic password;
#dynamic user;
- (User *)isValidEmail:(NSString *)email inManagedObjectContext:(NSManagedObjectContext *)context
{
User *user = nil;
NSFetchRequest *request = [[NSFetchRequest alloc] init];
request.entity = [NSEntityDescription entityForName:#"User" inManagedObjectContext:context];
request.predicate = [NSPredicate predicateWithFormat:#"email = %#", email];
NSError *error = nil;
user = [[context executeFetchRequest:request error:&error] lastObject];
[request release];
return user;
}
+ (User *)loginWithEmail:(NSString *)email withPassword:(NSString *)password inManagedObjectContext:(NSManagedObjectContext *)context
{
Login *loginHelper = [[Login alloc] init];
User *user = nil;
if ((user = [loginHelper isValidEmail:email inManagedObjectContext:context])) {
if ([user.login.password isEqualToString:password]) {
// correct login
} else {
// invalid password
user = nil;
}
} else {
// user does not exist
user = nil;
}
[loginHelper release];
return user;
}
#end

My understanding is that you typically don't alloc/init NSManagedObjects or subclasses of NSManagedObjects explicitly- CoreData handles instantiating and deallocating managed objects as necessary - but you are attempting to alloc/init your own subclass in your loginWithEmail method. So that's probably why you're getting the error.
In the broader sense, this implementation seems to blur the lines between what should be a cut-and-dry data model (your NSManagedObject subclass), and the application logic of "logging in" - so I'd recommend reconsidering your architecture just a bit to more firmly reflect model-view-controller principles! Happy coding.

Related

Initialising CoreData in AppleScript-objc

I'm trying to write and read from CoreData on OSX, combinig cocoa classes with applescript-objc.
I wrote methods to handle my CoreData as in tutorial (youtube, Cocoa Tutorial: Core Data Introduction in iOS and Mac OS Programming Part 2) <- those are cocoa classes in my project
I have a class called CoreDataHelper that defines methods to manipulate Core Data. Here are some of them:
+(NSManagedObjectContext *) managedObjectContext{
NSError*error;
[[NSFileManager defaultManager] createDirectoryAtPath:[CoreDataHelper directoryForDatabaseFilename] withIntermediateDirectories:YES attributes:nil error:&error];
if(error){
NSLog(#"%#", [error localizedDescription]);
return nil;
}
NSString* path = [NSString stringWithFormat:#"%#/%#",[CoreDataHelper directoryForDatabaseFilename],[CoreDataHelper databaseFilename]];
NSURL *url = [NSURL fileURLWithPath:path];
NSManagedObjectModel* managedModel = [NSManagedObjectModel mergedModelFromBundles:nil];
NSPersistentStoreCoordinator* storeCordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:managedModel];
if(![storeCordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:url options:nil error:&error]){
NSLog(#"%#",[error localizedDescription]);
return nil;
}
NSManagedObjectContext* managedObjectContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];
return managedObjectContext;
}
+(id)insertManagedObjectOfClass:(Class) aClass inManagedObjectContext:(NSManagedObjectContext *)managedObjectContext{
NSManagedObject* managedObject = [NSEntityDescription insertNewObjectForEntityForName:NSStringFromClass(aClass) inManagedObjectContext:managedObjectContext];
return managedObject;
}
I'm using .xcdatamodeld for my Model.
I have 2 entities in it with classes for each one of them:
Tab
Service
Tab.h looks like this
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#class Service;
NS_ASSUME_NONNULL_BEGIN
#interface Tab : NSManagedObject
// Insert code here to declare functionality of your managed object subclass
#end
NS_ASSUME_NONNULL_END
#import "Tab+CoreDataProperties.h"
and Tab.m looks like this:
#import "Tab.h"
#import "Service.h"
#implementation Tab
// Insert code here to add functionality to your managed object subclass
#end
Tab+CoreDataProperties.h:
#import "Tab.h"
NS_ASSUME_NONNULL_BEGIN
#interface Tab (CoreDataProperties)
#property (nullable, nonatomic, retain) NSString *nZakladka;
#property (nullable, nonatomic, retain) NSString *uZakladka;
#property (nullable, nonatomic, retain) Service *podstronaSerwisu;
#end
NS_ASSUME_NONNULL_END
Tab+CoreDataProperties.m:
#import "Tab+CoreDataProperties.h"
#implementation Tab (CoreDataProperties)
#dynamic nZakladka;
#dynamic uZakladka;
#dynamic podstronaSerwisu;
#end
Now, my AppDelegate.applescript looks like this
...
property CoreDataHelper: class "CoreDataHelper"
property cService: class "Service"
property cTab: class "Tab"
script AppDelegate
on applicationWillFinishLaunching_(aNotification)
set theContext to CoreDataHelper's managedObjectContext()
set ccTab to cTab's alloc()'s init()
//the one below cause an error "CoreData: error: Failed to call designated initializer on NSManagedObject class 'Tab'"
set theTab to CoreDataHelper's insertManagedObjectOfClass_inManagedObjectContext_(ccTab, theContext)
end applicationWillFinishLaunching_
...
end Script
When I run whole thing I got an error message posted in a commented line in AppleScriptObjC code. The method that is causing an error is NSManagedObject* managedObject = [NSEntityDescription insertNewObjectForEntityForName:NSStringFromClass(aClass) inManagedObjectContext:managedObjectContext];
What is the problem?

Still confused by Objective C variable scope

I am trying to get some employee data from a JSON service. I am able to get the data and load it into an NSMutableArray, but I cannot access that array outside the scope of the method that gets the data.
TableViewController h filed
#import <UIKit/UIKit.h>
#import "employee.h"
#interface ViewController : UITableViewController
{
//NSString *test;
//NSMutableArray *employees;
}
#end
And here is my m file:
#define kBgQueue dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
#define scoularDirectoryURL [NSURL URLWithString: #"https://xxxx"]
#import "ViewController.h"
#interface ViewController()
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
dispatch_async(kBgQueue, ^{
NSData* data = [NSData dataWithContentsOfURL:
scoularDirectoryURL];
[self performSelectorOnMainThread:#selector(fetchedData:) withObject:data waitUntilDone:YES];
});
}
- (void)fetchedData:(NSData *)responseData {
NSError* error;
NSMutableArray *jsonArray = [NSJSONSerialization JSONObjectWithData: responseData options: NSJSONReadingMutableContainers error: &error];
id jsonObject = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
NSMutableArray *employees = [[NSMutableArray alloc ]init];
if (!jsonArray) {
} else {
for (jsonObject in jsonArray){
employee *thisEmployee = [employee new];
thisEmployee.fullName = [jsonObject objectForKey:#"$13"];
thisEmployee.state = [jsonObject objectForKey:#"state"];
thisEmployee.city = [jsonObject objectForKey:#"city"];
[employees addObject:thisEmployee];
}
}
}
Any help would be appreciated.
Bryan
You were on the right track. All you have to do is uncomment the NSMutableArray declaration in your #interface, and then change this line:
NSMutableArray *employees = [[NSMutableArray alloc] init];
to this
employees = [[NSMutableArray alloc] init];
Declaring the array in your interface will allow it to be accessed from anywhere within your implementation, or even from other classes and files if you declare it as a public property. When you make a declaration inside a function, that variables scope does not extend to outside of the function.
Just to elaborate a little on the scope of the variables, you have several ways of declaring them. The most used are:
Instance variables, which are declared in your interface and they can be accessed from any method inside the class or inside any method from it's subclasses. For example:
#interface MyObject : NSObject { //this can be any class
NSString *instanceVariable;
}
#implementation MyObject
-(void)someStrangeMethod {
instanceVariable = #"I'm used here";
NSLog(#"%#",instanceVariable);
}
//from subclasses
#interface MySubclassObject: MyObject {
//see that the variable is not declared here;
}
#implementation MySubclassObject
-(void)anotherStrangeMethod {
[super someStrangeMethod]; // this will print the value "I'm used here"
instanceVariable = #"I'm changing my value here"; //here we access the variable;
}
If you want the instance variable to be accessed only from the "owner" class you can declare it after the #private tag. You also have the #protected tag, though that isn't used so much.
If you want to have a variable that can be accessed outside the class, declare it as a property in your interface.
Also you can make the properties private using #private but this will contradict the purpose of the properties.

How to add CoreData to exisiting Tab Based IOS project

I have tried a lot of different answers, but I just can't seem to get this to work. I am trying to add Core Data to an existing Tab Based Project that I have. I added the core data framework through the targets, I set up the DataModel and entities correctly, but I can't seem to access it. I have gotten many different errors, but the most recent is:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot create an NSPersistentStoreCoordinator with a nil model'
I set up a new utility based project using the preset Core Data and copied the code as directly. I simply changed the File URL name to what current project is and it doesn't work. Here is my code:
appDelegate.h
#import <UIKit/UIKit.h>
#interface AppDelegate : UIResponder <UIApplicationDelegate>
{
BOOL isNotFirstTime;
NSMutableArray *teamMembers;
NSMutableArray *projects;
NSMutableArray *tasks;
}
#property(readwrite, retain) NSMutableArray *teamMembers;
#property(readwrite, retain) NSMutableArray *projects;
#property(nonatomic, retain) NSMutableArray *tasks;
#property(nonatomic)BOOL isNotFirstTime;
#property (strong, nonatomic) UIWindow *window;
#property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
#property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
#property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
- (void)saveContext;
- (NSURL *)applicationDocumentsDirectory;
- (NSURL *)applicationDocumentsDirectory;
- (void)saveContext;
#end
AppDelegate.m
For some reason when I create the File URL it remains null.....I have no idea why..
#import "AppDelegate.h"
#import "Task.h"
#import "Project.h"
#import "TeamMember.h"
#import "newTeamMemberWindow.h"
#implementation AppDelegate
#synthesize window = _window;
#synthesize tasks;
#synthesize teamMembers;
#synthesize projects;
#synthesize isNotFirstTime;
#synthesize managedObjectContext = __managedObjectContext;
#synthesize managedObjectModel = __managedObjectModel;
#synthesize persistentStoreCoordinator = __persistentStoreCoordinator;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSManagedObjectContext *context = [self managedObjectContext];
if (!context) {
NSLog(#"No Context on App Load");
}
newTeamMemberWindow *newTeamMemberWindowObject = [[newTeamMemberWindow alloc]init];
newTeamMemberWindowObject.managedObjectContext = context;
return YES;
}
//Removed all normal methods to consolidate code on stack overflow
#pragma mark - Core Data stack
/**
Returns the managed object context for the application.
If the context doesn't already exist, it is created and bound to the persistent store coordinator for the application.
*/
- (NSManagedObjectContext *)managedObjectContext
{
if (__managedObjectContext != nil)
{
return __managedObjectContext;
}
NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
if (coordinator != nil)
{
__managedObjectContext = [[NSManagedObjectContext alloc] init];
[__managedObjectContext setPersistentStoreCoordinator:coordinator];
}
return __managedObjectContext;
}
/**
Returns the managed object model for the application.
If the model doesn't already exist, it is created from the application's model.
*/
- (NSManagedObjectModel *)managedObjectModel
{
if (__managedObjectModel != nil)
{
return __managedObjectModel;
}
This part the modelURL remains Null.....
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:#"TimeLines" withExtension:#"momd"];
__managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
NSLog(#"Created managedObjectModel with Url: %#", modelURL);
return __managedObjectModel;
}
/**
Returns the persistent store coordinator for the application.
If the coordinator doesn't already exist, it is created and the application's store added to it.
*/
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if (__persistentStoreCoordinator != nil)
{
return __persistentStoreCoordinator;
}
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:#"TimeLines.sqlite"];
NSError *error = nil;
__persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error])
{
/*
Replace this implementation with code to handle the error appropriately.
abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
Typical reasons for an error here include:
* The persistent store is not accessible;
* The schema for the persistent store is incompatible with current managed object model.
Check the error message to determine what the actual problem was.
If the persistent store is not accessible, there is typically something wrong with the file path. Often, a file URL is pointing into the application's resources directory instead of a writeable directory.
If you encounter schema incompatibility errors during development, you can reduce their frequency by:
* Simply deleting the existing store:
[[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil]
* Performing automatic lightweight migration by passing the following dictionary as the options parameter:
[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
Lightweight migration will only work for a limited set of schema changes; consult "Core Data Model Versioning and Data Migration Programming Guide" for details.
*/
NSLog(#"Unresolved error %#, %#", error, [error userInfo]);
abort();
}
return __persistentStoreCoordinator;
}
#pragma mark - Application's Documents directory
/**
Returns the URL to the application's Documents directory.
*/
- (NSURL *)applicationDocumentsDirectory
{
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}
#end
If I understood you have a separate project utility for coredata, if yes take a look at this question of mine. It made me crazy time ago !!!
How to include a bundle in main project xcode 4.1

iOS persistent storage strategy

I'm developing an app which will save data to the local file system. The data that will be saved will be mostly NSString and NSDate. The data will not be saved that often, perhaps new data will be entered 10 times at a typical usage. The data should also of course be retrievable (CRUD)
How should I save this data? First of all is it necessary to model these objects? If not should I use property lists? Or SQLLite3?
Else should I archive the class models? Use SQLLite3?
EDIT: I accidentally left out some vital information about the app. Actually my app will be having 2 data models which have an aggregated relationship. So my first data model (lets call it DataA) which will have a NSString and NSDate will also have a reference to the second data model (lets call it DataB) which itself will consist of a NSString and a NSArray. So it gets a little more complicated now. If an object from DataB gets deleted it should of course cease to exist in DataA (but the rest of DataA should be left untouched)
This kind of data seems to be very simple to store and retrieve and does not have any other dependencies such as a horridly complex object graph.
You should store this data in a flat file or in NSUserDefaults.
I'll give you an example of both, using object archiving with the use of the NSCoding protocol:
#interface ApplicationData <NSCopying, NSCoding> {}
#property (nonatomic, strong) NSDate *someDate;
#property (nonatomic, strong) NSDate *someOtherDate;
#property (nonatomic, copy) NSString *someString;
#property (nonatomic, copy) NSString *someOtherString;
#end
#implementation ApplicationData
#synthesize someDate = _someDate, someOtherDate = _someOtherDate, someString = _someString, someOtherString = _someOtherString;
- (NSArray *)keys {
static dispatch_once_t once;
static NSArray *keys = nil;
dispatch_once(&once, ^{
keys = [NSArray arrayWithObjects:#"someString", #"someOtherString", #"someDate", #"someOtherDate", nil];
});
return keys;
}
- (id) copyWithZone:(NSZone *) zone {
ApplicationData *data = [[[self class] allocWithZone:zone] init];
if(data) {
data.someString = _someString;
data.someOtherString = _someOtherString;
data.someDate = _someDate;
data.someOtherDate = _someOtherDate;
//...
}
return data;
}
- (void) encodeWithCoder:(NSCoder *) coder {
[super encodeWithCoder:coder];
NSDictionary *pairs = [self dictionaryWithValuesForKeys:[self keys]];
for(NSString *key in keys) {
[coder encodeObject:[pairs objectForKey:key] forKey:key];
}
}
- (id) initWithCoder:(NSCoder *) decoder {
self = [super initWithCoder:decoder];
if(self) {
for(NSString *key in [self keys]) {
[self setValue:[decoder decodeObjectForKey:key] forKey:key];
}
}
return self;
}
#end
Then, say in your application delegate, you can do this:
#interface AppDelegate (Persistence)
#property (nonatomic, strong) ApplicationData *data;
- (void)saveApplicationDataToFlatFile;
- (void)loadApplicationDataFromFlatFile;
- (void)saveApplicationDataToUserDefaults;
- (void)loadApplicationDataFromUserDefaults;
#end
#implementation AppDelegate (Persistence)
#synthesize data;
- (NSString *)_dataFilePath {
static NSString *path = nil;
static dispatch_once_t once;
dispatch_once(&once, ^{
path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) stringByAppendingPathComponent:#"xAppData.dat"];
});
return path;
}
- (void)loadApplicationDataFromUserDefaults {
NSData *archivedData = [[NSUserDefaults standardUserDefaults] objectForKey:#"appData"];
self.data = [NSKeyedUnarchiver unarchiveObjectWithData:archivedData];
}
- (void)saveApplicationDataToUserDefaults {
NSData *archivedData = [NSKeyedArchiver archivedDataWithRootObject:self.data];
[[NSUserDefaults standardUserDefaults] setObject:archivedData forKey:#"appData"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (void)loadApplicationDataFromFlatFile {
NSData *archivedData = [NSData dataWithContentsOfFile:[self _dataFilePath]];
self.data = [NSKeyedUnarchiver unarchiveObjectWithData:archivedData];
}
- (void)saveApplicationDataToFlatFile {
NSData *archivedData = [NSKeyedArchiver archivedDataWithRootObject:self.data];
[archivedData writeToFile:[self _dataFilePath] atomically:YES];
}
#end
Disclaimer: I have not tested this code.
NSUserDefault is good choice if you have only a limited set of data.
But if you consider filtering and fetching, then you should have a look to Core Data to store objects.
Even if the object graph is minimal you will gain cached object management and free undo/redo management.
I would suggest that you go with NSUserDefaults. It's surely the best approach to store information pertaining to your app and any app related data. Check the documentation !!

Storing custom objects in NSUserDefaults

I am trying to save an object in NSUserDefaults but i have not been successful in it. Scenario is that, I have an object syncObject of class SyncObjct. I have implemented following methods in SyncObject class
- (NSMutableDictionary*)toDictionary;
+ (SyncObject*)getFromDictionary :(NSMutableDictionary*)dictionary;
- (id) initWithCoder: (NSCoder *)coder;
- (void) encodeWithCoder: (NSCoder *)coder;
And also the SyncObject class is NSCoding class. Now SyncObject class contains an NSMutableArray with name jobsArray. This array contains objects of class JobsObject. I implemented same above methods for this class as well to make it coding compliant. In toDictionary method of SyncObject class, i am storing this array in dictionary by writing following line.
[dictionary setValue:jobsArray forKey:#"jobsArray"];
and I am retrieving it in getFromDictionary method of SyncOject class by writing following line.
+ (SyncObject*)getFromDictionary :(NSMutableDictionary*)dictionary
{
NSLog(#"SyncObject:getFromDictionary");
SyncObject *syncObject = [[SyncObject alloc] init];
#try
{
syncObject.noOfJobs = [[dictionary valueForKey:#"noOfJobs"] intValue];
syncObject.totalJobsPerformed = (TotalJobsPerformed*)[dictionary valueForKey:#"totalobsPerformed"];
syncObject.jobsArray = [dictionary valueForKey:#"jobsArray"];
}
#catch (NSException * e)
{
NSLog(#"EXCEPTION %#: %#", [e name], [e reason]);
}
#finally
{
}
return syncObject;
}
And also I am storing syncObject in NSUserDefault by writing following lines.
NSData *myEncodedObject = [NSKeyedArchiver archivedDataWithRootObject:syncObject];
[userStorage setObject:myEncodedObject forKey:SYNC_OBJECT];
I am retrieving the object from NSUserDefaults by writing following lines
NSData *myEncodedObject = [userStorage objectForKey: SYNC_OBJECT];
syncObject = (SyncObject*)[NSKeyedUnarchiver unarchiveObjectWithData: myEncodedObject];
Problem is that i am not able to retrieve jobsArray correctly. Some invalid object is returned and app crashes when trying to access it. Please can anyone tell me the reason of this problem?
Best Regards
I believe the problem is that NSUserDefaults does not support storing of custom object types.
From Apple's documentation when using -setObject: The value parameter can be only property list objects: NSData, NSString, NSNumber, NSDate, NSArray, or NSDictionary. For NSArray and NSDictionary objects, their contents must be property list objects.
You can review the remaining documentation directly from Apple's NSUserDefault Class Reference manual.
Custom class .h
#import <Foundation/Foundation.h>
#interface Person : NSObject
#property(nonatomic, retain) NSArray *names;
#property(strong,nonatomic)NSString *name;
#end
custom class .m
#import "Person.h"
#implementation Person
#synthesize names;
- (void)encodeWithCoder:(NSCoder *)encoder {
[encoder encodeObject:self.name forKey:#"name"];
}
- (id)initWithCoder:(NSCoder *)decoder {
if((self = [super init])) {
//decode properties, other class vars
self.name = [decoder decodeObjectForKey:#"name"];
}
return self;
}
#end
To create Person class object and store and retrieve your stored data from NSUserDefaults
Stored your object :
#import "ViewController.h"
#import "Person.h"
#interface ViewController ()
#property (weak, nonatomic) IBOutlet UITextField *textBox;
#end
NSMutableArray *arr;
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)saveButton:(id)sender {
Person *person =[Person new];
person.name = _textBox.text;
arr = [[NSMutableArray alloc]init];
[arr addObject:person];
NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:arr];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:encodedObject forKey:#"name"];
[defaults synchronize];
}
- (IBAction)showButton:(id)sender {
_label.text = #"";
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSData *storedEncodedObject = [defaults objectForKey:#"name"];
NSArray *arrStoreObject = [NSKeyedUnarchiver unarchiveObjectWithData:storedEncodedObject];
for (int i=0; i<arrStoreObject.count; i++)
{
Person *storedObject = [arrStoreObject objectAtIndex:i];
_label.text = [NSString stringWithFormat:#"%# %#", _label.text , storedObject.name];
}
}
#end