Application crashing ( Maybe I'm over releasing object? )
Application crashing ( Maybe I'm over releasing object? )
- Subject: Application crashing ( Maybe I'm over releasing object? )
- From: "Nicolas Goles" <email@hidden>
- Date: Wed, 20 Aug 2008 00:40:54 -0400
Hey guys , I am writing an application to read/write tags to mp3 files...
the thing is working out pretty nice , ( my application is able to get a
directory input and scan the mp3 files and print the tags in the console ).
The problem is that after printing my tags the app crashes and I get an
error like :
objc[2765]: FREED(id): message release sent to freed object=0x15bf9720
>From what I have read, I may be over releasing an object, but I'm not pretty
sure at what could I've be doing wrong... here is the piece of code where my
app fails.
It looks quite long , but it's not really, most of the code is for creating
an open dialog window... the app crashes at the end of the last for showing
that message ( after writing the mp3 tags in the console )*.
*I have read about memory management in cocoa, and I don't really know
what's going on here :( , help would be really appreciated.
Thanks!
*
-(IBAction)scanAlbums:(id)sender*
{
int totalFiles; *// Loop counter.*
int j=0; *// Another loop counter*
*
// Create the File Open Dialog class.*
NSOpenPanel* openDlg = [NSOpenPanel openPanel];
*// Enable the selection of files in the dialog.*
[openDlg setCanChooseFiles:NO];
*// Enable the selection of directories in the dialog.*
[openDlg setCanChooseDirectories:YES];
*// Display the dialog. If the OK button was pressed,**
// process the files.*
if ( [openDlg runModalForDirectory:nil file:nil] == NSOKButton )
{
* //Takes the "last object ( only one )" from the files array*
NSString *files = [[openDlg filenames] lastObject];
NSFileManager *manager = [NSFileManager defaultManager];
*//Creates a File Manager *
NSDirectoryEnumerator *dirEnumerator = [manager
enumeratorAtPath:files]; *//Creates an enumerator*
id object; *// Creates a generic object*
while(object = [dirEnumerator nextObject])
{
*//First We craft the whole path for a single object*
NSString *fullPath = [files
stringByAppendingPathComponent:object];
if(!fullPath)
{
NSLog(@"Error when appending strings in appcontroller");
}
*//We check if the object is actually a dictionary or another
file.*
NSDictionary *fileAttributes = [manager
fileAttributesAtPath:fullPath traverseLink:NO];
*//if file is regular... for now it's like this, I'll improve
this later*
if( [[fileAttributes objectForKey:NSFileType] isEqualToString:@
"NSFileTypeRegular"])
{
Track *newTrack = [[Track alloc] init];
[albumsLibrary addTrackToLibrary:newTrack
withPath:fullPath];
}
}
}
totalFiles = [albumsLibrary count];
*//after this for loop is where the application crashes :)*
for(j = 0; j < totalFiles; j++)
{
[[albumsLibrary objectAtIndex:j] getTrackTags]; /*I get track tags*/
[[albumsLibrary objectAtIndex:j] printTagContents]; // I print tags
in the console
}
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden