cocoa - NSTokenField set maximal number of Token -


let's say, have tokenfield, user can input message should sent to. don't want user can input more 3 token.

is there way achieve this?

implement nstokenfield delegate tokenfield:shouldaddobjects:atindex:

// return array of represented objects want add. // if want reject add, return empty array.  - (nsarray *)tokenfield:(nstokenfield *)tokenfield shouldaddobjects:(nsarray *)tokens atindex:(nsuinteger)index {     if (index>2) {         return [nsarray array];     }     nslog(@"%@-- %d %d", tokens, [tokens count],index);     return tokens; } 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -