Skip to content

Using state as a variable name in PFObject subclass causes crash #155

@jlnbuiles

Description

@jlnbuiles

Summary of the bug:

Steps to reproduce the bug:

  1. Create a subclass
  2. Add a property named state
  3. Instantiate class via init() method
  4. Assign a value to state attribute
  5. Print instance

Here is an example:

the offending class
class Address: PFObject, PFSubclassing, MKAnnotation {
  @NSManaged var address1: String!
  @NSManaged var state: String!
...
}

then tried:

  let address = Address()
  address.address1 = "124 Broadway Ave"
  address.state = "ab"
  println(address)

This causes the crash.

I created a regular swift class to verify:

    class Boy {
    var name: String = ""
    var state: String = ""
    ... 
   }

then tried:

    let boy = Boy()
    boy.state = "abc"
    boy.name = "212"
    println(boy)

It does not crash if it isn't a PFObject subclass.

If i change the name of the state attribute to anything else, it works fine

SDK version: 1.8.0

This is the stack trace:

2015-09-01 17:12:42.579 Morsel[10829:1143015] -[Swift._NSContiguousString isComplete]: unrecognized selector sent to instance 0x7ffac9f63160
2015-09-01 17:12:42.600 Morsel[10829:1143015] �[31m*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Swift._NSContiguousString isComplete]: unrecognized selector sent to instance 0x7ffac9f63160'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000109340c65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x00000001099a7bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x00000001093480ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x000000010929e13c ___forwarding___ + 988
    4   CoreFoundation                      0x000000010929dcd8 _CF_forwarding_prep_0 + 120
    5   Morsel                              0x00000001062b6736 -[PFObject isDataAvailable] + 70
    6   Morsel                              0x00000001062a720a -[PFObject(Private) isDataAvailableForKey:] + 138
    7   Morsel                              0x00000001062b8e6f -[PFObject objectForKey:] + 111
    8   Morsel                              0x00000001062b9223 -[PFObject objectForKeyedSubscript:] + 67
    9   Morsel                              0x00000001062c9bd7 -[PFObjectSubclassingController _forwardGetterInvocation:forProperty:withObject:] + 1079
    10  Morsel                              0x00000001062c96b3 -[PFObjectSubclassingController forwardObjectInvocation:withObject:] + 307
    11  Morsel                              0x00000001062bb5ac -[PFObject forwardInvocation:] + 108
    12  CoreFoundation                      0x000000010929df4f ___forwarding___ + 495
    13  CoreFoundation                      0x000000010929dcd8 _CF_forwarding_prep_0 + 120
    14  Morsel                              0x0000000106198196 _TFC6Morsel11AddressCell14displayAddressfS0_FCS_7AddressT_ + 54
    15  Morsel                              0x0000000106188c64 _TFC6Morsel12LocationsTVC9tableViewfS0_FTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 1524
    16  Morsel                              0x0000000106188d9f _TToFC6Morsel12LocationsTVC9tableViewfS0_FTCSo11UITableView21cellForRowAtIndexPathCSo11NSIndexPath_CSo15UITableViewCell + 79
    17  UIKit                               0x0000000107c669e8 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 508
    18  UIKit                               0x0000000107c45208 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2853
    19  UIKit                               0x0000000107c5b869 -[UITableView layoutSubviews] + 210
    20  UIKit                               0x0000000107be59eb -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536
    21  QuartzCore                          0x000000010785aed2 -[CALayer layoutSublayers] + 146
    22  QuartzCore                          0x000000010784f6e6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
    23  QuartzCore                          0x000000010784f556 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    24  QuartzCore                          0x00000001077bb86e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
    25  QuartzCore                          0x00000001077bca22 _ZN2CA11Transaction6commitEv + 462
    26  QuartzCore                          0x00000001077bd0d3 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89
    27  CoreFoundation                      0x0000000109273ca7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    28  CoreFoundation                      0x0000000109273c00 __CFRunLoopDoObservers + 368
    29  CoreFoundation                      0x0000000109269a33 __CFRunLoopRun + 1123
    30  CoreFoundation                      0x0000000109269366 CFRunLoopRunSpecific + 470
    31  GraphicsServices                    0x000000010ae72a3e GSEventRunModal + 161
    32  UIKit                               0x0000000107b658c0 UIApplicationMain + 1282
    33  Morsel                              0x00000001061c1f77 main + 135
    34  libdyld.dylib                       0x000000010a0dd145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
�[0m

Metadata

Metadata

Assignees

No one assigned

    Labels

    state:duplicateDuplicate of already reported issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions