• 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
returning char* from an obj-c method
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

returning char* from an obj-c method


  • Subject: returning char* from an obj-c method
  • From: crucial felix <email@hidden>
  • Date: Sun, 23 Feb 2003 19:39:28 -0500

hi,

I am using a framework that wraps a c library with obj-c methods.

-(char*)fulltypes
{
int i=0;
int size = [args count] + 2; // , \0
char types[size];
types[0] = ',';
for(i = 0; i < [args count]; i++) {
types[i + 1] = [[args objectAtIndex: i] type]; // each arg::type returns a char
}
types[size - 1] = '\0';
NSLog(@"built types: %s",types);
return types;
}

you can see the result logged here:
2003-02-23 19:20:06.646 Untitled[24544] built types: ,siiisfssiiisf

but here is the method being called from my unit test:

NSLog(@"fulltypes: %s",[msg fulltypes]);

2003-02-23 19:20:06.646 Untitled[24544] built types: ,siiisfssiiisf
2003-02-23 19:20:06.646 Untitled[24544] fulltypes : \\370\\u02c7\\317\\uf8ffisfs\\352\\307\\u02db\\331sf

the char* didn't survive being returned ?
the header for -(char*)fulltypes is correct. ( a common problem )

does anybody have any ideas why my string turned to gibberish ?
some kind of encoding mismatch, or total garbage ?

thank you, oh wise ones.

-felix
_______________________________________________
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.

  • Follow-Ups:
    • Re: returning char* from an obj-c method
      • From: Pete Yandell <email@hidden>
  • Prev by Date: Displaying multiple windows in one sheet
  • Next by Date: Re: returning char* from an obj-c method
  • Previous by thread: Re: Displaying multiple windows in one sheet
  • Next by thread: Re: returning char* from an obj-c method
  • Index(es):
    • Date
    • Thread