CoreData questions: How to reset NSManagedObject, how to Un-manage an NSManagedObject.

2011-03-23 Thread Motti Shneor
Hi. 

1. When you create an NSManagedObject, it is initialized with default values 
defined in the model. How can I reset an existing NSManagedObject to these 
default values? 

2. We have a multithreaded application, and we only keep one core-data context. 
Our network-related code receives data in a background thread, but is unable to 
write it to the model directly. So it saves it in some intermediate data 
object, and passes it to the main-thread for writing into the model.

I would like to use an NSManagedObject to replace the intermediate data object 
--- It is quite ugly to have duplicated model classes definition for 
everything. My question:

Can I somehow detach an NSManagedObject from its context, and use it in an 
Unmanaged way? 
Hopefully I can later attach it to the context, or create another 
NSManagedOBject from its data?


Motti Shneor, 
Spectrum Reflections LTD.
---
ceterum censeo microsoftiem delendam esse
---










___

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: design question

2011-03-23 Thread Ariel Feinerman
thank you very much for your answers.

2011/3/23 Graham Cox graham@bigpond.com


 On 23/03/2011, at 11:58 AM, Quincey Morris wrote:

  1b. The property is a to-many relationship.
 
  If #1a, then the return value should be unchangeable, in the sense that
 it should never change after being returned (regardless of whether the
 returned object is of a mutable class or not). That means, if an existing
 mutable array is the desired return value, which the owning class might
 mutate later, a copy *must* be returned instead.
 
  If #1b, then the return value should be assumed to be changeable, in the
 sense that it could change any time after being returned. (Again, the return
 value's class's mutability is irrelevant.) *Semantically, what's being
 returned is a proxy for the relationship*, not an array. In this case, the
 return type merely indicates whether the caller can mutate the relationship
 via the proxy or not.
 
  In practice, it works in reverse. If the method returns something
 unchangeable, the property is regarded as an attribute. If it returns
 something changeable, the property is regarded as a to-many relationship.
 
  This is consistent with Core Data properties, and keeping the distinction
 clear keeps the API design honest and helps write correct code -- it makes
 it easy to decide whether to return a copy of the underlying array or not.
 
  Your discussion about how long and why has different answers
 depending on which of the two kinds of properties is involved. The pitfall
 here is that if the property is intended to be a snapshot of the state of a
 relationship (an attribute, as opposed to the actual relationship),
 returning the underlying mutable array without copying is a bug, even if the
 return type is NSArray.


 Right, and I agree. You've expressed it better than I did, sometimes it's
 hard to convey in writing something that you have only understood at some
 intuitive level. So this helps clarify something I hadn't made entirely
 clear in my own mind.

 The situation is #1b. And you know this, because you have more information
 than just a return type - you have the name of the method, -children. This
 pretty much tells you that you're dealing with a to-many relationship. If it
 doesn't, you've named it badly. Thus, a client can and should expect it to
 change, and so, if it actually wants a snapshot, it should perform the copy,
 but if not, it shouldn't cache it. Either way, in my view the onus is on the
 client as to whether to perform the copy - the vending object doesn't know
 what the client is going to use it for, so whether to copy it or not is not
 something it can know, so it should do the simplest thing (an instance of
 Occam's Razor?) which is, not copy. In practice, you rarely run into
 problems with this approach. I know everyone will have their favourite
 counter-examples, but that's why I say 'rarely', not 'never'.



 --Graham





-- 
best regards
Ariel
___

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: CoreData questions: How to reset NSManagedObject, how to Un-manage an NSManagedObject.

2011-03-23 Thread Andreas Grosam

On Mar 23, 2011, at 8:21 AM, Motti Shneor wrote:

 Hi. 
 
 1. When you create an NSManagedObject, it is initialized with default values 
 defined in the model. How can I reset an existing NSManagedObject to these 
 default values? 
Unless there is a better way, I would suggest to use a dictionary 
representation of a freshly created managed object  through taking a 
snap-shot of this object using dictionaryWithValuesForKeys:. Then reset any 
managed object by sending it setValuesForKeysWithDictionary:. You may declare 
this dictionary as a class variable of your custom class and initialize it once 
when you create the first managed object. You may get the key paths using the 
entity description.

 
 2. We have a multithreaded application, and we only keep one core-data 
 context. Our network-related code receives data in a background thread, but 
 is unable to write it to the model directly. So it saves it in some 
 intermediate data object, and passes it to the main-thread for writing into 
 the model.
 I would like to use an NSManagedObject to replace the intermediate data 
 object --- It is quite ugly to have duplicated model classes definition for 
 everything. My question:
I wonder why you cannot modify the model (that is save a context) within the 
background thread. Business logic should be honored regardless of the thread. 
So, usually you would do the following:

Use one dedicated context for each thread. Your background thread imports new 
objects and inserts (or modifies) it into its context, say import context. A 
controller has registered (e.g. on the main thread) for context save 
notifications (NSManagedObjectContextDidSaveNotification) sent from import 
context. It also specifies a method to be invoked, say importContextDidSave::

// controller.m
[[NSNotificationCenter defaultCenter] addObserver:self 
 
selector:@selector(importContextDidSave:) 
 
name:NSManagedObjectContextDidSaveNotification 
   object:importContext];

When you are ready with importing, save the import context in the background 
thread (or do it periodically if this is appropriate). When the context is 
saved, the notification center invokes the registered method in your 
controller. Upon receiving, you merge the import context with your main context 
(which may be used for a table view), so basically:

- (void) importContextDidSave:(NSNotification*)saveNotification  {
[mainContext mergeChangesFromContextDidSaveNotification:saveNotification];
}
Here, the current thread-context is irrelevant as long as you do not access the 
managed objects directly which are accessible through the userInfo of the 
saveNotification. Using mergeChangesFromContextDidSaveNotification:, the 
context is able to safely merge the changes, regardless of the thread-context.  
Note, that due to merging, the mainContext's state with respect to hasChanges 
does not change.


Please note, that this background thread does not necessarily have to be the 
same thread where you import data. It can be any worker thread, and it may 
take any imported data objects from a fifo which are subsequently taken to 
create managed objects. Also, this worker thread may take any actions to 
perform additional validations or plausibility checks which may have prevented 
the import thread to save these objects to the model.
 

Fortunately, there is quite good documentation for threading and Core Data. 
Core Data Programming Guide, Concurrency with Core Data.
There are also good examples for this. Please take look. ;)

 
 Can I somehow detach an NSManagedObject from its context, and use it in an 
 Unmanaged way? 
