• 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: Newbie Question about Converting From NSTextField to NSData
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie Question about Converting From NSTextField to NSData


  • Subject: Re: Newbie Question about Converting From NSTextField to NSData
  • From: Garrett Baker <email@hidden>
  • Date: Thu, 18 Jul 2002 10:07:38 -0500

This is what I do:
[theNSString dataUsingEncoding:[NSString defaultCStringEncoding] allowLossyConversion:YES];

hope this helps


On Thursday, July 18, 2002, at 09:42 AM, Tom Gray wrote:

As always, thanks in advance and sorry about such a bone headed newbie
question. I am reading an NSTextField and want to convert the string value
into an NSData type. I am doing this:

// Read the data from the text field.
theNSString = [[NSSTring alloc] initWithString:[myTextField stringValue]];

// Get the length of the string.
length = [theNSString length];

// Convert the NSString to a C String.
theCString = [theNSSTring cString];

// Convert the C string to an NSData.
theNSData = [[[NSData alloc] initWithBytes:theCString length:length]
autorelease];

I know their is a better way.

--

Tom Gray
email@hidden
or
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.



Garrett Baker
Internet Development Specialist
ACO Information Services LLC
voice tel: (251) 433-1088 ext. 233
fax tel: (251) 652-0012
email: email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Newbie Question about Converting From NSTextField to NSData (From: Tom Gray <email@hidden>)

  • Prev by Date: RE: Saving the visible state of the window
  • Next by Date: Re: Newbie Question about Converting From NSTextField to NSData
  • Previous by thread: Newbie Question about Converting From NSTextField to NSData
  • Next by thread: Re: Newbie Question about Converting From NSTextField to NSData
  • Index(es):
    • Date
    • Thread