• 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: NSData confusion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSData confusion


  • Subject: Re: NSData confusion
  • From: "Stephen J. Butler" <email@hidden>
  • Date: Fri, 20 Mar 2009 15:00:38 -0500

On Fri, Mar 20, 2009 at 2:28 PM, James Maxwell
<email@hidden> wrote:
> okay, but what about matrices?
>
> I've set them up using:
>
> float **theMatrix = [[self matrixData] mutableBytes];
>
> and this part seems okay - or at least, it compiles... But how do I then
> access the matrix.
> I've been using normal C-style array notation, thus far:
>
> theMatrix[i][j] = 0.6666;
>
> but this gives me an EXC_BAD_ACESS error when I run it.

Because this:

float theMatrix[ XSIZE ][ YSIZE ];

is not equivalent to this:

float **theMatrix = /* something */;

The latter says you have an array of float POINTERS. What you want is simple:

float *theMatrix = /* something */;

And then index it with:

theMatrix[ i*XSIZE + j ] = 0.666;
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSData confusion
      • From: James Maxwell <email@hidden>
References: 
 >NSData confusion (From: James Maxwell <email@hidden>)
 >Re: NSData confusion (From: Quincey Morris <email@hidden>)
 >Re: NSData confusion (From: James Maxwell <email@hidden>)

  • Prev by Date: Re: q's regarding appropriate use of core data?
  • Next by Date: Re: NSCell with URL
  • Previous by thread: Re: NSData confusion
  • Next by thread: Re: NSData confusion
  • Index(es):
    • Date
    • Thread