Trying to create a (Swift 3) generics based function that allows for any NSManagedObject to use.
function (from NSManagedObject+MagicalAggregation.h)
open class func mraggregateOperation( function: String, onAttribute attributeName: String, with predicate: NSPredicate?) -> Any?
...
here is my function:
func execAggregateOperation(domain :T, operation :String, attribute :String) -> Any?
{
let operationResult = T.mr_aggregateOperation(operation, onAttribute: attribute, with: nil)
print(operationResult)
let value = operationResult as! Int
print(value)
return value
}
It compile, builds and runs, but at the end of the invocation, at the return statement, I get this:
EXC_BAD_ACCESS (code=1 ...)
From what I understand, bad access is from a variable going out of scope and being garbage collected. I turned on zombies and still get this, without any additional information per the reason.
Hi,
Trying to create a (Swift 3) generics based function that allows for any NSManagedObject to use.
function (from NSManagedObject+MagicalAggregation.h)
open class func mraggregateOperation( function: String, onAttribute attributeName: String, with predicate: NSPredicate?) -> Any?
...
here is my function:
func execAggregateOperation(domain :T, operation :String, attribute :String) -> Any?
{
let operationResult = T.mr_aggregateOperation(operation, onAttribute: attribute, with: nil)
print(operationResult)
let value = operationResult as! Int
print(value)
return value
}
It compile, builds and runs, but at the end of the invocation, at the return statement, I get this:
EXC_BAD_ACCESS (code=1 ...)
From what I understand, bad access is from a variable going out of scope and being garbage collected. I turned on zombies and still get this, without any additional information per the reason.
Thanks.