Schmelter
Schmelter

Reputation: 43

Assertion Failed in Objective C

I'm getting the error "Assertion failed: (cls), function getName, file /SourceCache/objc4_Sim/objc4-427.1.1/runtime/objc-runtime-new.m, line 3939." whenever I run the following code.

NSLog(@"Hello: %@\n", [NSMutableString stringWithString:@"Whatever"]);

It also get about a thousand of the above error whenever I run this:

NSMutableString* urlCopy = [[NSMutableString alloc] initWithString:url];

and mouse over the urlCopy variable it in the debugger. Is it my version of XCode? What the hell is going on? I'm running 3.2.4 64-bit. I'm at a complete loss to explain this, and I can't seem to create any sort of String without this problem. I've written programs where this is the only line in the program, and it still creates this error. Please help!

Upvotes: 4

Views: 3694

Answers (2)

zoul
zoul

Reputation: 104065

The function in question:

/***********************************************************************
* getName
* fixme
* Locking: runtimeLock must be held by the caller
**********************************************************************/
static const char *
getName(struct class_t *cls)
{
    // fixme hack rwlock_assert_writing(&runtimeLock);
    assert(cls);

    if (isRealized(cls)) {
        return cls->data->ro->name;
    } else {
        return ((const struct class_ro_t *)cls->data)->name;
    }
}

…if somebody can make something out of it :)

Upvotes: 0

zpasternack
zpasternack

Reputation: 17898

I'm also using 3.2.4 64-bit, and your code (the NSLog call) works fine for me. If it's happening with every project, sounds like there must be something wrong with your environment. Have you tried reinstalling Xcode?

Upvotes: 2

Related Questions