Re: Appending string to NSTextView crashing app
Re: Appending string to NSTextView crashing app
- Subject: Re: Appending string to NSTextView crashing app
- From: PGM <email@hidden>
- Date: Tue, 24 Apr 2007 23:52:50 -0400
On 24-Apr-07, at 23:24 PM, Evan Moseman wrote:
Thanks for the reply, I made the changes you suggested:
- (void)appendString:(NSString *)string toView:(NSTextView *)view
{
if (string == nil) { return; }
string = [string stringByAppendingString:@"\n"];
NSAttributedString *stringToAppend =
[[NSAttributedString alloc] initWithString:string];
[[view textStorage] appendAttributedString:stringToAppend];
[stringToAppend release];
}
Even shorter (typed in Mail):
- (void)appendString:(NSString *)string toView:(NSTextView *)view
{
if(string != nil){
[[[view textStorage] mutableString] appendFormat:@"%@\n", string];
}
}
Apparently, your error must come from somewhere else than this
method, can you post some code where you call this method?
Cheers, Patrick
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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