Coding for the mac in an NSView is incredibly similar to the iPhone, though I have one problem.
How do I connect my CustomView to my NSView? Never really used Interface Builder and it appears quite strange.
-Gan
// .h
@property (readwrite, copy) NSString *name;
// .m
@synthesize name;
// .h
- (void)setName:(NSString *)aName;
- (NSString *)name;
// .m
- (void)setName:(NSString *)aName
{
if (name != aName) {
[name release];
name = [aName copy];
}
}
- (NSString *)name
{
return [[name retain] autorelease];
}
Should I go for 10.4 and do all that work? Would it be worth it?
I'm looking into Cocoa Async Socket for networking. I'm going to try to make a mac server and mac+iPhone client. This will be for a game so it'd need fast packet sending...
Is Cocoa Async Socket a good choice? Do you guys know anything better?
case NSStreamEventHasSpaceAvailable:
event = @"NSStreamEventHasSpaceAvailable";
if (theStream == oStream)
{
//send data
//uint8_t buffer[11] = "I send this";
//int len;
NSString *welcomeMsg = @"Yo Yo Yo";
NSData *welcomeData = [welcomeMsg dataUsingEncoding:NSASCIIStringEncoding];
len = [oStream write:[welcomeData bytes] maxLength:sizeof([welcomeData bytes])];
if (sizeof([welcomeData bytes]) > 0)
{
NSLog(@"Command send");
[oStream close];
}
}
break;
Code:len = [oStream write:[welcomeData bytes] maxLength:sizeof([welcomeData bytes])];
if (sizeof([welcomeData bytes]) > 0)
if (true)
This appears to be the correct code, yet it still doesn't work. How can I check to make sure the packet is actually getting to the server?case NSStreamEventHasSpaceAvailable:
event = @"NSStreamEventHasSpaceAvailable";
if (theStream == oStream)
{
//send data
uint8_t buffer[11] = "I send this";
int len;
len = [oStream write:buffer maxLength:sizeof(buffer)];
if (len > 0)
{
NSLog(@"Command send");
[oStream close];
}
}
break;