- Joined
- Oct 7, 2009
- Messages
- 14
- Reaction score
- 0
- Points
- 1
- Location
- Singapore
I just started playing with typedef struct
MyClass.h
MyClass.m
Main.m
I have two questions, why doesn't
work ?
And secondly, how to I create my own typedef struct ?
For example I created this:
where do I put it ?
MyClass.h
Code:
#import <Cocoa/Cocoa.h>
@interface MyClass:NSObject
{
NSRange Range;
}
-(void) Generic_Message;
@end
MyClass.m
Code:
#import "MyClass.h"
#import <stdio.h>
#import <Foundation/Foundation.h>
@implementation MyClass
-(void) Generic_Message
{
//Range = { 17 , 4 }; //For some reason, this doesn't work :(
Range=NSMakeRange (17,4) ;
NSLog (@"\nRange location: %d\nlength: %d", Range.location, Range.length );
}
@end
Main.m
Code:
#import "MyClass.m"
int main(int argc, char * argv[])
{
id ClassInstance = [ [MyClass alloc] init];
[ClassInstance Generic_Message];
[ClassInstance release];
return 0;
}
I have two questions, why doesn't
Code:
Range = { 17 , 4 };
And secondly, how to I create my own typedef struct ?
For example I created this:
Code:
typedef struct _CustomType
{
int width;
int length;
int height;
}
CustomType;