Re: NSArray problem for a newbie
Re: NSArray problem for a newbie
- Subject: Re: NSArray problem for a newbie
- From: Dylan Adams <email@hidden>
- Date: Wed, 30 Jul 2003 12:15:35 -0500
Ufficio Tecnico Metagraphics wrote:
Hi to all,
I'm a complete newbie to Cocoa and Obj-C.
I'm trying to write in a NSTextView an array like follow:
#import "byip.h"
@implementation byip
- (IBAction)connect_ip:(id)sender
{
NSString * file = @"/Library/Apache2/logs/access_log";
NSString * path = [file stringByStandardizingPath];
NSString * source = [NSString stringWithContentsOfFile:path];
NSString * name = [path lastPathComponent];
//NSMutableArray * [[IpArray alloc]init];
NSMutableArray * ip = [[source
componentsSeparatedByString:@"\n"]retain];
int count = [ip count];
int i;
for (i = 0; i < count; i++)
{
[by_ip insertText:[NSString stringWithFormat:@"%i: \n",[ip
objectAtIndex:i]]];
Are you sure that by_ip isn't nil? How is by_ip getting its value? Is it
an outlet? Are you sure it's connected properly in IB?
Also, your ip is going to be full of NSStrings, not ints. You probably
want to do:
[by_ip insertText: [NSString stringWithFormat:@"%@: \n",
[ip objectAtIndex:i]]];
}
[logs_ip setObjectValue :[NSString stringWithFormat:name]];
It doesn't really make a big difference, but wouldn't this make more
sense as [NSString stringWithString: name]?
//[ip release];
With this line commented out, you're going to leak the NSMutableArray
pointed to by `ip.' That's probably not what you want.
}
@end
dylan
_______________________________________________
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.