objective c - Calling instance method from class method: Possible or no? -
in previous post explained converting old 'c' program objective-c, , learned difference between messaging (old version) static methods , class methods.
however, how can class method call instance method (assuming it's possible)? here's original (static) function:
static int newsplitb(int b, int hi, int lo, int found) { int hlp; if(hi - lo <= 1) return 0; bis(lo + (hi - lo + 1) / 2); // calls function bis(); return 1; }
and exact same code 'translated' obj-c:
+(int)newsplitb :(int)b :(int)hi :(int)lo :(int)found { int hlp; if((hi - lo) <= 1) return 0; [tablesclass bis:(lo+(hi-lo+1)/2)]; // gives compile error return 1; }
the 'bis()' function -- snipped brevity -- sitting in separate source file in 'tables' class. unfortunately, attempting build program gives me 'tablesclass' undeclared (first use in function) error, though class has been alloc/inited earlier in same implementation file.
i've searched net hours solution, no avail. if i'm trying isn't possible, how can modify last method i'm after? in advance :-)
make sure importing tablesclass.h
file otherwise current class won't know of existence , common issue when dealing error.
Comments
Post a Comment