Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Where to place your typedef struct declaration file ?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Bracer" data-source="post: 922174" data-attributes="member: 125415"><p>I just started playing with typedef struct</p><p></p><p>MyClass.h</p><p>[code]</p><p>#import <Cocoa/Cocoa.h></p><p>@interface MyClass:NSObject</p><p>{</p><p> NSRange Range;</p><p>}</p><p>-(void) Generic_Message;</p><p>@end</p><p>[/code]</p><p></p><p>MyClass.m</p><p>[code]</p><p>#import "MyClass.h"</p><p>#import <stdio.h></p><p>#import <Foundation/Foundation.h></p><p></p><p>@implementation MyClass</p><p>-(void) Generic_Message</p><p>{</p><p> //Range = { 17 , 4 }; //For some reason, this doesn't work :(</p><p> Range=NSMakeRange (17,4) ;</p><p> NSLog (@"\nRange location: %d\nlength: %d", Range.location, Range.length );</p><p>}</p><p>@end</p><p>[/code]</p><p></p><p>Main.m</p><p>[code]</p><p>#import "MyClass.m"</p><p></p><p>int main(int argc, char * argv[])</p><p>{</p><p> id ClassInstance = [ [MyClass alloc] init];</p><p> [ClassInstance Generic_Message];</p><p> [ClassInstance release];</p><p> return 0;</p><p>}</p><p>[/code]</p><p></p><p>I have two questions, why doesn't </p><p>[code]Range = { 17 , 4 };[/code]</p><p>work ?</p><p></p><p>And secondly, how to I create my own typedef struct ?</p><p>For example I created this:</p><p>[code]</p><p>typedef struct _CustomType</p><p>{</p><p> int width;</p><p> int length;</p><p> int height;</p><p>}</p><p>CustomType;</p><p>[/code]</p><p>where do I put it ?</p></blockquote><p></p>
[QUOTE="Bracer, post: 922174, member: 125415"] I just started playing with typedef struct MyClass.h [code] #import <Cocoa/Cocoa.h> @interface MyClass:NSObject { NSRange Range; } -(void) Generic_Message; @end [/code] 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 [/code] Main.m [code] #import "MyClass.m" int main(int argc, char * argv[]) { id ClassInstance = [ [MyClass alloc] init]; [ClassInstance Generic_Message]; [ClassInstance release]; return 0; } [/code] I have two questions, why doesn't [code]Range = { 17 , 4 };[/code] work ? 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; [/code] where do I put it ? [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Where to place your typedef struct declaration file ?
Top