No, a managed object must be registered with a managed object context.
 Hopefully I can later attach it to the context, or create another 
 NSManagedOBject from its data?
You could use a dictionary representation and initialize a managed object from 
it.

Regards
Andreas
 
 
 Motti Shneor, 
 Spectrum Reflections LTD.
 ---
 ceterum censeo microsoftiem delendam esse
 ---
___

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: How hidden the Keyboard in a UIWebView

2011-03-23 Thread Rodrigo Zanatta Silva
Hi, sorry for this delay, I had to solve another thing. The reason of WHY i
am trying do this is because my boss say: DO IT!! Lol. I am doing a User
Manager so the user will not need to write in the keyboard and the system
will record the user name.

The UIWebView has a bad integration with keyboard and Java Script. And i
can't control the keyboard at all, I can only listen what it will do.

Ok, you give-me a start point. What I tried was:

   - [myWebView
stringByEvaluatingJavaScriptFromString:@document.getElementsByName(myname)[0].onclick
   = function onclick(event){document.getElementsByName(myname)[0].blur();};

Result: FAIL!! why? Because the cocoa first start to show the keyboard than
it will execute the JavaScript code. So,  in the middle of animation, it run
and the keyboard return the animation and go out. I don't want it even start
to show.

The second way:

 [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification object:nil];

- (void)esconde {
 for (UIWindow *keyboardWindow in [[UIApplication sharedApplication]
windows])
 for (UIView *keyboard in [keyboardWindow subviews])
 if([[keyboard description] hasPrefix:@UIPeripheralHostView]
== YES) [keyboard removeFromSuperview];
}
- (void)keyboardWillShow:(NSNotification *)aNotification {
[self performSelector:@selector(esconde) withObject:nil afterDelay:0];
}

Result: Well, work... But... It show the very start of the animation, but
the keyboard don't show. See that I NEED some delay, because this I use the
performSelector. I don't need more delay than the use of this way. If I use
the function directly, the UIPeripheralHostView will not exist. This way
is little dirty...

The problem to automatic focus a text box (it work) and than show the
keyboard isn't working.

How can I use the comand [keyboard showForFocusedTextBox]. Any more idea to
control the keyboard?


2011/3/15 Conrad Shultz con...@synthetiqsolutions.com

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 On 3/15/11 7:09 AM, Rodrigo Zanatta Silva wrote:
  Anyone have any idea? I am stuck... It's easy do this with
  UITextView, but the text field in a web page have less control. I
  really need a new idea, please, anyone give-me a idea??!?!?

 Please be patient.  If no one responds, it's probably because they don't
 have an idea either.


Lol.. I have to try..



  2011/3/14 Rodrigo Zanatta Silva rodrigozanattasi...@gmail.com
 
  I searched a lot, and all thing that hidden the keyboard is when
  you are in a UITextField.
 
  This is the problem. I am in a UIWebView and the user click in a
  text box in the web page, so the iOS open the keyboard. I can know
  when the keyboard will show by the  UIKeyboardWillShowNotification.
  But, I want to show another screen instead the keyboard.

 Try not using a UIWebView?  This whole scheme sounds a bit fishy to
 me... if you are interfacing with a web service, for example, you should
 probably implement a native UI and use XML, JSON, etc. to talk the the
 site.

 I do know that there are some reasons you would want to do this, such as
 displaying a keypad for numeric entry.  This _ought_ to be handled with
 XHTML's inputmode attribute, which MobileSafari doesn't support.

 For any Apple engineers out there, I filed a bug a long time ago on
 this... rdar://6404093

  How can I hidden, or never show the keyboard. If the people cancel
  my screen, than I want to keyboard appear. There are any class that
  I can manager the keyboard? How can I do this:
 
  *[keyboard goWay]* and
 
  *[keyboard show]*

 I have no special insights on this, but you might check out

 http://stackoverflow.com/questions/792035/how-do-i-cancel-a-text-field-edit-in-a-uiwebview

 This purports to let you lose the keyboard via defocusing in JavaScript.
  You would then probably need to present your own view for input on top
 of/next to the UIWebView and write controller code to send it into the
 UIWebView.

 Also see

 http://stackoverflow.com/questions/2749486/fill-uiwebview-textinput-with-custom-keyboard

 Sounds like a huge headache to me, though, and again I question the
 wisdom of what you are trying to do.  Perhaps you can elaborate on WHY
 you need to this and someone on the list might offer a more robust and
 probably simpler solution.

 - --
 Conrad Shultz

 Synthetiq Solutions
 www.synthetiqsolutions.com
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.7 (Darwin)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

 iD8DBQFNf9TMaOlrz5+0JdURAmJ3AJ0bBHozwjR4gboflOeyvJ3lBpXotgCeLC/y
 pvvZ3U04Qt956lkho/e6Tmw=
 =nZnY
 -END PGP SIGNATURE-

___

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:

Re: How hidden the Keyboard in a UIWebView

2011-03-23 Thread Laurent Daudelin
Rodrigo,

I'm not sure, even after reading your entire message, what you're trying to 
accomplish. But, from what you mention, you seem to want to provide your boss 
with a way to bypass some login screen or automatically enter a user name, is 
that right?

I wrote an application which kind of does what you're trying to do. If you have 
to show the login screen or the screen when the user name is entered, it will 
not work. In my application, I have my own view for the user to enter his user 
name. I even provide an option so that his user name is saved so that the next 
time, I can retrieve it. Then, the trick is to keep the UIWebView hidden. You 
just don't show it and using the stringByEvaluatingJavascriptFromString:, you 
can provide the user name and even trigger the button that will allow the 
login. From that point, when the UIWebView starts loading the next page after 
the login, you can show it.

I can provide you more details privately if you're interested, just email me.

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://www.nemesys-soft.com/
Logiciels Nemesys Software  
laur...@nemesys-soft.com

On Mar 23, 2011, at 11:25, Rodrigo Zanatta Silva wrote:

 Hi, sorry for this delay, I had to solve another thing. The reason of WHY i
 am trying do this is because my boss say: DO IT!! Lol. I am doing a User
 Manager so the user will not need to write in the keyboard and the system
 will record the user name.
 
 The UIWebView has a bad integration with keyboard and Java Script. And i
 can't control the keyboard at all, I can only listen what it will do.
 
 Ok, you give-me a start point. What I tried was:
 
   - [myWebView
 stringByEvaluatingJavaScriptFromString:@document.getElementsByName(myname)[0].onclick
   = function onclick(event){document.getElementsByName(myname)[0].blur();};
 
 Result: FAIL!! why? Because the cocoa first start to show the keyboard than
 it will execute the JavaScript code. So,  in the middle of animation, it run
 and the keyboard return the animation and go out. I don't want it even start
 to show.
 
 The second way:
 
 [[NSNotificationCenter defaultCenter] addObserver:self
 selector:@selector(keyboardWillShow:)
 name:UIKeyboardWillShowNotification object:nil];
 
 - (void)esconde {
 for (UIWindow *keyboardWindow in [[UIApplication sharedApplication]
 windows])
 for (UIView *keyboard in [keyboardWindow subviews])
 if([[keyboard description] hasPrefix:@UIPeripheralHostView]
 == YES) [keyboard removeFromSuperview];
 }
 - (void)keyboardWillShow:(NSNotification *)aNotification {
 [self performSelector:@selector(esconde) withObject:nil afterDelay:0];
 }
 
 Result: Well, work... But... It show the very start of the animation, but
 the keyboard don't show. See that I NEED some delay, because this I use the
 performSelector. I don't need more delay than the use of this way. If I use
 the function directly, the UIPeripheralHostView will not exist. This way
 is little dirty...
 
 The problem to automatic focus a text box (it work) and than show the
 keyboard isn't working.
 
 How can I use the comand [keyboard showForFocusedTextBox]. Any more idea to
 control the keyboard?

___

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


Exporting and Importing CoreData

2011-03-23 Thread Siegfried
Hello,

I need to create an export / import system for my app, and just thought that 
asking the list for some advices could help a lot.

The CoreData database I have is fairly simple. No relationships, only 3 
entities with no more than 4 properties each: numbers and strings. So I think 
exporting this as XML is the more appropriate solution. Also, it would allow 
users make changes in the file easily.

Are there any serious drawbacks from using this method? Or may a better 
solution? What worries me most is the XML validation. It's not a high priority, 
but having an at least decent XML is worthwhile. The big question: A header 
saying XML version 1.0 is enough? Or do I need to create a DTD?

Also, now on the mechanics, I think creating a mutable string and go appending 
parts of the XML in a loop is adequate for this task, and using NSXMLParser to 
parse it back should work. Indeed, the file will not be that big (usually a few 
hundreds of KBs, really extremes cases are 1 or 2MB). Well, at least I'm not 
aware of a framework to export / import CoreData, I don't even think it is 
possible.

Any yes or no on my ideas are really appreciated.

Thanks,

Best wishes,

Siegfried___

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


Problem with setAttributesOfItemAtPath:error:

2011-03-23 Thread Laurent Daudelin
I'm writing an application that copies files from one folder to another.

I've been using NSFileManager copyItemAtPath:toPath:error: and it generally 
works well. However, when trying to copy files from a local folder to a folder 
on a remote volume, copyItemAtPath:toPath:error: will sometimes fails to set 
the creation and modification dates of the item copied. The problem is that 
when it fails to set the attributes of the item it copies, it will not report 
it as an error (not sure if this is a bug, this is kind of very annoying).

In any case, I wanted to dig a little deeper to find what's going on with that 
since I set permissions on the original folder to read/write for everyone and 
the receiving or destination folder on the remote drive with the same 
read/write permission to everybody. Of course, I connected with my user ID and 
password on the remote volume. When I check the permissions in the Finder, I 
see that both the source and destination folders have read/write permissions 
for the owner, the group and everybody. So, from there, I decided to 
systematically set the attributes myself, since copyItemAtPath:toPath:error: 
is failing to do it. So, I'm using attributesOfItemAtPath:error: and 
setAttributesOfItemAtPath:error to try to set the attributes of the copied 
item to that of the original item. I was not expecting it to really succeed but 
at least I was hoping to catch the error. That's where it gets interesting. 
When it fails, the localized description of the error is invariably You don’t 
have permission to save the file “Blah” in the folder “Folder Blah”. Folder 
Blah in this case is the destination folder on the remote drive.

So, what am I missing here? The error is plain wrong in the first place because 
I was not attempting to copy the item, it's already copied! I just checked 
again Folder Blah permissions and they are still set to read/write to owner, 
group and everybody.

Can someone explains this result?

Thanks in advance!

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://www.nemesys-soft.com/
Logiciels Nemesys Software  
laur...@nemesys-soft.com

___

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


NSCollectionView and firstResponder madness

2011-03-23 Thread Dave DeLong
Hi everyone,

I have an NSCollectionView in a sheet.  The NSCV does not allow selection and 
is used for displaying a list (so maxNumberOfColumns = 1) of views.  These 
views have things like NSComboBoxes and NSTextFields in them.  I'm trying to 
figure out how to be able to tab from textfield to textfield, jumping in 
between collectionViewItems, if necessary.

I've tried patching my NSCollectionViewItem subclass into the responder chain, 
overriding various NSResponder methods on various objects, and so on.  All of 
this has been fruitless.  I never see any of the events, let alone am able to 
respond to them.

How should I go about tabbing between views in disparate NSCollectionViewItems?

Thanks,

Dave
___

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: iPhone animation puzzle

2011-03-23 Thread Matt Neuburg
Nothing was reversed, unfortunately. Block-based animation was introduced in 
iOS 4.0, and user interaction has always been off by default during one, so if 
you wanted user interaction you always had to use 
UIViewAnimationOptionAllowUserInteraction - and you still do.

Apple did seem to regret this, and signaled an intent to change this policy; 
but they have never done so, and indeed it is hard to see how they could do it 
coherently.

(Of course, Apple can reverse anything at any time, like when they reversed the 
meaning of the y-component of a shadow offset without warning and screwed up 
everyone's drawing starting in 3.2.)

m.

On Sun, 20 Mar 2011 14:13:25 -0400, Jeff Kelley slauncha...@gmail.com said:
If I recall correctly, in iOS 4.0, this was reversed, but the next update 
changed the behavior to what we have now.

On Mar 20, 2011, at 1:25 PM, WT wrote:

 I seem to recall that one of the WWDC 2010 instructional videos - available 
 for free from Apple's developer site - mentions that the block version has 
 UIViewAnimationOptionAllowUserInteraction off by default.
 
 That being said, have you filed a document enhancement request?
 
 WT
 
 On Mar 20, 2011, at 1:59 PM, David Rowland wrote:
 
 That did it.
 
 The View Programmming Guide for iOS, discusses both methods and implies 
 that their code samples are equivalent. They don't say, or I didn't see, 
 that the option you mention is on by default for the begin/commit style and 
 off for the newer block style.
 
 thanks,
 
 David
 
 
 
 On Mar 19, 2011, at 5:08 PM, Roland King wrote:
 
 UIViewAnimationOptionAllowUserInteraction ?
 
 
 
 On Mar 20, 2011, at 5:42, David Rowland rowla...@sbcglobal.net wrote:
 
 This works. It fades the label to invisibility.
 
 label.alpha = 1.0;
 [UIView beginAnimations:nil context:nil];
 [UIView setAnimationDuration:2.5];
 label.alpha = 0;
 [UIView commitAnimations];
 
 
 and so does this,
 
 label.alpha = 1.0;
 [UIView animateWithDuration:2.5 animations:^{label.alpha = 0.0;} ];
 
 
 The documentation says the latter is now preferred and does the same 
 thing as the former. In particular, both will
 start a separate thread for the animation.
 
 My problem is that the second method seems to block the main thread. 
 While it is acting I cannot use any of the controls on the screen. The 
 first method lets me do what I wish as it proceeds.
 
 
 Anyone have advice?
 
 thanks,
 
 David

Jeff Kelley
slauncha...@gmail.com



--
matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook___

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

2011-03-23 Thread Lynn Barton
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


Re: Exporting and Importing CoreData

2011-03-23 Thread WT
On Mar 23, 2011, at 8:13 PM, Siegfried wrote:

 Hello,
 
 I need to create an export / import system for my app, and just thought that 
 asking the list for some advices could help a lot.
 
 The CoreData database I have is fairly simple. No relationships, only 3 
 entities with no more than 4 properties each: numbers and strings. So I think 
 exporting this as XML is the more appropriate solution. Also, it would allow 
 users make changes in the file easily.
 
 Are there any serious drawbacks from using this method? Or may a better 
 solution? What worries me most is the XML validation. It's not a high 
 priority, but having an at least decent XML is worthwhile. The big question: 
 A header saying XML version 1.0 is enough? Or do I need to create a DTD?
 
 Also, now on the mechanics, I think creating a mutable string and go 
 appending parts of the XML in a loop is adequate for this task, and using 
 NSXMLParser to parse it back should work. Indeed, the file will not be that 
 big (usually a few hundreds of KBs, really extremes cases are 1 or 2MB). 
 Well, at least I'm not aware of a framework to export / import CoreData, I 
 don't even think it is possible.
 
 Any yes or no on my ideas are really appreciated.
 
 Thanks,
 
 Best wishes,
 
 Siegfried

How about using a property list file instead? Easier to import and export, and 
can be edited with tools such as Property List Editor, though your users might 
not know how to use it, or even have it.

WT___

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: Problem with setAttributesOfItemAtPath:error:

2011-03-23 Thread Ken Thomases
On Mar 23, 2011, at 6:17 PM, Laurent Daudelin wrote:

 I've been using NSFileManager copyItemAtPath:toPath:error: and it generally 
 works well. However, when trying to copy files from a local folder to a 
 folder on a remote volume, copyItemAtPath:toPath:error: will sometimes 
 fails to set the creation and modification dates of the item copied. The 
 problem is that when it fails to set the attributes of the item it copies, it 
 will not report it as an error (not sure if this is a bug, this is kind of 
 very annoying).
 
 In any case, I wanted to dig a little deeper to find what's going on with 
 that since I set permissions on the original folder to read/write for 
 everyone and the receiving or destination folder on the remote drive with the 
 same read/write permission to everybody. Of course, I connected with my user 
 ID and password on the remote volume. When I check the permissions in the 
 Finder, I see that both the source and destination folders have read/write 
 permissions for the owner, the group and everybody. So, from there, I decided 
 to systematically set the attributes myself, since 
 copyItemAtPath:toPath:error: is failing to do it. So, I'm using 
 attributesOfItemAtPath:error: and setAttributesOfItemAtPath:error to try 
 to set the attributes of the copied item to that of the original item. I was 
 not expecting it to really succeed but at least I was hoping to catch the 
 error. That's where it gets interesting. When it fails, the localized 
 description of the error is invariably You don’t have permission to save the 
 file “Blah” in the folder “Folder Blah”. Folder Blah in this case is the 
 destination folder on the remote drive.
 
 So, what am I missing here? The error is plain wrong in the first place 
 because I was not attempting to copy the item, it's already copied! I just 
 checked again Folder Blah permissions and they are still set to read/write 
 to owner, group and everybody.
 
 Can someone explains this result?

Not all file system drivers support all attributes.  Even if, on the file 
server, the local file system driver supports the attributes you're trying to 
set, the file sharing protocol may not.  Even if the file sharing protocol 
does, the file system driver on the client machine that implements that 
protocol may not.

You can see what happens when you drop down to using lower-level routines like 
setattrlist().  You can also use Apple's FSMegaInfo sample code to query the 
file system's capabilities using getattrlist().  (You can, of course, write 
your own tool to query that, but FSMegaInfo is ready-built.)

Regards,
Ken

___

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: Exporting and Importing CoreData

2011-03-23 Thread Siegfried

On 23/03/2011, at 20:38, WT wrote:

 On Mar 23, 2011, at 8:13 PM, Siegfried wrote:
 
 Hello,
 
 I need to create an export / import system for my app, and just thought that 
 asking the list for some advices could help a lot.
 
 …
 
 How about using a property list file instead? Easier to import and export, 
 and can be edited with tools such as Property List Editor, though your users 
 might not know how to use it, or even have it.
 
 WT

I was considering using it initially, but as you've stated that would make 
things a bit more complicated when it comes to editing. XML would be ideal. 
Also, the final file would be less verbose (not filled with nested dicts and 
key value pairs).

I really don't know when it comes to building the system. Do you think it would 
integrate with CoreData better? Or just mean less code to write? The latter 
case is not a problem though :-)

Thanks WT!___

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: Exporting and Importing CoreData

2011-03-23 Thread WT
On Mar 23, 2011, at 8:46 PM, Siegfried wrote:

 On 23/03/2011, at 20:38, WT wrote:
 
 On Mar 23, 2011, at 8:13 PM, Siegfried wrote:
 
 Hello,
 
 I need to create an export / import system for my app, and just thought 
 that asking the list for some advices could help a lot.
 
 …
 
 How about using a property list file instead? Easier to import and export, 
 and can be edited with tools such as Property List Editor, though your users 
 might not know how to use it, or even have it.
 
 WT
 
 I was considering using it initially, but as you've stated that would make 
 things a bit more complicated when it comes to editing. XML would be ideal. 
 Also, the final file would be less verbose (not filled with nested dicts and 
 key value pairs).

If you save your property list as XML and not as a binary file, then it's still 
XML and can be edited equally with PLE or any text editor (though maintaining 
its property list format may be a challenge for your users). As for how verbose 
it would be, a simple structure such as what you mentioned shouldn't produce 
anything overly verbose, I think. I suggest you try some simple tests to see 
how you like the results.

 I really don't know when it comes to building the system. Do you think it 
 would integrate with CoreData better? Or just mean less code to write? The 
 latter case is not a problem though :-)

