I am making a website in Dashcode. I know objective c very well but barely know javascript at all. Here is an example objective-c class:
/* Here is an example .h file, "CircularList.h".
All behavior is inherited from List, which defines a List of objects.
Nowadays we can use NSArray which is more complex than List.
*/
#include <objc/List.h> /* Superclass interface */
@interface CircularList: List /* List is superclass */
{
int currentLocation;
}
- (NSString *) next; /* Returns next object in List or nil if none. */
@end
/* Here is the corresponding .m file: */
#include "CircularList.h"
@implementation CircularList
- (NSString *) next
{
int numObjects = [self count];
if (currentLocation >= numObjects)
currentLocation = 0;
return [self objectAt:currentLocation++];
}
@end
How do I connect this class with a safari web application project in DashCode? How do I call next? How can I convert NSString to var and then print the var to the log?
Additional Details
I have looked at the dev library. How do I import the objective c class into a dashcode project?
Here is the class:
/* Here is an example .h file, "CircularList.h".
All behavior is inherited from List, which defines a List of objects.
Nowadays we can use NSArray which is more complex than List.
*/
#include <objc/List.h> /* Superclass interface */
@interface CircularList: List /* List is superclass */
{
int currentLocation;
}
- (NSString *) next; /* Returns next object in List or nil if none. */
@end
/* Here is the corresponding .m file: */
#include "CircularList.h"
@implementation CircularList
- (NSString *) next
{
int numObjects = [self count];
if (currentLocation >= numObjects)
currentLocation = 0;
return [self objectAt:currentLocation++];
}
+ (NSString *) webScriptNameForSelector:(SEL)sel
{
if (sel == @selector(nameAtIndex:))
name = [self next];
return name;
}
+ (BOOL)isSelectorExcludedFromWebScript:(S…
{
if (sel == @selector(nameAtIndex:)) return NO;
return YES;
}
@end
How do I connect the objective c with the javascript file or dashcode project? Where does the objective c class go (eg same folder as js)? What is the javascript to call my function 'next'? What does the following code do?: + (BOOL)isSelectorExcludedFromWebScript:(S… { if (sel == @selector(nameAtIndex:)) return NO; return YES; }