Thread 1 = EXC_BAD_ACCESS (code=2, address = 0x7ffee9199ff8) - Reserved Property Names? #244

Open
opened 2025-12-29 18:24:51 +01:00 by adam · 2 comments
Owner

Originally created by @ogugo on GitHub (Dec 12, 2018).

Hey John,

Loving your project. I just wanted to check if I'm right assuming that there's a conflict using property keys that match with NSManagedObject instance properties. I've isolated the crashing code, which set off an infinite loop calling [NSManagedObject description], [NSManagedObject _descriptionValues], and then _PF_Handler_Public_GetProperty.

private func makeExerciseDetailPage() -> BLTNItem {

    guard let _ = self.selectedRowIndexPath else {
        
        os_log("Attempted to create new bulletin without a selected row.", log: Logger.presentation, type: .default)
        
        fatalError("Attempted to create new bulletin without a selected row.")
    }
    
    let exercise = exercises[self.selectedRowIndexPath!]
    
    let name = exercise.name.value
    
    os_log("Creating bulletin item for %@.", log: Logger.presentation, type: .debug, name)
    
    let page = BLTNPageItem(title: name)
    
    page.image = exercise.getImage()
    
    **page.descriptionText = exercise.description.value** // ERROR HERE
    
    page.actionButtonTitle = "Favorite"
    
    page.alternativeButtonTitle = "Hide"
    
    page.isDismissable = true
    
    page.appearance = makeExerciseDetailAppearance()
    
    page.actionHandler = { (item: BLTNActionItem) in
        
        CoreStore.perform(asynchronous: {(transaction) in
            
            let proxy = transaction.edit(exercise)
            
            proxy?.isFavorite .= true
            
        }, completion: {(result) in
            
            if result.boolValue {
                
                os_log("Successfully added %@ to favorite exercises.", log: Logger.customization, type: .info, name)
            }
            else {
                
                os_log("Could not add %@ to favorite exercises.", log: Logger.customization, type: .default, name)
            }
        })
        
        item.manager?.dismissBulletin(animated: true)
        
        os_log("Dismissing bulletin for %@/", log: Logger.presentation, type: .debug, name)
    }
    
    page.alternativeHandler = { (item: BLTNActionItem) in
        
        item.manager?.dismissBulletin(animated: true)
        
        os_log("Dismissing bulletin for %@/", log: Logger.presentation, type: .debug, name)
    }
    
    return page
}
Originally created by @ogugo on GitHub (Dec 12, 2018). Hey John, Loving your project. I just wanted to check if I'm right assuming that there's a conflict using property keys that match with NSManagedObject instance properties. I've isolated the crashing code, which set off an infinite loop calling [NSManagedObject description], [NSManagedObject _descriptionValues], and then _PF_Handler_Public_GetProperty. private func makeExerciseDetailPage() -> BLTNItem { guard let _ = self.selectedRowIndexPath else { os_log("Attempted to create new bulletin without a selected row.", log: Logger.presentation, type: .default) fatalError("Attempted to create new bulletin without a selected row.") } let exercise = exercises[self.selectedRowIndexPath!] let name = exercise.name.value os_log("Creating bulletin item for %@.", log: Logger.presentation, type: .debug, name) let page = BLTNPageItem(title: name) page.image = exercise.getImage() **page.descriptionText = exercise.description.value** // ERROR HERE page.actionButtonTitle = "Favorite" page.alternativeButtonTitle = "Hide" page.isDismissable = true page.appearance = makeExerciseDetailAppearance() page.actionHandler = { (item: BLTNActionItem) in CoreStore.perform(asynchronous: {(transaction) in let proxy = transaction.edit(exercise) proxy?.isFavorite .= true }, completion: {(result) in if result.boolValue { os_log("Successfully added %@ to favorite exercises.", log: Logger.customization, type: .info, name) } else { os_log("Could not add %@ to favorite exercises.", log: Logger.customization, type: .default, name) } }) item.manager?.dismissBulletin(animated: true) os_log("Dismissing bulletin for %@/", log: Logger.presentation, type: .debug, name) } page.alternativeHandler = { (item: BLTNActionItem) in item.manager?.dismissBulletin(animated: true) os_log("Dismissing bulletin for %@/", log: Logger.presentation, type: .debug, name) } return page }
Author
Owner

@JohnEstropia commented on GitHub (Dec 12, 2018):

Oof, it's a no-no in Core Data to use any common NSObject property names, especially description.

You will want to rename this to property. Thanks for reporting this though, I'll write an assert that would catch these during DataStack initialization.

@JohnEstropia commented on GitHub (Dec 12, 2018): Oof, it's a no-no in Core Data to use any common NSObject property names, especially `description`. You will want to rename this to property. Thanks for reporting this though, I'll write an `assert` that would catch these during `DataStack` initialization.
Author
Owner

@ogugo commented on GitHub (Dec 12, 2018):

Ahhh, that explains it. Thanks!

@ogugo commented on GitHub (Dec 12, 2018): Ahhh, that explains it. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore-JohnEstropia#244