I'm not entirely sure because I'm relatively inexperienced with Core Data but I 
suspect that it would involve much less code than having to parse the input 
file yourself.


 Thanks WT!

Most welcome. :)

WT

___

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: Exporting and Importing CoreData

2011-03-23 Thread BareFeetWare
On 24/03/2011, at 10:13 AM, Siegfried wrote:

 I need to create an export / import system for my app, and just thought that 
 asking the list for some advices could help a lot.
 
 The CoreData database I have is fairly simple. No relationships, only 3 
 entities with no more than 4 properties each: numbers and strings.

Have you considered using SQLite, either for the import/export file format, or 
even for the native app document format (so the native and export file are 
actually the same thing and no export is needed)? It removes several layers of 
complication.

There are many tools for manipulating SQLite data on every platform, so it's 
easy to access the document elsewhere.

Tom
BareFeetWare

 --
Comparison of SQLite GUI tools:
http://www.barefeetware.com/sqlite/compare/?ml

___

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: Problem with setAttributesOfItemAtPath:error:

2011-03-23 Thread Laurent Daudelin
On Mar 23, 2011, at 16:38, Ken Thomases wrote:

 On Mar 23, 2011, at 6:17 PM, Laurent Daudelin wrote:
 
 I've been using NSFileManager copyItemAtPath:toPath:error: and it 
 generally works well. However, when trying to copy files from a local folder 
 to a folder on a remote volume, copyItemAtPath:toPath:error: will 
 sometimes fails to set the creation and modification dates of the item 
 copied. The problem is that when it fails to set the attributes of the item 
 it copies, it will not report it as an error (not sure if this is a bug, 
 this is kind of very annoying).
 
 In any case, I wanted to dig a little deeper to find what's going on with 
 that since I set permissions on the original folder to read/write for 
 everyone and the receiving or destination folder on the remote drive with 
 the same read/write permission to everybody. Of course, I connected with my 
 user ID and password on the remote volume. When I check the permissions in 
 the Finder, I see that both the source and destination folders have 
 read/write permissions for the owner, the group and everybody. So, from 
 there, I decided to systematically set the attributes myself, since 
 copyItemAtPath:toPath:error: is failing to do it. So, I'm using 
 attributesOfItemAtPath:error: and setAttributesOfItemAtPath:error to try 
 to set the attributes of the copied item to that of the original item. I was 
 not expecting it to really succeed but at least I was hoping to catch the 
 error. That's where it gets interesting. When it fails, the localized 
 description of the error is invariably You don’t have permission to save 
 the file “Blah” in the folder “Folder Blah”. Folder Blah in this case is 
 the destination folder on the remote drive.
 
 So, what am I missing here? The error is plain wrong in the first place 
 because I was not attempting to copy the item, it's already copied! I just 
 checked again Folder Blah permissions and they are still set to read/write 
 to owner, group and everybody.
 
 Can someone explains this result?
 
 Not all file system drivers support all attributes.  Even if, on the file 
 server, the local file system driver supports the attributes you're trying to 
 set, the file sharing protocol may not.  Even if the file sharing protocol 
 does, the file system driver on the client machine that implements that 
 protocol may not.
 
 You can see what happens when you drop down to using lower-level routines 
 like setattrlist().  You can also use Apple's FSMegaInfo sample code to query 
 the file system's capabilities using getattrlist().  (You can, of course, 
 write your own tool to query that, but FSMegaInfo is ready-built.)
 
 Regards,
 Ken
 

