Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Mar 22, 2007, 05:15 PM   #1
Littleodie914
macrumors 68000
 
Littleodie914's Avatar
 
Join Date: Jun 2004
Location: Rochester, NY
Finding the size of an NSArrayController?

Hey guys, pretty simple question, I've got an NSArrayController, and I'm trying to somehow get the size of it. Right now I'm trying:

[[stepsController arrangedObjects] count]

But it's returning 0. Any ideas? Thanks!
Littleodie914 is offline   0 Reply With Quote
Old Mar 23, 2007, 01:47 AM   #2
HiRez
macrumors 601
 
HiRez's Avatar
 
Join Date: Jan 2004
Location: Western US
Quote:
Originally Posted by Littleodie914 View Post
Hey guys, pretty simple question, I've got an NSArrayController, and I'm trying to somehow get the size of it. Right now I'm trying:

[[stepsController arrangedObjects] count]

But it's returning 0. Any ideas? Thanks!
Dunno, seems like that should work, and I'm pretty sure I'm using exactly that code in one of my projects. Are you absolutely certain you have more than 0 objects being controlled by the controller? Are you maybe using Core Data (where "count" possibly doesn't reflect objects that haven't been fetched from the data store yet)?
__________________
Go outside, the graphics are amazing!
HiRez is offline   0 Reply With Quote
Old Mar 23, 2007, 06:14 AM   #3
Eraserhead
macrumors G4
 
Eraserhead's Avatar
 
Join Date: Nov 2005
Location: UK
Quote:
Originally Posted by HiRez View Post
Dunno, seems like that should work, and I'm pretty sure I'm using exactly that code in one of my projects. Are you absolutely certain you have more than 0 objects being controlled by the controller? Are you maybe using Core Data (where "count" possibly doesn't reflect objects that haven't been fetched from the data store yet)?
Thats what I use too... Try checking the filter predicate is nil, then if it's still nil fetch the objects from the data store (Core Data only), see the following code.
Code:
	[arrayController setFilterPredicate:nil];
	if([[arrayController arrangedObjects] count]==0){
		//NSLog(@"no objects");//may be worth uncommenting this.
		[arrayController addObjects:[mObjC executeFetchRequest:[model fetchRequestFromTemplateWithName:@"yourObject"  substitutionVariables:[NSDictionary dictionary]]
															 error:nil]];
	}
EDIT: mObjC is the managedObjectContext and model is the managedObjectModel
__________________
If they have to tell you every day they are fair you can bet they arent, if they tell you they are balanced then you should know they are not - Don't Hurt me

Last edited by Eraserhead; Mar 23, 2007 at 06:21 AM.
Eraserhead is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Which do you prefer: MBA 12" same size as 11" or 11" with smaller size? hzxu MacBook Air 15 Apr 14, 2014 08:38 PM
are the lighted Apple logo the same size regardless of Macbook screen size? Jaranson MacBook Air 1 Dec 10, 2013 08:57 PM
Resolved: NSArrayController and "Shared User Defaults Controller" davidmirv Mac Programming 5 Apr 10, 2013 05:27 PM
Edit NSTableView - NSArrayController kikko088 Mac Programming 0 Jan 17, 2013 08:57 AM
Help me size choose the right size Air conditioner maflynn Community Discussion 6 Jul 16, 2012 09:54 AM

Forum Jump

All times are GMT -5. The time now is 07:50 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC