Core Data relationship fault
Can someone point me to an example or tutorial that shows how to get the value of a to-many relationship attribute of a Core Data entity? My application is simple and comparable to the Departments and Employees example in Apple's documents. When I select a department object I have no trouble accessing any of its other properties, but when I try to get its employees I get only a relationship fault. I have tried everything that I could find in the documentation and other people's comments (Google search) without success. I have subclassed the array controllers for departments and employees. In the departments array controller I am trying to calculate a transient property based on the properties of the employees when the method -(id)tableView:(NSTableView *)aTableView objectValueForTableColumn: (NSTableColumn *)aTableColumn row:(NSInteger)rowIndex is called by the departments TableView. Thanks. Lynn. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Data relationship fault
Thanks, that helps. I need to study the Core Data Programming Guide again, and this time pay more attention to the FAQs. Lynn On 2011 Apr 11, at 09:54, Lynn Barton wrote: Can someone point me to an example or tutorial that shows how to get the value of a to-many relationship attribute of a Core Data entity? My application is simple and comparable to the Departments and Employees example in Apple's documents. You just answered you own question ;) When I select a department object I have no trouble accessing any of its other properties, but when I try to get its employees I get only a relationship fault. I am trying to calculate a transient property I'd bet that's the problem. In my experience, transient properties are all pain (lotsa gotchas) with no (performance) gain. Consider either making it a regular property, or, probably better for your case since a table view can only show several tens of rows at a time, calculating it as a derived attribute. For the latter, remember your friend +keyPathsForValuesAffectingFoo. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: TableView sorts and then it doesn't--SOLVED
Problem solved. The sort key for the decimal property was misspelled in the table column attributes in IB. On Mar 20, 2011, at 8:48 PM, Scott Anguish wrote: have you implemented the delegate methods? is the array mutable? or do you supply a new array that is sorted? do you reload the data? On Mar 20, 2011, at 8:44 PM, Lynn Barton wrote: I have a document based application. The document window has an NSTableView with six columns. Four columns are bound to four text properties of an entity in my model; one column is bound to a decimal property, and one column has check boxes bound to a boolean property. When I run the application and open the saved document I can sort the text columns and the check box column by clicking on their headers. But once I click on the decimal column header, not only does it not sort but none of the other columns will sort after that. What's going on here? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
TableView sorts and then it doesn't
I have a document based application. The document window has an NSTableView with six columns. Four columns are bound to four text properties of an entity in my model; one column is bound to a decimal property, and one column has check boxes bound to a boolean property. When I run the application and open the saved document I can sort the text columns and the check box column by clicking on their headers. But once I click on the decimal column header, not only does it not sort but none of the other columns will sort after that. What's going on here? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Selecting an object based on the value of one of its attributes
Roland, the application in question uses Core Data. To build a dictionary as you suggest, I will need to wait until the array controller loads its content, then iterate over all members of the array, putting the property in question and the array index into the dictionary. How can I know immediately (without any user action) that the content has finished loading? I can't use awakeFromNib, as the content has not yet been loaded when that method is called. --Lynn On Apr 27, 2010, at 8:06 PM, Roland King wrote: Graham Cox wrote: On 28/04/2010, at 12:37 PM, Lynn Barton wrote: Newbie question: Consider an array of dictionary objects, all of the same class. One of the ivars of that class is an NSString which is unique for each instance. Does there already exist a method that will identify the one dictionary object that has a given value of that ivar, without me having to write code to examine all of the objects one by one? I have searched the documentation without finding such a method. Lynn Barton You could use NSPredicate to filter your collection based on your unique string property being equal to the one sought. If they are unique it will return exactly one item (or none, if it doesn't exist). See [NSArray filteredArrayUsingPredicate:] It's unclear whether that would be actually any faster than doing a linear search yourself - it might be slower, in that it wouldn't return as soon as it found the item, but would always check every element. --Graham I think that as Graham suggests that would be slower than searching yourself, but it is a method and it does exist and it's free, so you could try that and if it's fast enough for you, that's great. Actually iterating the list however yourself is very simple and possibly only the same number of lines of code as making a predicate. (code typed in mail) YourObject *found = nil; for( YourObject *obj in yourArrayOfObjects ) if( [ [ obj thePropertyYouWant ] isEqualToString:yourThing ] ) { found = obj; break; } // if found isn't nil, you found one, if it is, you failed. Finally - are these all your objects and are you always looking for the same property of them? If so instead of dumping them into an array you could build a dictionary of them as you insert them, keyed by that string property, then go look it up later when you want it. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Selecting an object based on the value of one of its attributes
Newbie question: Consider an array of dictionary objects, all of the same class. One of the ivars of that class is an NSString which is unique for each instance. Does there already exist a method that will identify the one dictionary object that has a given value of that ivar, without me having to write code to examine all of the objects one by one? I have searched the documentation without finding such a method. Lynn Barton ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Selecting an object based on the value of one of its attributes
On Apr 27, 2010, at 8:06 PM, Roland King wrote: Graham Cox wrote: On 28/04/2010, at 12:37 PM, Lynn Barton wrote: Newbie question: Consider an array of dictionary objects, all of the same class. One of the ivars of that class is an NSString which is unique for each instance. Does there already exist a method that will identify the one dictionary object that has a given value of that ivar, without me having to write code to examine all of the objects one by one? I have searched the documentation without finding such a method. Lynn Barton You could use NSPredicate to filter your collection based on your unique string property being equal to the one sought. If they are unique it will return exactly one item (or none, if it doesn't exist). See [NSArray filteredArrayUsingPredicate:] It's unclear whether that would be actually any faster than doing a linear search yourself - it might be slower, in that it wouldn't return as soon as it found the item, but would always check every element. --Graham I think that as Graham suggests that would be slower than searching yourself, but it is a method and it does exist and it's free, so you could try that and if it's fast enough for you, that's great. Actually iterating the list however yourself is very simple and possibly only the same number of lines of code as making a predicate. (code typed in mail) YourObject *found = nil; for( YourObject *obj in yourArrayOfObjects ) if( [ [ obj thePropertyYouWant ] isEqualToString:yourThing ] ) { found = obj; break; } // if found isn't nil, you found one, if it is, you failed. Finally - are these all your objects and are you always looking for the same property of them? If so instead of dumping them into an array you could build a dictionary of them as you insert them, keyed by that string property, then go look it up later when you want it. GREAT IDEA ! I'll try it. Thanks to you and Graham. Lynn ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [solved] Multiple validation errors. Why?
On Mar 18, 2010, at 7:51 AM, Sean McBride wrote: On Wed, 17 Mar 2010 21:05:06 -0700, Lynn Barton said: the app quits, I get a multiple validation errors occured message. The console has no error messages. Stick this in your app delegate: - (NSError*)application:(NSApplication*)application willPresentError:(NSError*)error { if (error) { NSDictionary* userInfo = [error userInfo]; NSLog (@encountered the following error: %@, userInfo); Debugger(); } return error; } -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada Thanks. That was just the help I needed. Console messages showed that I needed to explicitly set the value of one of the string attributes, which was defined with a minimum length of zero and a blank default value. Once I programmatically set the value to @ the errors went away. Things are looking up. Lynn Barton___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Multiple validation errors. Why?
I have a core data application. One entity is Hit. This entity typically has no instances when the application starts, and gets populated during the execution of the program. All of the instances appear to be OK when viewed in a TableView. Some or all instances may get deleted before the application quits. If any instances remain when the app quits, I get a multiple validation errors occured message. The console has no error messages. In debugging, I have gone so far as supplying no data at all when adding any instances, so they get created with default values only. Still I get the error message. Some attributes are strings, some are 16 bit integers, and some are 32 bit integers. The string defaults are empty strings, and the integer defaults are zero. I am creating Hit instances with this method NSManagedObject *newHit = [NSEntityDescription insertNewObjectForEntityForName:@Hit inManagedObjectContext:[appDelegate managedObjectContext]]; The app has three other entities, but they don't cause validation errors. Can anyone help? Lynn Barton ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
[SOLVED] Re: PopupButtonCell in a TableView column
Ok, after re-studying the documentation on bindings, etc, and material from the list archives, I was able to get my tableview working with a popup menu in one column. Neuburg's suggestions, though appreciated, let to a blind alley because the documentation clearly states that the array that defines the menu should be an array of strings. The turning point for me came when I saw that the popup's content binding should have a blank in the key field. After that, everything fell into place logically. However, the persistence of the error message remains a mystery that I will not pursue. If anyone wants to know more, just send me a private email. Lynn Barton ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Private ivars, not marked as IBOutlet, visible in IB
Buck and Yacktman's book Cocoa Design Patterns says on page 208, Any instance variable with type id and a name that doesn't start with an underscore character is automatically considered an outlet. Lynn ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
PopupButtonCell in a TableView column
I am trying to display my model data in an NSTableView where one integer property is represented by a popup menu in the first column of the table. I have searched the archives and seen that some others have done the same and asked for assistance, but none of the answers I found were complete enough for me to find the solution. With a model entity of (let's say) MyData and an array controller of MyDataArrayController, and two properties myIntProperty and myStringProperty, the tableview works perfectly without the popup menu. In this case, the first column has a text cell and a number formatter, and the column is bound to MyDataArrayController.arrangedObjects.myIntProperty. The second column is bound to MyDataArrayController.arrangedObjects.myStringProperty. Then I created another array controller, MyMenuArrayController (super is NSArrayController), which builds a fixed array of 3 NSStrings. That array becomes the arrangedObjects property of the controller. After removing the number formatter, and placing an NSPopupButtonCell in the first column of the table, I have tried many different bindings, and none of them worked. I always get the console error message [NSTableColumn 0x200083e20 valueForUndefinedKey:]: this class is not key value coding-compliant for the key value. The problem is made worse by the fact that even if I reverse the changes made from the previous, working configuration, putting the text cell and the number formatter in place of the popupbutton cell, the same error occurs. I have to use Time Machine to load the previous project files in order to get rid of the error. (1) What key value should be used with an NSString object in an array? description perhaps? (2) What are the correct bindings to use? (3) When the user changes the selected item in the popup menu, will that be automatically reflected in the value of myIntProperty? (4) Why does the error persist after I reverse the changes to the tableview? (5) Am I not providing the menu's array of strings in a correct way? This has me stumped, so any help will be greatly appreciated. Lynn Barton ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Validation error after setting the value of a boolean attribute
Why does my Core Data app give me a validation error message, when quitting the app, if the following code is used? I am importing some legacy data to set 5 string attributes of an object, but using this code to set the one BOOL attribute. In my model, myBooleanAttribute has a default value of NO, and the legacy data does not include this attribute, so I can avoid the validation error by omitting the following code, but I would like to know why it causes errors. [myNewObject setMyBooleanAttribute: NO]; ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Validation error after setting the value of a boolean attribute
On Feb 16, 2010, at 2:38 PM, Steven Degutis wrote: Boolean attributes in Core Data are not actually of type BOOL but rather NSNumber. Thus, your NO value is interpreted as nil (since nil == 0 == NO) and you're setting your attribute to nil. If the attribute is required, then nil is not a valid value, and you will get a validation error. Next time, if you look at the header of your file, it tells you what types you should use as arguments to methods, and what types to expect as return values. Thanks. Silly me, I thought that when the docs said that a BOOL was YES or NO then those were the values to use. I did some research on Key-Value coding and then was able to get the code to work by modifying it to the following: NSNumber *myBoolNumber = [NSNumber numberWithBool:NO]; [myNewObject setMyBooleanAttribute: myBoolNumber]; Steven Degutis Software Engineer Big Nerd Ranch, Inc. http://www.bignerdranch.com/ On Tue, Feb 16, 2010 at 5:35 PM, Lynn Barton lynnbar...@mac.com wrote: Why does my Core Data app give me a validation error message, when quitting the app, if the following code is used? I am importing some legacy data to set 5 string attributes of an object, but using this code to set the one BOOL attribute. In my model, myBooleanAttribute has a default value of NO, and the legacy data does not include this attribute, so I can avoid the validation error by omitting the following code, but I would like to know why it causes errors. [myNewObject setMyBooleanAttribute: NO]; ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/steven.degutis%40gmail.com This email sent to steven.degu...@gmail.com -- Steven Degutis http://www.thoughtfultree.com/ http://www.degutis.org/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
initializer methods
After many years of using procedural programming languages, I am trying to learn Cocoa. Today I am reading the Apple document The Objective-C Programming Language dated 2009-10-19. On page 46 I read the following: This is an example of what not to do: + (Rectangle *)rectangleOfColor:(NSColor *) color { self = [[Rectangle alloc] init]; // BAD [self setColor:color]; return [self autorelease]; } However, on page 49 I read the following: There are several constraints and conventions that apply to initializer methods that do not apply to other methods: . . . • You should assign self to the value returned by the initializer. This is because the initializer could return a different object than the original receiver. Could someone please explain this apparent contradiction? Lynn___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Pop up button in a tableview cell
I am building a core data application. On one of the windows there is a tableview with two columns. One column contains ordinary text items. The other column I want to contain popup menus so that the user can select one of three values (text). The value choices are the same for every row and never change. I found no documentation for how to put a popup menu into a tableview in IB or programmatically. My Mac OS is Leopard, and my Xcode is version 3.1.2. TIA. Lynn Barton ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Responding to mouseDown in an NSImageView
My window has an NSImageView object within an NSScrollView. After setting the image and the image frame, I want to detect and respond to mouseDown on the image. The image appears in the view, but I found nothing responding to the mouseDown. I tried subclassing NSImageView and putting a -(void)mouseDown: (NSEvent *)theEvent method in the subclass. That allowed me to get and process the event, but the image did not appear in the view. Can anyone help? Lynn Barton ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
[solved] Re: Incompatible managed object model versions
If your application is NSPersistentDocument-based, the document file *is* the persistent store. If you application isn't document-based, your application delegate probably contains a method that specifies the path to the persistent store. (In the Xcode Core Data application template, the boilerplate code puts it in a folder inside the Application Support folder.) Thanks. I found the persistent store and deleted it. That of course removed the error message. Now I can continue developing my app. Lynn Barton ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Incompatible managed object model versions
I am programming a Core Data application, and testing it from time to time by importing a small amount of data. This was going well for a while, but after the latest changes to the data model the application produces the error message The managed object model version used to open the persistent store is incompatible with the one that was used to create the persistent store. I don't think that I saved any data while testing the app, but perhaps I did. Please help me rescue this application. Thanks. Lynn. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Incompatible managed object model versions
On Jun 18, 2009, at 6:27 PM, Kyle Sluder wrote: On Thu, Jun 18, 2009 at 6:19 PM, Lynn Bartonlynnbar...@mac.com wrote: I don't think that I saved any data while testing the app, but perhaps I did. Please help me rescue this application. This message means that the managed object model changed. Rather than lossily loading pieces of the persistent store, Core Data simply refuses to load persistent stores that contain managed objects whose entities are different or nonexistent in the managed object model. You'll need to revert your managed object model, and if you want to continue using your data set you'll need to write a mapping model: http://developer.apple.com/documentation/Cocoa/Conceptual/CoreDataVersioning/Introduction/Introduction.html Hopefully you're following best practices and have a known working managed object model in your version control system. --Kyle Sluder Thanks, Kyle. I would like to try just deleting the existing persistent store and letting a new one be created based on the current model. Where would I find the existing persistent store? Lynn Barton ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTableView
By a coincidence, I am working right now on an application using a NSTableView. Did your controller call [ directoryTable reloadData] to let the NSTableView that it needs to update the table? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Can't get file type code using [fileAttr valueForKey:NSFileHFSTypeCode]
The replies to my original question are appreciated, but they do not answer the question. Once my NSFileManager object has found a file of interest, why can I get the modification date with the key NSFileModificationDate (using objectForKey or valueForKey doesn't matter) but I can't get the OSType code with the key NSFileHFSTypeCode. Each time I try to access this data I get a different result. I know that the file has a type code because I can access it with another program. From what I have read quickly since Sean McBride sent his comment, UTIs are not yet implemented to the point where I could get the UTI of every file on my computer. File attribute keys are found on page 48 of the pdf version of the document NSFileManager Class Reference. On 5/22/08 1:43 PM, Sean McBride [EMAIL PROTECTED] wrote: On 5/21/08 10:35 PM, Jens Alfke said: In general you're better off checking the filename extension. (I know. I used to be rabidly in favor of HFS types over extensions, but I gave up that fight years ago...) In general you're better off checking the UTI. http://developer.apple.com/macosx/uniformtypeidentifiers.html -- Sean McBride, B. Eng [EMAIL PROTECTED] Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Can't get file type code using [fileAttr valueForKey:NSFileHFSTypeCode]
I am trying to build a list of files found on my hard disk that pass a certain filter (predicate). Mostly my code works, but I want to get the modification date and the type code of each file. I am getting the date OK, but not the type code, which should be ³TEXT² for text files and might be ³WBBN² for a Microsoft Word document. Here is part of the code of my controller: NSFileManager *defMgr = [NSFileManager defaultManager]; NSDirectoryEnumerator *dirEnum = [defMgr enumeratorAtPath:placeToSearch]; while (file = [dirEnum nextObject]) { fileAttr = [dirEnum fileAttributes]; hfsFileType = [fileAttr valueForKey:NSFileHFSTypeCode]; modDate = [fileAttr valueForKey:NSFileModificationDate]; Can anyone tell me what is wrong? And by the way, how do I convert hfsFileType into a string? (Maybe I can figure that one out myself from the documentation.) Lynn ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]