Hello Ken.
I actually looked at FSMegaInfo but when I built it, I realized that it was 
using a lot of deprecated functions in 10.6 so I decided against using any part 
of it because of the amount of work that would be required to rewrite some 
parts of it.

And yes, I do understand that different file systems will have different 
attributes. But, I'm sharing that remote volume from an Intel iMac running 
10.5.8, connected to it through AFP. Shouldn't AFP supports basic file 
attributes? Not using Samba here or WebDAV, just plain Finder Shared 
computers...

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://www.nemesys-soft.com/
Logiciels Nemesys Software  
laur...@nemesys-soft.com

___

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: Exporting and Importing CoreData

2011-03-23 Thread Siegfried
On 23/03/2011, at 20:55, WT wrote:
 On Mar 23, 2011, at 8:46 PM, Siegfried wrote:
 On 23/03/2011, at 20:38, WT wrote:
 On Mar 23, 2011, at 8:13 PM, Siegfried wrote:
 Hello,
 
 I need to create an export / import system for my app, and just thought 
 that asking the list for some advices could help a lot.
 
 …
 
 How about using a property list file instead? Easier to import and export, 
 and can be edited with tools such as Property List Editor, though your 
 users might not know how to use it, or even have it.
 
 WT
 
 I was considering using it initially, but as you've stated that would make 
 things a bit more complicated when it comes to editing. XML would be ideal. 
 Also, the final file would be less verbose (not filled with nested dicts and 
 key value pairs).
 
 If you save your property list as XML and not as a binary file, then it's 
 still XML and can be edited equally with PLE or any text editor (though 
 maintaining its property list format may be a challenge for your users). As 
 for how verbose it would be, a simple structure such as what you mentioned 
 shouldn't produce anything overly verbose, I think. I suggest you try some 
 simple tests to see how you like the results.

