This should be pretty simple. I have a data source that always gives me UInt16s. I derive different data sets from this raw data and plot the results. Some of the derived data sets are Floats, some are UInt8s, and some are UInt16s.
I queue the derived data where it is later retrieved by my graphing classes.
Queues are arrays of arrays and look like this: [[UInt16]], [[Float]], or [[UInt8]].
I'm trying to make use of generics, but I get a compiler error when I try to append a generic-typed array to an array that is declared to be [[AnyObject]].
As I'm learning Swift, I keep bumping into this AnyObject / generic problem quite a bit. Any help/insight is appreciated.
class Base: NSObject {
var queue : [[AnyObject]] = Array()
func addtoQueue<T>(dataSet: [T]) {
queue.append(dataSet)
}
func removeFromQueue() -> [AnyObject]? {
return queue.removeAtIndex(0)
}
}
class DataSet1 : Base {
func getSomeData(rawData: [UInt16]) {
var result : [Float] = processRawData(rawData)
addToQueue(result)
}
}