Tuesday, 15 May 2012

ios - Accessing utility methods from any class instance? -



ios - Accessing utility methods from any class instance? -

(this has been answered elsewhere don't know search on find it)

i have printerrormessage method below find useful. i've been including in classes kind of dumb in terms of duplicating code. can define class method in separate utility class?

this on ios, if matters.

- (void) printerrormessage: (nsstring *) errorstring withstatus: (osstatus) result { char str[20]; // see if appears 4-char-code *(uint32 *)(str + 1) = cfswapint32hosttobig(result); if (isprint(str[1]) && isprint(str[2]) && isprint(str[3]) && isprint(str[4])) { str[0] = str[5] = '\''; str[6] = '\0'; } else // no, format integer sprintf(str, "%d", (int)result); nslog (@"*** %@ error: %s\n", errorstring, str); }

can define class method in separate utility class?

of course of study can. class methods for. alternatively, inject existing class way of category.

ios objective-c

No comments:

Post a Comment