I agree. Editing a XML plist is not difficult, and can be done with no problems 
in a standard text editor — users may not have problems. I'll be working on 
some tests as you suggested.

 
 I really don't know when it comes to building the system. Do you think it 
 would integrate with CoreData better? Or just mean less code to write? The 
 latter case is not a problem though :-)
 
 I'm not entirely sure because I'm relatively inexperienced with Core Data but 
 I suspect that it would involve much less code than having to parse the input 
 file yourself.

Yes, parsing is the laborious part. I see calling a method on NSDictionary to 
read the plist is a lot easier :-) but now just tests may reveal the next path 
to take. At least, I'd get the validation stuff for free.

Thanks again WT,

Best regards,

Sirgfried___

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: Exporting and Importing CoreData

2011-03-23 Thread Siegfried

On 23/03/2011, at 20:57, BareFeetWare wrote:

 On 24/03/2011, at 10:13 AM, Siegfried wrote:
 
 I need to create an export / import system for my app, and just thought that 
 asking the list for some advices could help a lot.
 
 The CoreData database I have is fairly simple. No relationships, only 3 
 entities with no more than 4 properties each: numbers and strings.
 
 Have you considered using SQLite, either for the import/export file format, 
 or even for the native app document format (so the native and export file are 
 actually the same thing and no export is needed)? It removes several layers 
 of complication.

