Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-21-2011, 09:44 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2011
Posts: 1
Urbn is on a distinguished road
Unhappy Wont save file when textFieldDidEndEditing is called 2nd time

Hello guys,

I am currently developing for iPad, I am loading a path of the documents directory via a UITableView in a Popover. Via a textField, I want to change the files name. The first time, when i choose the file, the name is changed. But when I want to change the name afterwards again, nothing happens. I need to select the thing again, then enter the name again, and then it works again. :confused:

Code:
- (void)textFieldDidEndEditing:(UITextField *)tf
{
    textLabel.text = textField.text;
    NSString* newName = textLabel.text;
    newName = [newName stringByAppendingPathExtension:@"txt"];
    NSString* newPath = [[currentFilePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:newName]; 
    NSLog(@"%@",newPath);
    [[NSFileManager defaultManager] moveItemAtPath:currentFilePath toPath:newPath error:nil];
    [[NSNotificationCenter defaultCenter] postNotificationName:@"DataSaved" object:nil];

}
I figured out that I needed to set at the end of the method:

Code:
currentFilePath = newPath;
But that actually gave me a EXC_BAD_ACCESS, no Idea why.

I really don't have a clue whats going on there …

Thanks in advance!
Urbn is offline   Reply With Quote
Old 09-21-2011, 03:33 PM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

It's quite obvious why this gives you an EXC_BAD_ACCESS
Code:
currentFilePath = newPath;
You will need to do some research on how memory management works in iOS. I'd specifically do some digging on properties. Basically currentFilePath is not being retained, so the next time you try to use it, you're gonna get the crash.
smithdale87 is offline   Reply With Quote
Reply

Bookmarks

Tags
exc_bad_access, file management, iphone, textfielddidendediting

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 394
14 members and 380 guests
7twenty7, eski, EvilElf, HemiMG, iOS.Lover, jarv, n00b, pbart, Pudding, sacha1996, Sami Gh, UMAD, VinceYuan, yuncarl28
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,672
Threads: 94,121
Posts: 402,905
Top Poster: BrianSlick (7,990)
Welcome to our newest member, yuncarl28
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:14 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0