• 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
description method question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

description method question


  • Subject: description method question
  • From: Dave <email@hidden>
  • Date: Mon, 15 Jun 2015 14:02:58 +0100

Hi,

I’ve added the description method to my class, (please see methods below), but when the String is logged, I get this:

   "LTWBufferIndex:  - Length: 1\n0: 1\n-----\n",
    "LTWBufferIndex:  - Length: 5\n0: 1\n1: 2\n2: 3\n3: 4\n4: 5\n-----\n”,

e.g. the newlines are not interpreted as such. Is there a trick to including a newline in the String returned my “description” ?

I am not sure if this makes a difference, but the description method is being called via a log of an NSArray, e.g.

LogIfDave(@"Before Sort: %@",myArray);
[myArray sortedArrayUsingSelector:@selector(compare:)];
LogIfDave(@"After Sort: %@",myArray);

Thanks in Advance for any help.
Dave

-(void) logIndexesWithMessage:(NSString*) theMessage andLogString:(NSMutableString*) theLogString
{
NSUInteger				myLength;
NSUInteger				myIndex;
NSUInteger				myBufferIndex;
NSUInteger*				myBufferPtr;

myLength = self.pIndexLength;
[theLogString appendFormat:@"%@ - Length: %ld\n",theMessage,myLength];

myBufferPtr = self.pIndexBaseBufferPtr;
for (myIndex = 0;myIndex < myLength;myIndex++)
	{
	myBufferIndex = *myBufferPtr;
	[theLogString appendFormat:@"%ld: %ld\n",myIndex,myBufferIndex];

	myBufferPtr++;
	}

[theLogString appendString:@"-----\n"];
}


-(NSString*) description
{
NSMutableString*		myLogString;

myLogString = [[NSMutableString alloc] initWithEmptyString];
[self logIndexesWithMessage:@"LTWBufferIndex: " andLogString:myLogString];
[myLogString autorelease];

return myLogString;
}


_______________________________________________

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: description method question
      • From: Dave <email@hidden>
  • Prev by Date: Buy music on iTunes
  • Next by Date: Re: Buy music on iTunes
  • Previous by thread: Re: Buy music on iTunes
  • Next by thread: Re: description method question
  • Index(es):
    • Date
    • Thread