objective c - how to put characters combination as constant command into iOS framework -
i new ios programming. developing sdk framework right now. have command 3 characters: 'esc' 'e' '1', wanna combine 3 characters generate nsstring , put nsstring framework. therefore others can directly use constant in framework.
any 1 knows how this? because in constant.h file, cannot use run-time functions such stringwithformat.
i think using \u combine 3 characters. doing way: nsstring *message2 = @"\\u001b\\u002d\\u0031"; failed. considered long string: \\u001b\\u002d\\u0031 rather esc+e+1
thanks lot.
\u
universal characters restricted iso 10646 exclude characters. of particular interest esc. can encode in octal:
nsstring *message2 = @"\033e1";
note typically not put these in header file. typically implement this way:
mymessages.h
// declare here extern nsstring * const mymessage2;
mymessages.m
// define here nsstring * const mymessage2 = @"...";
as possible, avoid generic files constant.h
. place constants in header closely matches. example, nsglobaldomain
string constant defined in nsuserdefaults.h
because it's used user defaults. there's no global "cocoastringconstants.h" file.
Comments
Post a Comment