EXC_BAD_ACCESS Crash with stubs from a swift class

51 views
Skip to first unread message

JM

unread,
Oct 23, 2015, 11:04:03 AM10/23/15
to Cedar Discussion
Hi All, I'm having some issues with stubbing a swift class in Objective C..

Most of my code is in objective C, but I introduced a swift class and want to stub a property on an instance. 

For example I have a UITableViewController, for it's numberOfRows, it users "vendors.count", where vendors is a swift class. In my stack trace, I'll see vendors.count be valid up until I get into the swift class and get a BAD_ACCESS

Is this expected given the current state of Cedar/Swift?

Andrew Kitchen

unread,
Oct 23, 2015, 11:12:47 AM10/23/15
to cedar-...@googlegroups.com, Cedar Discussion
I'm not so sure this is expected... 

Could you please provide enough sample code to show the setup of the test subject and the model in question?



--
You received this message because you are subscribed to the Google Groups "Cedar Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cedar-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

JM

unread,
Oct 23, 2015, 12:05:46 PM10/23/15
to Cedar Discussion
I tried to setup a new project and cannot reproduce the way I expected I'd be able to

here is the numberOfRows method
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        guard let searchResult
: VendorSearchResult = self.searchResult where searchResult.vendors.count > 0 else {
           
return 0
       
}
       
return searchResult.vendors.count + Int(self.canFetchMore)
   
}

It crashes when trying to access the searchResult.vendors.count, searchResult has a stubbed selector, which isn't even related to vendors.count..  but as long as it's stubbed I get this error.

JM

unread,
Oct 23, 2015, 12:08:47 PM10/23/15
to Cedar Discussion
Actually - Simply spying on it makes it crash.. If I don't spy - it's fine.

dah...@umich.edu

unread,
May 15, 2017, 12:05:42 PM5/15/17
to Cedar Discussion
Also seeing this. If I've spied on a Swift class, it'll throw an EXC_BAD_ACCESS on simple setters like this:

self.property = value

Andrew Kitchen

unread,
May 22, 2017, 11:11:15 PM5/22/17
to cedar-...@googlegroups.com
Hello - is the class you're spying on a descendent of NSObject?

--
You received this message because you are subscribed to the Google Groups "Cedar Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cedar-discuss+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages