Swift CMutablePointers in factories e.g. NewMusicSequence -


how use c level factory methods in swift?

let's try using factory such newmusicsequence().

var status:osstatus var sequence:musicsequence status=newmusicsequence(&sequence) 

this errors out "error: variable 'sequence' passed reference before being initialized". set sequence nil, , exc_bad_instruction.

you can try being explicit this:

var sp:cmutablepointer<musicsequence>=nil status=newmusicsequence(sp) 

but bad access exception when set sp nil. if don't set sp, "error: variable 'sp' used before being initialized"

i'd expect way it, it's not:

import audiotoolbox var sequence: musicsequence? var status:osstatus = newmusicsequence(&sequence) 

error: cannot convert expression's type 'osstatus' type 'inout musicsequence?' var status:osstatus = newmusicsequence(&sequence)

here's reference.

i think issue need optional value. optional values initialized nil , optional values can ever nil.

var sequence: musicsequence? let status = newmusicsequence(&sequence) 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -