im trying to open a url with object c my code is as follows
#include <stdio.h>
int main()
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.ithinksw.com/"]];
return 0;
}
but when i try to compile it i get these errors
hello.c: In function 'main':
hello.c:4: error: expected expression before '[' token
hello.c:4: error: 'NSWorkspace' undeclared (first use in this function)
hello.c:4: error: (Each undeclared identifier is reported only once
hello.c:4: error: for each function it appears in.)
hello.c:4: error: expected ']' before 'openURL'
hello.c:4: error: stray '@' in program
im extremal new to this so any help would be great 🙂
Seems you targetering to iphone, so you have to use [[UIApplication sharedApplication] openURL] instead of NSWorkspace.
And don’t forget to add Foundation framework to include and link section.