• 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
NSMutableData: Adding One char to a NSMutableData Object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSMutableData: Adding One char to a NSMutableData Object


  • Subject: NSMutableData: Adding One char to a NSMutableData Object
  • From: Jordan Evans <email@hidden>
  • Date: Sat, 14 Jan 2006 09:12:02 -0800 (PST)

How do I add one character at a time to a
NSMutableData object?

This code is supposed to be adding an 'a' to a
NSMutableData object, then incrementing it to 'b' and
then adding it, etc., on through the alphabet.  Of
course this snippet doesn't work, and that's why I'm
asking how this is done.  Can anyone help me with
NSData abc's?

        int i;
	unsigned char str[2];
	unsigned char *aBuffer;
        char a = 'a';

	aBuffer = str;

	for( i=0; i<26; i++ )
	{
		str[0] = a++;
		str[1] = '\0';

		[myData appendBytes:aBuffer length:1];
		[myFile writeData:myData];
	}




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
 _______________________________________________
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

  • Follow-Ups:
    • Re: NSMutableData: Adding One char to a NSMutableData Object
      • From: Shawn Erickson <email@hidden>
  • Prev by Date: Re: Cocoa Custom NSCell Binding Issue
  • Next by Date: Re: NSMutableData: Adding One char to a NSMutableData Object
  • Previous by thread: Re: Cocoa-dev Digest, Vol 3, Issue 58
  • Next by thread: Re: NSMutableData: Adding One char to a NSMutableData Object
  • Index(es):
    • Date
    • Thread