Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Cocoa Pointer Warning Msg Question

Cocoa Pointer Warning Msg Question
Thread Tools
Fresh-Faced Recruit
Join Date: Jun 2002
Status: Offline
Reply With Quote
Jun 20, 2002, 06:34 PM
 
- (void)awakeFromNib
{
NSURL * userURL;
//NSMutableArray * aArray;

userURL = [NSURL URLWithString:@"http://www.yahoo.com"];
[[myTable dataSource] setDataArray:[self parseURL:userURL]];
[[myTable dataSource] init];


// aArray = [self parseURL:userURL];
// [[myTable dataSource] initWithDataArray:aArray];
}

I get a 'warning: passing arg 1 of 'setDataArray:' from incompatible pointer type on.
[[myTable dataSource] setDataArray:[self parseURL:userURL]];

App then compiles, runs and then quits with a Signal 4. heh. <img border="0" alt="[Skeptical]" title="" src="graemlins/bugeye.gif" /> Any ideas? Here's declarations of header files:
- (NSArray *)parseURLNSURL *)thePage;
- (id)initWithDataArrayNSMutableArray *)theArray;
- (void)setDataArrayNSMutableArray *)anArray;
Thx
     
Fresh-Faced Recruit
Join Date: Jan 2000
Location: Los Altos, CA, USA
Status: Offline
Reply With Quote
Jun 20, 2002, 08:33 PM
 
A few things I'd be leary of...

i) your parseURL routine is returning an NSArray, not an NSMutableArray- you probably need to convert
ii) when setting the array, do you retain it? (and release it later)
iii) init methods should be for initializing a member of a class (I'm not sure if you created this init method returning an (id) or just happened to call your method as such)
iv) your data source ought to be already instantiated from Interface Builder so you won't need to 'init' or 'initWithDataArray'
v) you should have a connected IBOutlet for the instantiated dataSource class member - instead of using [myTable dataSource], in my example it is tableDataSource which has your setDataArray and the other necessary NSTableView methods
- (int) numberOfRowsInTableView: (NSTableView *)tableView
- (id) tableView: (NSTableView *)tableView objectValueForTableColumn: (NSTableColumn *) column row: (int) row

So this is how I would expect your method to be (off the top of my head):

- (void)awakeFromNib
{
NSURL * userURL;
NSMutableArray *parsedURL;

userURL = [NSURL URLWithString:@"http://www.yahoo.com"];
parsedURL = [NSMutableArray arrayWithArray:[self parseURL:userURL]];

[tableDataSource setDataArrayarsedURL];
}

and your dataSource class would be something like:

- (void) setDataArrayNSMutableArray *)anArray{
[anArray retain];
[tableViewArray release];
tableViewArray = anArray;
}

and you'll have in your dealloc method something like:

- (void) dealloc {
[tableViewArray release];
[super dealloc];
}

Another option would be that you could have an NSMutableArray instantiated, and at the setDataArray, remove all objects, and addObjectsFromArray from the passed array...

<small>[ 06-20-2002, 10:07 PM: Message edited by: Brad Brack ]</small>
     
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Jun 20, 2002, 08:39 PM
 
NSMutableArray != NSArray. parseURL returns the latter, and setDataArray expects the former. Your best bet to fix it, if you wrote the parseURL method, is to return an NSMutableArray* instead; if not, use [NSMutableArray arrayWithArray:[self parseURL:userURL]] to turn the NSArray into one.
[vash:~] banana% killall killall
Terminated
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:27 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2