Well, the app is not document based, so exporting its internal database is only 
for backup and sharing purposes. Also, I don't think exporting a partial 
database would be practical with SQLite (exporting one kind of entity for 
example). So I don't think that's something

 
 There are many tools for manipulating SQLite data on every platform, so it's 
 easy to access the document elsewhere.
 
 Tom
 BareFeetWare
 
 --
 Comparison of SQLite GUI tools:
 http://www.barefeetware.com/sqlite/compare/?ml
 

Great link! Quite useful.

Thanks Tom for providing valuable information,

Best wishes,

Siegfried___

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: Problem with setAttributesOfItemAtPath:error:

2011-03-23 Thread Ken Thomases
On Mar 23, 2011, at 7:37 PM, Laurent Daudelin wrote:

 I actually looked at FSMegaInfo but when I built it, I realized that it was 
 using a lot of deprecated functions in 10.6 so I decided against using any 
 part of it because of the amount of work that would be required to rewrite 
 some parts of it.

First of all, deprecated doesn't mean not available.  Second, the disk image 
I have (maybe from some time ago) has a pre-built binary.


 And yes, I do understand that different file systems will have different 
 attributes. But, I'm sharing that remote volume from an Intel iMac running 
 10.5.8, connected to it through AFP. Shouldn't AFP supports basic file 
 attributes?

