In a view I am showing images which I am fetching from coredata, The images I am showing using carousel classes. In the same view I have facebook button which will navigate me to another screen. When I am clicking the Facebook button then the action is not getting performed, after the images are loaded only the next screen is coming, the button action is not getting called as soon as I click on it.
In viewDidLoad I have called:
[self performSelectorInBackground:#selector(popularImages) withObject:nil];
The popularImages method:
- (void)popularImages
{
NSFetchRequest *request = [[NSFetchRequest alloc] initWithEntityName:#"Deals"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:#"ispopular == 1"];
[request setPredicate:predicate];
NSLog(#"popular Hypes called");
[self.managedObjectContext executeFetchRequest:request returnManagedObjectIDs:NO onSuccess:^(NSArray *deals) {
deals123 = [[NSMutableArray alloc] initWithArray:deals];
ij = 1;
for (Deals *deals in deals123) {
customizedMessage = [deals valueForKeyPath:#"txtmsgrec"];
dealIdString = [deals valueForKeyPath:#"dealsId"];
descriptionStr = [deals valueForKeyPath:#"dealdescription"];
captionStrArray = [deals valueForKeyPath:#"dealsassets.caption"];
[customizedMessageDict setObject:customizedMessage forKey:[NSString stringWithFormat:#"dealid%d",ij]];
[dealDict setObject:customizedMessageDict forKey:#"dealsmessage"];
[dealsIdDict setObject:dealIdString forKey:[NSString stringWithFormat:#"dealid%d",ij]];
[dealDict setObject:dealsIdDict forKey:#"dealsId"];
NSDictionary *dict = [NSDictionary dictionaryWithObject:captionStrArray forKey:#"caption"];
NSArray *captionTemparr = [[dict objectForKey:#"caption"] allObjects];
NSArray *assets = [deals valueForKeyPath:#"dealsassets.dealassetid"];
NSDictionary *dealassetidDict = [NSDictionary dictionaryWithObject:assets forKey:#"dealassetid"];
NSArray *dealassetidTemparr = [[dealassetidDict objectForKey:#"dealassetid"] allObjects];
[dealsUrlDict setObject:[[dealassetidDict objectForKey:#"dealassetid"] allObjects] forKey:[NSString stringWithFormat:#"dealid%d",ij]];
[dealDict setObject:dealsUrlDict forKey:#"delasURL"];
[dealsdescriptionDict setObject:descriptionStr forKey:[NSString stringWithFormat:#"dealid%d",ij]];
[dealDict setObject:dealsdescriptionDict forKey:#"dealsDescription"];
[dealscaptionDict setObject:captionTemparr forKey:[NSString stringWithFormat:#"dealid%d",ij]];
[dealDict setObject:dealscaptionDict forKey:#"dealscaption"];
ij++;
}
NSArray *array = [[dealDict valueForKey:#"delasURL"]allKeys];
NSLog(#"allKeys]class %#",[[[dealDict valueForKey:#"delasURL"]allKeys]class]);
NSDictionary *dealurlDict = [dealDict valueForKey:#"delasURL"];
NSDictionary *dealDescDict = [dealDict valueForKey:#"dealsDescription"];
NSDictionary *dealCaptionDict = [dealDict valueForKey:#"dealscaption"];
NSDictionary *dealIDDict = [dealDict valueForKey:#"dealsId"];
NSDictionary *dealMessageDict = [dealDict valueForKey:#"dealsmessage"];
for(int i=0;i<[array count];i++)
{
NSString *keyvalue = (NSString *)[array objectAtIndex:i];
NSString *dealId = [dealIDDict valueForKey:keyvalue];
NSArray *dealUrl = [dealurlDict valueForKey:keyvalue];
NSString *dealdesc = [dealDescDict valueForKey:keyvalue];
NSArray *dealcaption = [dealCaptionDict valueForKey:keyvalue];
NSString *dealMessage = [dealMessageDict valueForKey:keyvalue];
if([dealUrl count] == [dealcaption count])
{
//[dealUrl enumerateObjectsUsingBlock:^(id obj,NSUInteger idx,BOOL *stop)
for(int j = 0; j<[dealUrl count]; j++)
{
PopularHypesModal *dobject = [[PopularHypesModal alloc]init];
dobject.dealsID = dealId;
dobject.dealDescription = dealdesc;
dobject.dealcaption = [dealcaption objectAtIndex:j];
dobject.dealsUrl = [dealUrl objectAtIndex:j];
dobject.dealsMessage = dealMessage;
[self.items addObject:dobject];
[dobject release];
}
}
else
{
//[dealUrl enumerateObjectsUsingBlock:^(id obj,NSUInteger idx,BOOL *stop)
for(int j=0;j<[dealUrl count];j++)
{
PopularHypesModal *dobject=[[PopularHypesModal alloc]init];
dobject.dealsID = dealId;
dobject.dealDescription = dealdesc;
dobject.dealsMessage = dealMessage;
if([dealcaption count]>0)
{
dobject.dealcaption =[dealcaption objectAtIndex:0];
}
dobject.dealsUrl=[dealUrl objectAtIndex:j];
[self.items addObject:dobject];
[dobject release];
}
// ];
}
}
//];
carousel.dataSource = self;
carousel.delegate = self;
}onFailure:^(NSError *error) {
NSLog(#"Error fetching: %#", error);
popularHypes = YES;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Server Problem" message:#"Sorry, There is some Error with server,Please try after some time" delegate:nil cancelButtonTitle:#"Cancel" otherButtonTitles:#"Ok", nil];
[alert show];
[alert release];
ij++;
}];//1st
[dealDict retain];
}
The button I have added in xib, How can I overcome this?
Running on a background thread shouldn't give you any issues, unless you try to update a UI element from that same background thread. Be sure to forward any UI-related activities to the main thread. For example:
- (void)viewWillAppear:(BOOL)animated {
[self performSelectorInBackground:#selector(refreshTableView)];
[super viewWillAppear:animated];
}
- (void)refreshTableView {
// YourCode
[self.tableView performSelectorOnMainThread:#selector(reloadData) withObject:nil waitUntilDone:YES];
}
hope it's helpful :)
Please try this NSThread method
[NSThread detachNewThreadSelector:#selector(RunMethodEvenWhenMinimized) toTarget:self withObject:dict];
Related
The problem I'm having it that when I long touch the map it saves the data to Core Data and I can retrieve this data by NSLogs but I cannot figure out how to create multiple map markers from this data. Can anyone give me an example of a for loop for drawing these markers?
-(void) mapView:(GMSMapView *)mapView didLongPressAtCoordinate:(CLLocationCoordinate2D)coordinate{
location = coordinate;
[self alertview1];
}
- (void) alertview1 {
UIAlertView *av = [[UIAlertView alloc] initWithTitle:#"Save Map Location" message:#"Enter Title & Description" delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"OK", nil];
[av setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
[[av textFieldAtIndex:1] setSecureTextEntry:NO];
[[av textFieldAtIndex:0] setPlaceholder:#"Title"];
[[av textFieldAtIndex:1] setPlaceholder:#"Description"];
[av show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex != alertView.cancelButtonIndex) {
markerTitle = [alertView textFieldAtIndex:0].text;
markerSnippet = [alertView textFieldAtIndex:1].text;
NSLog(#"1 %#", [alertView textFieldAtIndex:0].text);
NSLog(#"2 %#", [alertView textFieldAtIndex:1].text);
[self saveMarker];
}
- (void) saveMarker{
NSManagedObjectContext *context = [self managedObjectContext];
NSManagedObject *newDevice = [NSEntityDescription insertNewObjectForEntityForName:#"Marker" inManagedObjectContext:context];
[newDevice setValue:[NSNumber numberWithDouble:location.latitude] forKey:#"latitude"];
[newDevice setValue:[NSNumber numberWithDouble:location.longitude] forKey:#"longitude"];
[newDevice setValue:markerTitle forKey:#"title"];
[newDevice setValue:markerSnippet forKey:#"snippet"];
NSError *error = nil;
if (![context save:&error]) {
NSLog(#"Can't Save! %# %#", error, [error localizedDescription]);
}
[self dismissViewControllerAnimated:YES completion:nil];
[self fetchMarkers];
}
- (void) fetchMarkers {
NSManagedObjectContext *managedObjectContext = [self managedObjectContext];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:#"Marker"];
self.markers = [[managedObjectContext executeFetchRequest:fetchRequest error:nil] mutableCopy];
NSArray *title = [self.markers valueForKey:#"Title"];
NSArray *snippet = [self.markers valueForKey:#"Snippet"];
NSArray *latitude = [self.markers valueForKey:#"Latitude"];
NSArray *longitude = [self.markers valueForKey:#"Longitude"];
NSLog (#"%#", title);
NSLog (#"%#", snippet);
NSLog (#"%#", latitude);
NSLog (#"%#", longitude);
double lat = [latitude doubleValue];
double lng = [longitude doubleValue];
for (GMSMarker *marker in title) {
GMSMarker *mkr = [[GMSMarker alloc] init];
[mkr setPosition:CLLocationCoordinate2DMake(lat,lng)];
[mkr setAnimated:YES];
[mkr setTitle:title];
[mkr setSnippet:snippet];
[mkr setMap:self.mapView1];
}
}
After banging my head against the wall for hours and taking a few shots it finally came to me and was very simple. I stuck the data from core data in separate arrays and indexes the markers then indexed the arrays in a variable. Anyway here is the code. If anyone else has a better way of doing this please let me know. I am still learning Objective C and only started a couple months ago so there probably is a better solution but this at least works.
-(void) mapView:(GMSMapView *)mapView didLongPressAtCoordinate:(CLLocationCoordinate2D)coordinate{
location = coordinate;
[self alertview1];
}
- (void) alertview1 {
UIAlertView *av = [[UIAlertView alloc] initWithTitle:#"Save Map Location" message:#"Enter Title & Description" delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"OK", nil];
[av setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
// Alert style customization
[[av textFieldAtIndex:1] setSecureTextEntry:NO];
[[av textFieldAtIndex:0] setPlaceholder:#"Title"];
[[av textFieldAtIndex:1] setPlaceholder:#"Description"];
[av show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex != alertView.cancelButtonIndex) {
markerTitle = [alertView textFieldAtIndex:0].text;
markerSnippet = [alertView textFieldAtIndex:1].text;
NSLog(#"1 %#", [alertView textFieldAtIndex:0].text);
NSLog(#"2 %#", [alertView textFieldAtIndex:1].text);
[self saveMarker];
} else {
// this is where you would handle any actions for "Cancel"
}
}
- (void) saveMarker{
NSManagedObjectContext *context = [self managedObjectContext];
// Create a new managed object
NSManagedObject *newDevice = [NSEntityDescription insertNewObjectForEntityForName:#"Marker" inManagedObjectContext:context];
[newDevice setValue:[NSNumber numberWithDouble:location.latitude] forKey:#"latitude"];
[newDevice setValue:[NSNumber numberWithDouble:location.longitude] forKey:#"longitude"];
[newDevice setValue:markerTitle forKey:#"title"];
[newDevice setValue:markerSnippet forKey:#"snippet"];
NSError *error = nil;
// Save the object to persistent store
if (![context save:&error]) {
NSLog(#"Can't Save! %# %#", error, [error localizedDescription]);
}
[self dismissViewControllerAnimated:YES completion:nil];
[self fetchMarkers];
}
- (void) fetchMarkers {
// Fetch the devices from persistent data store
NSManagedObjectContext *managedObjectContext = [self managedObjectContext];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:#"Marker"];
self.markers = [[managedObjectContext executeFetchRequest:fetchRequest error:nil] mutableCopy];
NSMutableArray *title = [self.markers valueForKey:#"Title"];
NSMutableArray *snippet = [self.markers valueForKey:#"Snippet"];
NSMutableArray *latitude = [self.markers valueForKey:#"Latitude"];
NSMutableArray *longitude = [self.markers valueForKey:#"Longitude"];
for (int i = 0; i < [title count]; i++){
GMSMarker *mkr = [[GMSMarker alloc] init];
double lat = [[latitude objectAtIndex:i] doubleValue];
double lng = [[longitude objectAtIndex:i] doubleValue];
NSString *T = [title objectAtIndex:i];
NSString *S = [snippet objectAtIndex:i];
[mkr setPosition:CLLocationCoordinate2DMake(lat, lng)];
[mkr setAnimated:YES];
[mkr setTitle:T];
[mkr setSnippet:S];
[mkr setMap:self.mapView1];
}
I saved the persistent ID of the songs selected with media picker, now I'm trying to crate the queue to play that list but something is wrong in this code:
myPlayer = [MPMusicPlayerController applicationMusicPlayer];
NSMutableArray *canzonilist = [[[NSMutableArray alloc] initWithCapacity:1] retain];
NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:#"listaCanzoni"];
NSArray *decodedData = [NSKeyedUnarchiver unarchiveObjectWithData:data];
[canzonilist addObjectsFromArray:decodedData];
MPMediaQuery *songQuery = [MPMediaQuery songsQuery];
for (int i = 0; i > [canzonilist count]; i++) {
[songQuery addFilterPredicate:[MPMediaPropertyPredicate predicateWithValue:[canzonilist objectAtIndex:i] forProperty:MPMediaItemPropertyPersistentID]];
}
NSArray *songs = [songQuery items];
MPMediaItemCollection *currentQueue = [[MPMediaItemCollection alloc] initWithItems:songs];
if (currentQueue != nil) {
[myPlayer setQueueWithItemCollection:currentQueue];
} else {
[myPlayer setQueueWithQuery: [MPMediaQuery songsQuery]];
}
[myPlayer play];
[canzonilist release];
[currentQueue release];
Thanks
Finally I found the solution:
SAVE:
- (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) mediaItemCollection {
[self savePlaylist:mediaItemCollection];
[self dismissModalViewControllerAnimated: YES];
}
- (void)savePlaylist:(MPMediaItemCollection *) mediaItemCollection {
NSArray* items = [mediaItemCollection items];
NSMutableArray* listToSave = [[NSMutableArray alloc] initWithCapacity:0];
for (MPMediaItem *song in items) {
NSNumber *persistentId = [song valueForProperty:MPMediaItemPropertyPersistentID];
[listToSave addObject:persistentId];
}
NSData *data = [NSKeyedArchiver archivedDataWithRootObject: listToSave];
[[NSUserDefaults standardUserDefaults] setObject:data forKey:#"songsList"];
[[NSUserDefaults standardUserDefaults] synchronize];
[listToSave release];
}
LOAD
- (void)setupMusic {
myPlayer = [MPMusicPlayerController applicationMusicPlayer];
if ([[NSUserDefaults standardUserDefaults] objectForKey:#"songsList"] != nil) {
NSMutableArray *theList = [[NSMutableArray alloc] initWithCapacity:0];
NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:#"songsList"];
NSArray *decodedData = [NSKeyedUnarchiver unarchiveObjectWithData:data];
[theList addObjectsFromArray:decodedData];
NSMutableArray *allTheSongs = [[NSMutableArray alloc] initWithCapacity:0];
for (int i = 0; i < [theList count]; i++) {
MPMediaQuery *songQuery = [MPMediaQuery songsQuery];
[songQuery addFilterPredicate:[MPMediaPropertyPredicate predicateWithValue:[theList objectAtIndex:i] forProperty:MPMediaItemPropertyPersistentID]];
NSArray *songs = [songQuery items];
[allTheSongs addObjectsFromArray: songs];
}
MPMediaItemCollection *currentQueue = [[MPMediaItemCollection alloc] initWithItems:allTheSongs];
[myPlayer setQueueWithItemCollection:currentQueue];
[theList release];
[currentQueue release];
[allTheSongs release];
} else {
[myPlayer setQueueWithQuery: [MPMediaQuery songsQuery]];
[myPlayer setShuffleMode: MPMusicShuffleModeSongs]; //optional
}
}
i am working on a fishing app these days and i am getting a memory leak problem
-(void)requestFinished:(ASIFormDataRequest *) request {
if(hud != nil){
[hud show:NO];
[hud release];
hud = nil;
}
isLoading = NO;
self.responseText = [request responseString];
[self parseXml]; //I am getting leak here
if ( [self.responseText hasPrefix:#"<result>"]) {
UIAlertView *info = [[[UIAlertView alloc] initWithTitle:#" " message:#"Limited Internet access, please find a stronger signal in the area" delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil]autorelease];
[info show];
}
if (!isRefreshButtonClicked) {
[UIAccelerometer sharedAccelerometer].delegate = self;
[NSThread detachNewThreadSelector:#selector(parseXml) toTarget:self withObject:nil];
} }
This is my function...
-(void) parseXml
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
_fishes = [[fishes parseXml:self.responseText] retain];
[self performSelectorOnMainThread:#selector(parseXmlDone) withObject:nil waitUntilDone:YES];
[pool release];
Here _fishes is an array which is getting a value from a array return type function.....and here is that function...
+(NSMutableArray *)parseXml:(NSString *)xmlString {
//xmlString = [xmlString stringByReplacingOccurrencesOfString:#"&" withString:#""];
const char *cString = [xmlString UTF8String];
NSMutableArray *fishes = [NSMutableArray array];
NSData *xmlData = [NSData dataWithBytes:cString length:strlen(cString)];
NSError *error;
GDataXMLDocument *doc = [[GDataXMLDocument alloc]initWithData:xmlData options:0 error:&error];
if (doc == nil) { return nil; }
//parseXml
NSArray *_fishes = [doc.rootElement elementsForName:#"fishery"];
for (GDataXMLElement *_fish in _fishes) {
NSMutableDictionary *fish = [NSMutableDictionary dictionary];
NSArray *ids = [_fish elementsForName:#"id"];
if ([ids count]>0) {
GDataXMLElement *firstId = (GDataXMLElement *)[ids objectAtIndex:0];
[fish setValue:firstId.stringValue forKey:#"id"];
} else continue;
NSArray *names = [_fish elementsForName:#"name"];
if ([names count]>0) {
GDataXMLElement *firstName = (GDataXMLElement *)[names objectAtIndex:0];
[fish setValue:firstName.stringValue forKey:#"name"];...........
........
else continue;
NSArray *distances = [_fish elementsForName:#"distance"];
if ([distances count]>0) {
GDataXMLElement *distance = (GDataXMLElement *)[distances objectAtIndex:0];
[fish setValue:distance.stringValue forKey:#"distance"];
}else continue;
[fishes addObject:fish];
}
[doc release];
return fishes;
}
#end
I hope u guys will understand my problem...thanx
In -parseXml,
_fishes = [[fishes parseXml:self.responseText] retain];
will leak any previous object _fishes was pointing to in case -parseXml is sent more than once. You could use a retain property instead of an instance variable, or a setter method that releases the previous object, or release the previous object before assigning a new (retained) object to _fishes.
I'm trying to insert a search bar in a tableview, that is loaded with information from a NSDictionary of Arrays. Each Array holds and object. Each object has several properties, such as Name or Address.
I've implemented the methods of NSSearchBar, but the code corresponding to the search it self, that i have working on another project where the Arrays have strings only, is not working, and I can't get to thr problem.
Here's the code:
'indiceLateral' is a Array with the alphabet;
'partners' is a NSDictionary;
'RLPartnersClass' is my class of Partners, each one with the properties (name, address, ...).
-(void)handleSearchForTerm:(NSString *)searchTerm {
NSMutableArray *sectionsToRemove = [[NSMutableArray alloc] init];
[self resetSearch];
for (NSString *key in self.indiceLateral) {
NSMutableArray *array = [partners valueForKey:key];
NSMutableArray *toRemove = [[NSMutableArray alloc] init];
for (NSString *name in array) {
if ([name rangeOfString:searchTerm options:NSCaseInsensitiveSearch].location == NSNotFound)
[toRemove addObject:name];
}
if ([array count] == [toRemove count])
[sectionsToRemove addObject:key];
[array removeObjectsInArray:toRemove];
[toRemove release];
}
[self.indiceLateral removeObjectsInArray:sectionsToRemove];
[sectionsToRemove release];
[theTable reloadData];
}
Can anyone help me please?
Thanks,
Rui Lopes
I've done it.
Example:
-(void)handleSearchForTerm:(NSString *)searchTerm {
NSMutableDictionary *finalDict = [NSMutableDictionary new];
NSString *currentLetter = [[NSString alloc] init];
for (int i=0; i<[indiceLateral count]; i++) {
NSMutableArray *elementsToDict = [[[NSMutableArray alloc] init] autorelease];
currentLetter = [indiceLateral objectAtIndex:i];
NSArray *partnersForKey = [[NSArray alloc] initWithArray:[partnersCopy objectForKey:[indiceLateral objectAtIndex:i]]];
for (int j=0; j<[partnersForKey count]; j++) {
RLNames *partnerInKey = [partnersForKey objectAtIndex:j];
NSRange titleResultsRange = [partnerInKey.clientName rangeOfString:searchTerm options:NSDiacriticInsensitiveSearch | NSCaseInsensitiveSearch];
if (titleResultsRange.length > 0){
NSLog(#"found: %#", partnerInKey.clienteCity
[elementsToDict addObject:partnerInKey];
}
}
[finalDict setValue:elementsToDict forKey:currentLetter];
}
NSMutableDictionary *finalResultDict = [finalDict mutableDeepCopy];
self.partners = finalResultDict;
[finalResultDict release];
[theTable reloadData];
}
i have leaks in this code. The performane tool leaks tell me that this is in this line:
NSArray *fakeData = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:#"FakeData" ofType:#"plist"]];
I can't find out what is going on. The plist that i am loading have 3 NSDictionary Elements, so same as leaks in screenshot. Each Dictionary has 3 strings.
The entire code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Ładowanie danych
if (![[FlickrFetcher sharedInstance] databaseExists]) {
NSArray *fakeData = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:#"FakeData" ofType:#"plist"]];
for (NSDictionary *element in fakeData) {
//Wypełnianie CoreData danymi
Photo *newPhoto = (Photo *)[NSEntityDescription insertNewObjectForEntityForName:#"Photo"
inManagedObjectContext:[[FlickrFetcher sharedInstance] managedObjectContext]];
NSLog(#"Creating Photo: %#", [element objectForKey:#"name"]);
[newPhoto setName:[element objectForKey:#"name"]];
[newPhoto setImageURL:[element objectForKey:#"path"]];
NSLog(#"Person is: %#", [element objectForKey:#"user"]);ŕŕŕ
NSPredicate *predicate = [NSPredicate predicateWithFormat:#"name == %#", [element objectForKey:#"user"]];
NSMutableArray *peopleArray = (NSMutableArray *)[[FlickrFetcher sharedInstance] fetchManagedObjectsForEntity:#"Person"
withPredicate:predicate];
NSEnumerator *enumerator = [peopleArray objectEnumerator];
Person *person;
BOOL exists = FALSE;
while (person = [enumerator nextObject]) {
NSLog(#"Person is: %#", person.name);
if ([person.name isEqualToString:[element objectForKey:#"user"]]) {
exists = TRUE;
NSLog(#"-- Person exists: %#", person.name);
[newPhoto setOwner:person];
}
}
if (!exists) {
Person *newPerson = (Person *)[NSEntityDescription insertNewObjectForEntityForName:#"Person"
inManagedObjectContext:[[FlickrFetcher sharedInstance] managedObjectContext]];
[newPerson setName:[element objectForKey:#"user"]];
NSLog(#"Person created: %#", newPerson.name);
[newPhoto setOwner:newPerson];
}
NSError *error;
if (![[[FlickrFetcher sharedInstance] managedObjectContext] save:&error]) {
NSLog(#"Unresolved error %# %#", error, [error userInfo]);
exit(-1);
}
[fakeData release];
}
}
//Person Navigation Controller
personNavigationController = [[UINavigationController alloc] init];
PersonListViewController *personListViewController = [[PersonListViewController alloc] initWithStyle:UITableViewStylePlain];
personListViewController.title = #"Contacts";
[personNavigationController pushViewController:personListViewController animated:NO];
[personListViewController release];
//Recent Photo Navigation Controller
recentPhotoNavigationController = [[UINavigationController alloc] init];
RecentPhotoViewController *recentPhotoViewController = [[RecentPhotoViewController alloc] init];
recentPhotoViewController.title = #"Recent";
UITabBarItem *item = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemRecents tag:1];
recentPhotoViewController.tabBarItem = item;
[item release];
[recentPhotoNavigationController pushViewController:recentPhotoViewController animated:NO];
[recentPhotoViewController release];
//Tab Bar Controller
tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = [NSArray arrayWithObjects:
personNavigationController,
recentPhotoNavigationController,
nil];
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
return YES;
}
It looks like your fakeData array is being released inside of the for loop, which seems problematic on several levels. You probably meant to release it when the loop has exited. From Leaks' perspective, the for loop might never be entered, in which case the object would be leaked.