• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: objective-c newbie type question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: objective-c newbie type question


  • Subject: Re: objective-c newbie type question
  • From: Lucas Eckels <email@hidden>
  • Date: Sat, 16 Apr 2005 10:21:07 -0400

On 4/16/05, Aaron Boothello <email@hidden> wrote:
> Hey guys,
>
> Thanks for your help on my previous querry.
> Alright, so im porting some c++ code.
> I'm sure this is a syntax issue:
> there's a header file(with an associated '.m' file called 'utilities.h' and 'utilities.m'
>
> utilities.h contains typedef declerations and some #define macros.
> Along with some basic function, such as matrix multiplications,etc....
> ----------------------------------------------------
> #ifndef _UTIL_H_
> #define _UTIL_H_
>
> #import <Cocoa/Cocoa.h>
> #import <Foundation/Foundation.h>
>
> typedef double matrix[16];
> .
> .
> -(void)multilyMatrices:(matrix*)m:(matrix*)n;
> .
> .
> #endif
> ------------------------------------------------------
> utilities.m:
> #import "utilities.h"
> -(void)multilyMatrices:(matrix*)m:(matrix*)n
> {
> .
> .
> }
> -----------------------------------------------------
> error returned:fatal error:method definition not in class context
>

Hi Aaron,

On the surface, this is a syntax issue.  In C++, methods within
classes use the same syntax as plain C functions.  In Obj-C, there is
a different syntax (as well as a lot of differences under the hood).
Class methods are fundamentally different things than plain functions.

The error you received tells you what you did wrong -- you tried to
make a plain function with the Obj-C syntax.  You can either use plain
C functions (like void multiplyMatrices(matrix m, matrix n) ), or make
an Obj-C class which encapsulates a matrix.  If you've done
programming with Cocoa, you probably already know how to do this.

Remember -- developing with Objective-C means using the same kinds of
object-oriented principles you should be using when developing with
C++ (or any other OO language).

Lucas Eckels
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >objective-c newbie type question (From: Aaron Boothello <email@hidden>)

  • Prev by Date: objective-c newbie type question
  • Next by Date: NSOpenPanel stops showing inserted/ejected disks
  • Previous by thread: objective-c newbie type question
  • Next by thread: Re: objective-c newbie type question
  • Index(es):
    • Date
    • Thread