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

Posting 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

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
How detect the size of an original CD umbilical Mac Applications and Mac App Store 2 Aug 4, 2011 03:11 PM
Is it possible to change the size of an icon in menubar? rzucollo Mac Applications and Mac App Store 0 Apr 22, 2011 11:59 AM
how the size of an integer is decided? celia Mac Programming 25 Jul 1, 2007 11:11 AM
How to find the value of an apple gift card wmmk Apple, Industry and Internet Discussion 2 Nov 7, 2006 06:12 PM
μcard: 2 TB Storage on a drive the size of an SD card MacBytes MacBytes.com News Discussion 17 Aug 10, 2004 10:49 AM


All times are GMT -5. The time now is 07:06 AM.

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

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