Depends on what you mean by basic.  I don't recall you saying which 
attributes you were trying to set when you got errors.

Regards,
Ken

___

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


Changed Properties

2011-03-23 Thread Alex Kac
I love using CoreData and one of my favorite features is its ability to get me 
the changed values between commits without any work on my end. I know I can do 
it the old fashioned way of putting bools and setter methods that mark those 
booleans as dirty on changes, but I was curious if there was a good way to 
perhaps use CoreData mechanics or other Obj-C mechanics to do the same sort of 
thing in NSObject directly-derived classes. It seems to me that perhaps some 
KVO method might be useful for this purpose.
___

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


Help with Custom Control

2011-03-23 Thread Carlos Eduardo Mello

Hi,

I built a special control with a custom view and several parts,  
including standard controls and some subviews. The thing does special  
displaying and animation, and needs to be connected to other parts of  
the UI and to the document controller. The set up works very nicely.  
Isolating it as a unit helped me debug minor drawing bugs and make its  
internal behaviour very consistent. However, I need to use several of  
these  in the UI, so the whole wiring business involves dozens of  
connections in IB. Hence my questions:


1. Is there a way to make a custom NSView send IBActions as if it were  
one of the standard controls?


2. Is there a simple way to turn my little device into something I can  
add to the library and reuse in several places. The idea would be to  
treat it as aunit and be able to just wire an Action to the file's  
owner.


