Hello Guys, Girls,

Do you know why is the init?(length length: Int) NSMutableData's initializer 
failable?
The memory allocation can fail, but I think Swift doesn't handle that cases. 
(it is not a real issue in a modern OS)
The code on github calls a non failable initializer.
https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/NSData.swift#L904

public convenience init?(length: Int) {
        let memory = malloc(length)
        self.init(bytes: memory, length: length, copy: false) { buffer, amount 
in
                free(buffer)
        }
}

Thanks
s
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to