Unable to disassemble objc_assign_strongCast
Unable to disassemble objc_assign_strongCast
- Subject: Unable to disassemble objc_assign_strongCast
- From: Leonardo Borsten <email@hidden>
- Date: Mon, 2 Nov 2009 22:47:50 -0500
Hello all,
I'm getting a EXC_BAD_ACCESS error with the explanation "Unable to
disassemble objc_assign_strongCast" when I get to save the
NSManagedContext in one of my functions.
Using a breakpoint, I see that the debugger stops right after
0x904c6e76 <+1414> call 0x90573efe
<dyld_stub_objc_assign_strongCast>
These are the next two lines in the debugger:
0x904c6e7b <+1419> cmpb $0x0,-0xd1(ëp)
0x904c6e82 <+1426> je 0x904c6e99 <-[NSManagedObjectContext save:]
+1449>
I Googled for the obj_assign_strongCast term but what I read is way
over my head. I understand that it has something to do with Core
Foundation and CFRetaining/CFReleasing objects.
However, this particular function of mine doesn't explicitly use Core
Foundation methods. My app is not using Garbage Collection either.
The error didn't happen before I upgraded to SnowLeopard so I wonder
if something changed under the hood...
My question is: What can be causing this error?
I am pasting the function in question below this message as a reference.
Thanks in advance!
Leonardo Borsten
- (NSUInteger)initializeTypefaces
{
//return;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSLog(@"Starting intializeTypefaces");
NSFontManager *fm = [NSFontManager sharedFontManager];
availableFonts = [fm availableFonts];
NSEnumerator *fontEnumerator = [availableFonts objectEnumerator];
NSManagedObjectContext *importContext = [[NSManagedObjectContext
alloc] init];
NSPersistentStoreCoordinator *coordinator = [managedObjectContext
persistentStoreCoordinator];
[importContext setPersistentStoreCoordinator:coordinator];
[importContext setUndoManager:nil];
// Fetch an FCStyle as Undefined
NSEntityDescription *descr = [NSEntityDescription
entityForName:@"FCStyle" inManagedObjectContext:importContext];
NSFetchRequest *req = [[[NSFetchRequest alloc] init] autorelease];
[req setEntity:descr];
NSString *attributeName = @"name";
NSString *attributeValue = @"Undefined";
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K like
%@", attributeName, attributeValue];
[req setPredicate:predicate];
NSError *fetchError = nil;
NSArray *managedObjects = [importContext executeFetchRequest:req
error:&fetchError];
NSAssert([managedObjects count] > 0, @"Managed Object ZERO count");
if ([managedObjects count] == 0) return 0;
NSManagedObject *undefined = [managedObjects objectAtIndex:0];
NSUInteger count = 0, LOOP_LIMIT = 1000;
NSError **outError;
// Find-or-create
// make an array of font names from entity array
NSArray *registeredFonts = [self entitiesForEntity:@"Typeface"];
NSEnumerator *entityStepper = [registeredFonts objectEnumerator];
id regFontEntity;
NSMutableDictionary *knownTypefaces = [NSMutableDictionary
dictionaryWithCapacity:[self numberOfObjectsEntityForName:@"Typeface"]];
while (regFontEntity = [entityStepper nextObject]) {
[knownTypefaces setObject:regFontEntity forKey:[regFontEntity
valueForKey:@"fontName"]];
}
NSFont *namedFont;
NSString *aFontName;
while (aFontName = [fontEnumerator nextObject]) {
if ([knownTypefaces objectForKey:aFontName] == nil) {
// create a new managed object
NSManagedObject *newTypeface = [NSEntityDescription
insertNewObjectForEntityForName:@"Typeface"
inManagedObjectContext:importContext];
// get the font
@try {
namedFont = [NSFont fontWithName:aFontName size:0.0];
} @catch (NSException *exception) {
NSLog(@"initializeTypefaces caught %@: %@", [exception name],
[exception reason]);
} @finally {
exit;
}
if (namedFont != nil) {
// set values in new Typeface
[newTypeface setValue:[namedFont fontName] forKey:@"fontName"];
[newTypeface setValue:undefined forKey:@"style"];
NSLog(@"Added: %@", [newTypeface valueForKey:@"fontName"]);
count++;
if (count == LOOP_LIMIT) {
[importContext save:outError];
[importContext reset];
[pool drain];
pool = [[NSAutoreleasePool alloc] init];
count = 0;
}
}
}
}
NSError **saveError;
[importContext save:saveError]; // <--- crashes here
if ([importContext commitEditing]) {
NSLog(@"Editing initial typefaces committed");
[importContext release];
} else {
NSLog(@"Editing initial typefaces NOT committed");
}
[pool drain];
return [registeredFonts count];
}
_______________________________________________
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