3. The way it is working right now is through a triple delegation - I  
need to have a mouse up event initiated in a subview of my custom view  
trigger an action in the enclosing view which is in turn forwarded to  
the controller.


A, B and C are Custom Views

A contains B, B contains C;
B is C's delegate, A is B's delegate,
File's Owner is A's delegate;
Clicking C sends a message to F.O.

It works, but I was wondering if the design is not too complicated? (I  
am trying to keep each part from having to know about other part's  
workings).


I'd appreciate any ideas...
___

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: Changed Properties

2011-03-23 Thread Quincey Morris
On Mar 23, 2011, at 20:08, Alex Kac wrote:

 I love using CoreData and one of my favorite features is its ability to get 
 me the changed values between commits without any work on my end. I know I 
 can do it the old fashioned way of putting bools and setter methods that mark 
 those booleans as dirty on changes, but I was curious if there was a good way 
 to perhaps use CoreData mechanics or other Obj-C mechanics to do the same 
 sort of thing in NSObject directly-derived classes. It seems to me that 
 perhaps some KVO method might be useful for this purpose.

I'm pretty sure the answer is a pretty flat no. I can only think of 4 ways it 
could be done:

1. Write an advanced version of properties that does (basically) the 
bool/setter thing for you, with a new API.

2. Integrate the bool/setter thing into KVO.

3. Mimic the KVO approach of swizzling setter method implementations at run 
time, and maintain your change information that way.

4. Use KVO to observe every property of every object.

#1 is actually feasible, though quite a tricky task. (The implementation is 
similar, I think, to parts of what various people have done for language 
bridges to Objective-C.) #2-4 all sound horrible.

FWIW.


___

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