Tricks to convert UIImage into byte :-
1st convert UIImage() to NSData() .
Then pass the NSData to the
getArrayOfBytesFromImage() and get the return as NSMutableArray
func getArrayOfBytesFromImage(imageData:NSData) -> NSMutableArray
{
let count = imageData.length / sizeof(UInt8)
var bytes = [UInt8](count: count, repeatedValue: 0)
imageData.getBytes(&bytes, length:count * sizeof(UInt8))
var byteArray:NSMutableArray = NSMutableArray()
for (var i = 0; i < count; i++) {
byteArray.addObject(NSNumber(unsignedChar: bytes[i]))
}
return byteArray
}
It is always recommended that .. we should save NSData of UIImage in local DB