Re: Does anyone else dislike Xcode 4?

2011-07-24 Thread Joanna Carter
Le 24 juil. 2011 à 20:46, Gary L. Wade a écrit :

 As I mentioned before, everyone should go to bugreporter.apple.com and enter 
 bugs against this horrible MS Windows method of UI that prevents usable 
 viewing of multiple files that has been added to Xcode.

Well, I would count myself as a relative novice to Xcode 4, but I have 
discovered that you can have multiple tabs in the main window and, if you want, 
you can tear off a tab into a separate window, close the navigator and 
inspector and have as many windows as you want open on the same project, with a 
different file in each.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Windows get released on 10.6, leak on 10.7

2011-07-21 Thread Joanna Carter
Le 21 juil. 2011 à 17:29, Ross Carter a écrit :

 I'm looking for ideas on what might cause this behavior: an existing app that 
 was compiled with 10.6 SDK runs fine on 10.6 and 10.5. When run on 10.7, 
 document windows (and their window controllers and NSDocuments) do not get 
 released when the window is closed.
 
 All thoughts appreciated.

Just a long shot, but does this have anything to do with the new ARC (Automatic 
Reference Counting)?

Joanna

--
Joanna Carter
Carter Consulting

___

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: standardDefaults

2011-07-21 Thread Joanna Carter
Le 21 juil. 2011 à 21:34, John Cate a écrit :

 I'm not seeing a user/library/Preferences folder on Lion.  Where are they 
 hiding application pLists in Lion (searching for them doesn't find any).

The folder is there, just hidden. Use Finder - Go to folder and type it in.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Synthesised properties and additional actions

2011-06-22 Thread Joanna Carter
Hi folks

Le 22 juin 2011 à 08:58, Ken Tozier a écrit :

 I just started using @properties this week, so probably don't understand the 
 nuances, but after looking at Matt's sample code, reading the property 
 related docs and doing some experimentation, I'm not sure I understand what 
 problem he's trying to solve. Is he talking about overriding inherited 
 getters/setters?
 
 With my own very limited experience with properties, it seems to be really 
 easy to add functionality. Just write the getter/setter yourself. When you go 
 to use them, they behave exactly like the auto generated ones re dot syntax, 
 and do whatever cool thing you added.
 
 What am I missing?

Yes, I would also like to know what Matt is trying to achieve with all those 
machinations that you can't do with a simple ivar in the class and not 
bothering to @synthesize. The only time I declare @synthesize and write 
getters/setters is when I want either a complex getter or setter but not have 
to bother writing the other.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Synthesised properties and additional actions

2011-06-22 Thread Joanna Carter
Hi Matt

 Well, if you really want to know that, just read the discussion in the book:
 
 http://www.apeth.com/iOSBook/ch12.html
 
 My thought was (putting myself in the shoes of the student), hey, I have no 
 idea exactly what code @synthesize generates, but whatever it is, it surely 
 constitutes a correct getter and (especially) setter, whereas if I write 
 those things myself (and especially the setter) the chances that I'll do 
 something wrong are quite high. So the question is simply, how can I add my 
 own functionality while at the same time inheriting all the synthesized 
 accessors' yummy goodness, whatever it may be? m.

Ah, now I get it!!!  - at least I think I do ;-)

AFAICT, you are talking about making non-GC accessors less prone to reference 
counting errors? If I'm using GC, then this, presumably, becomes less relevant?

Joanna

--
Joanna Carter
Carter Consulting

___

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: Synthesised properties and additional actions

2011-06-22 Thread Joanna Carter
Hi Matt

 My book is about iOS 4; there is no GC in that world! ☺

Aha! Missed that bit embarrassed

But was I finally right?

Joanna

--
Joanna Carter
Carter Consulting

___

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: Parent-child Design Pattern

2011-06-12 Thread Joanna Carter
Le 12 juin 2011 à 20:12, Martin Hewitson a écrit :

 This is a question about choosing the correct design pattern for a particular 
 application. This application is generic enough that I can describe it by a 
 simple parent-child model.
 
 Suppose I have a model object Parent which contains an array of Child objects.
 
 Then I have a ParentView object and a corresponding ParentViewController. The 
 controller has a reference to the Parent and to the ParentView and so can act 
 as a data source for the view.  So far, so good.
 
 What I'm unsure about is, how to deal with the children objects. I will, in 
 principle, have a ChildView. This raises some questions:
 
 1) Should I have a ChildViewController class?
 2) Where do I keep the array of ChildView classes? In the ParentView? And how 
 do I ensure that each ChildView is associated with the appropriate Child 
 object? 
 3) If I do have a ChildViewController class, where should I keep the array of 
 these? In the ParentViewController? 
 
 I can see a complicated spagehti system arising here. Suppose I don't only 
 have a Parent-Child system, but a deeper tree (A contains an array of B, each 
 B contains an array of C, etc), how should one extend the scheme?
 
 I'm guessing this is a generic enough situation that there exists a 
 best-practice for handling it. For some reason, I can't arrive at it myself, 
 so far. Any hints, keywords or clues would be well received.

This sounds like a typical tree structure. The basic structure is:

Node
  Node *parent
  NSArray *childNodes // contains instances of Node

NodeView
  NodeView *parentView
  NSArray *childViews // contains instances of NodeView

The Model takes this structure and so should the View.

I would say that you should design a NodeController and then derive from that 
class to add a ParentNodeController.

Joanna

--
Joanna Carter
Carter Consulting

___

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 to intercepting click on send in Mail.app

2011-05-30 Thread Joanna Carter
Le 30 mai 2011 à 15:02, Nava Carmon a écrit :

 Is it possible to intercept click on Send in Mac OS X Mail application?
 I'm writing a client that on click on Send in Mail client should perform 
 certain action

Why not just get Mail Act-on from Indev http://www.indev.ca/MailActOn.html; it 
might save you reinventing the wheel :-)

Joanna

--
Joanna Carter
Carter Consulting

___

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 to intercepting click on send in Mail.app

2011-05-30 Thread Joanna Carter
Le 30 mai 2011 à 15:51, Nava Carmon a écrit :

 Actually the client is supposed to get a text from the mail message when the 
 user clicks send. This client is not a mail client and not is supposed to 
 send mail.
 Is there some programmatic solution?

Mail Act-On can call Apple Script, which can do whatever you want with 
scriptable applications. I have a script that reacts to a message being sent 
and creates a To-Do item in Things.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Getting a handle on CoreAnimation and MVC

2011-05-24 Thread Joanna Carter
Hi Graham

 Of course I'm simplifying when discussing MVC - I have rarely found a case 
 that's pure in the sense of just M, V and C as well, usually there are 
 several layers of controller and the data model is distributed among 
 different objects as well. I felt the game example might be advantageous 
 because it's a very simple game which is easily modelled, though even there I 
 ended up with 3 classes to do it.
 
 However, you may have hit the nail on the head in saying that a game is also 
 going to have to compromise because it's very much concerned with how the 
 thing is presented - the game *is* the presentation as much as anything - 
 there really isn't much you can do with the abstract data model in this case 
 except present it and interact with it. That said, my original non-animated 
 design was very clean in that all the on-screen stuff was restricted solely 
 to the view class.

This is where I prefer MVC's little brother MVP (Model View Presenter).

Instead of having a Controller, which tends to be a mediator where Model and 
View are both handled, the MVP pattern uses a Presenter, which can contain 
one or more Interactors.

An Interactor is an object that is designed to handle gestures from the View.

The Model is also slightly more complex, in that it contains a Command Set.

A Command Set contains one or more Commands, each of which are designed to 
instigate one particular behaviour in the Value Object, held in the Model.

The advantage of having a Value Object *inside* the Model is that the Model 
represents a particular scenario, in which the Value Object is a participant. 
Thus you can have an Editing Model, a Reporting Model, etc, all for the 
same Value Object.

This further decomposition of the MVP design pattern can bring better clarity 
to the separation of concerns that such patterns are designed to accomplish.

 I've now moved a number of view-like properties into the data model - 
 things like the background colour of the board and so forth - these were 
 originally conceived as properties that the view layer brought to the party; 
 the game logic does not need to know what colour the board is, but then 
 again, it's reasonable to think of this as a property of the board itself. By 
 doing this and letting the relevant model object create and manage the 
 CALayer that ultimately represents it on screen, I'm back to a clean design, 
 just one where the animation layers are woven into the model and controller 
 layers.

I would definitely argue that this kind of design is not really cleaning up 
the design but, further, polluting it :-)

In the Cocoa world, the Controller is a very important part of getting the 
non-UI code to connect to the UI elements and to respond to gestures made 
through those UI elements.

I would venture to suggest that you are tending to think of the visual 
elements, put together in IB, as the View; I would rather think that you could 
look at creating View classes, which can hold the appearance properties and, 
to which, the UI elements should be bound to achieve their look and feel.

The MVP concept of Interactors, responding to UI gestures can be emulated by 
a Controller class, looking after the input side of things, whilst a View 
Presentation class would become the output, from which UI elements get their 
data.

I could go on further but would rather get to know if you think this makes any 
sense or needs further explanation.

Joanna

--
Joanna Carter
Carter Consulting

___

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 to start a Dashboard widget as soon as the user logs in?

2011-05-22 Thread Joanna Carter
Le 22 mai 2011 à 09:43, John Joyce a écrit :

 Dashboard Widgets do not begin doing anything until the first time the user 
 launches Dashboard.

I would think the best option for Behrang would be to write an ordinary app, 
that can be launched on startup, that provides the services behind a Dashboard 
Widget, which the widget simply connects to.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Closing an app with the red dot.

2011-05-17 Thread Joanna Carter
Jim

Do you realise that this is a mailing list for software developers?

Nonetheless, assuming you don't mean programatically, simply click on the 
application in the Dock.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Closing an app with the red dot.

2011-05-17 Thread Joanna Carter
 I am a cocoa developer, albeit a new one.  So I have every right to
 post this question on this site.
 
 I think Joanna can be forgiven for an honest misunderstanding.

My apologies; I also moderate other technical newsgroups and it is sometimes 
easy to jump to the wrong conclusion, especially when the OP doesn't mention 
anything to do with programming :-)

Joanna

--
Joanna Carter
Carter Consulting

___

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: Properties vs Instance Variables

2011-04-27 Thread Joanna Carter
Le 27 avr. 2011 à 16:52, Matt Neuburg a écrit :

 And Apple now exemplifies this pattern, e.g. in the app template for 
 Window-based Application: there's a window property accessing a _window 
 ivar. I think they do this just so you can't accidentally say window 
 unqualified. m.

I also think that Apple is (finally) starting to use the @private and 
@protected visibility specifiers in templates which, although they are not as 
strict as in other languages, start to educate people not to use ivars 
directly.

I too would like to see a means of explicitly accessing the ivar, even if it 
has the same name as the property; although, I thought that not calling 
self.property from within the .m file defaulted to accessing the ivar if both 
it and a property existed?

Joanna

--
Joanna Carter
Carter Consulting

___

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: Properties vs Instance Variables

2011-04-27 Thread Joanna Carter
Le 27 avr. 2011 à 17:39, David Duncan a écrit :

 @property(...) id foo;
 @synthesize foo = _foo;
 
 Then the following holds:
 _foo and self-_foo are equivalent means of direct ivar access.
 self.foo = bar and [self setFoo:bar] are equivalent means of setting the 
 value of the property foo.
 bar = self.foo and bar = [self foo] are equivalent means of getting the value 
 of the property foo.
 
 This remains true if you name the instance variable the same as the property, 
 but is typically considered more confusing. That is, if you use @synthesize 
 foo, you can still access foo and self-foo identically to _foo and 
 self-_foo above.

It's OK, for some reason, I thought I had read that self-foo was no longer 
usable; my bad :-)

Joanna

--
Joanna Carter
Carter Consulting

___

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: ArrayController vs Pop-up button vs Transformer -- three way tag team death match!

2011-04-20 Thread Joanna Carter
Hi Ben

 Trouble is that what I'm trying to model really is an array of strings.
 
 To put this problem into context, what I'm trying to offer the user through 
 the pop-up button is which character to use as a field separator when reading 
 a CSV file.  The value transformer is something that can recognise a string 
 that isn't visible (TAB for example) and put some sort of visible 
 representation in the button string.  What I'm trying to do is to keep the 
 strings unchanged in the content array and just change the presentation on 
 the button so I don't have to translate to and from the printable 
 representation.

I can easily add NSStrings to an NSArray, set that array as the Content Array 
of an NSArrayController and set the array controller as the Content of the 
NSPopupButton, with arrangedObjects as the Controller Key.

I think the problem is in the value transformer; could you post your code?

Joanna

--
Joanna Carter
Carter Consulting
___

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: ArrayController vs Pop-up button vs Transformer -- three way tag team death match!

2011-04-20 Thread Joanna Carter
Hi Quincey

 Your value transformer, if you insist on doing it that way, should be coded 
 to expect this, and should transform an entire array of strings, not single 
 strings.

I got the impression that the array in question could hold unprintable 
characters (tab, etc) and that the transformer was to make them into 
human-readable strings (@TAB). There is certainly no problem with displaying 
lists of strings via the Content binding, whether it is through an array 
controller or not.

But, you reckon that the transformer for the binding has to transform the whole 
array? Hmmm, now I'm going to have to try that out :-)

Joanna

--
Joanna Carter
Carter Consulting

___

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: Proper way to create a singleton without @synchronized ?

2011-04-18 Thread Joanna Carter
H Scott

 I've worked on projects where other people have made the app delegate 
 responsible for everything and the kitchen sink. It's one thing to have a 
 few core data stack methods in the app delegate; it's another to do a lot of 
 one's core data tasks in the app delegate. Personally, I prefer to move all 
 of that to a class whose sole responsibility is to manage core data tasks.
 
 And that's good thinking. Where I tend to disagree is with the impulse to 
 enforce every utility class to be a singleton, rather than just creating an 
 instance and getting on with it…

Yes; after the first few projects, based on the default Core Data project 
template, I started to realise that this (separating out the Core Data stack) 
was an excellent case for a singleton/static class.

Can someone tell me if it is just a matter of adding/modifying class files in 
the templates folder to make this happen every time?

Joanna

--
Joanna Carter
Carter Consulting

___

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: Proper way to create a singleton without @synchronized ?

2011-04-18 Thread Joanna Carter
Hi Greg

 A narrow technical reason: Objective-C's type system is limited when it comes 
 to class objects. Singleton instances are better supported.

Do you mean in that static fields are not supported, or something else?

Joanna

--
Joanna Carter
Carter Consulting

___

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: Proper way to create a singleton without @synchronized ?

2011-04-18 Thread Joanna Carter
Hi Steven

 How? If you don't have an instantiation of the class you don't have 
 anywhere to store the data.
 Either I am misunderstanding what you are saying or you are missing my 
 suggestion of class methods.
 Perhaps you could explain?

// StaticClass.h
@interface StaticClass : NSObject
{
}

+ (NSManagedObjectContext *) managedObjectContext;

@end

//StaticClass.m
@implementation StaticClass

static NSManagedObjectContext *managedObjectContext = nil;

+ (NSManagedObjectContext *) managedObjectContext
{
  if (!managedObjectContext)
  {

… // create and setup

  }
  return managedObjectContext;
}

@end


This can then be accessed from other code as…

{
  NSManagedObjectContext *context = [StaticClass managedObjectContext];

  …
}

Joanna

--
Joanna Carter
Carter Consulting

___

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: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread Joanna Carter
Hi guys

 That's only because, unlike java, obj-c doesn't have a way built into the 
 language to enforce a class to be abstract. I can see valid reasons to 
 subclass a singleton if that singleton is to be used as an abstract class and 
 never be instantiated by itself.

Tell me; maybe it's my background in other languages, but I would tend to use a 
static class as a singleton; or, at least, design a class with only class 
methods/properties, with static fields declared in the @implementation 
section of a class.

Why this fascination with going to all the trouble of creating a singleton 
rather than using the static class approach?

Joanna

--
Joanna Carter
Carter Consulting

___

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: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread Joanna Carter
Hi WT

 what happens if you need/want to subclass that class? Then you have to search 
 for and change all the places in your code base that refer to it.

Hmmm, I have a problem with the idea of subclassing singletons. Does the 
derived instance contain the same data as the base class; so that any reference 
to the derived singleton is implicitly also a reference to the base singleton?

Joanna

--
Joanna Carter
Carter Consulting

___

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: Passing an object to a custom sheet

2011-04-05 Thread Joanna Carter
Hi Torsten

 When I want to use an Object in the onOkButtonPressed function, how can I 
 set this object in instance #2? [NSBundle loadNibNamed:@Dialog owner:self] 
 does not return a pointer to the instance. In opposite, when didEndSheet is 
 called, I'm back in instance#1 without any knowledge about the value of 
 NSTextfield of instance#2.

The way I would usually handle this would be to add an extra -init method, 
which takes the object as a parameter, to the controller class, and hold the 
object in a private ivar in the controller.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Using the same typedef in multiple files

2011-03-13 Thread Joanna Carter
 I have what I suppose is a very basic question about the use of a typedef'd 
 enumerated data type. I want to use such a definition in multiple 
 implementation files in my project, and I'm wondering what would be the best 
 place to put the definition, so it is accessible from all these different 
 files?

Simply place it in a separate header file, in the project, and #import that 
file into whichever implementation files you need to use it.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Editing a list of NSMutableStrings

2011-03-03 Thread Joanna Carter
Hi Quincey

 I think I win by a mile. ☺

You certainly do ☺ I have been away from bare metal C programming for so long 
that I had forgotten about the way C handles array manipulation.

 However, in any likely scenario, the actual difference in performance is 
 likely to be unmeasurable. To make a noticeable difference, you either have 
 to be mutating the array of strings thousands of times a second, or have tens 
 of thousands of strings in your array.

Yup, that's what I would have expected. But, because I usually end up teaching 
this stuff, it always helps to pass on good information.

I just need to spend even more time getting into the Cocoa way.

Thanks again

Joanna

--
Joanna Carter
Carter Consulting

___

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


Editing a list of NSMutableStrings

2011-03-02 Thread Joanna Carter
Hi folks

This all started with a friend who wanted to emulate the Delphi concept of 
being able to simply add a list box to a form and add strings to it in the 
designer.

So, because I understand and teach separation of UI from data and, because 
Xcode beautifully supports MVC, I decided to put together a quick tutorial on 
how to achieve this.

I started by using the NSTableView, together with its delegate methods to 
supply the list of strings, but what my friend was really after was a way of 
using NSArrayController to supply the list of strings. This would also allow me 
to use the same NSArrayController to supply the list to an NSComboBox.

In working through this, I found that I needed to supply a read/write property 
in a category to NSMutableString.

I am writing a small article on this 
http://carterconsulting.myzen.co.uk/Articles/CreatingAnMruListInXcode.pdf and 
would value feedback on whether 1. I am on the right track, 2. there is already 
a better tutorial on this.

Many thanks

Joanna

--
Joanna Carter
Carter Consulting

___

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: Editing a list of NSMutableStrings

2011-03-02 Thread Joanna Carter
Hi Quincey

Many thanks for taking the time to look at this issue.

 This has come up at least once before, and the approach you're using was 
 suggested. I think it has some academic interest, but I'm not sure that it's 
 of great use in practical applications.

I would agree that it is not something that I would normally consider as major 
part of application design.

As someone who is very well known in the Delphi world, I seem to be doing quite 
a bit of evangelism about Mac development and most Delphi developers haven't 
even heard of MVC, design patterns and separation of concerns.

The kind of RAD development that Delphi (and Visual Studio) seem to encourage 
tends to end up with all the code in the form classes; people are used to doing 
everything in the UI,  filling list boxes with strings in the form designer 
and having to get the strings back from the control when required for 
manipulation.

My aim, in the tutorial, was to show non-Mac programmers that they could feel 
safe,  in that they could, in theory, easily display and manipulate a list of 
strings.

Normally, as you allude, I would expect to be using the NSTableView and 
NSComboBox to be displaying and choosing proper objects, based on a 
particular property.

 One thing I notice is that your transformation of string into a 
 NSMutableString property *isn't* KVO compliant. It would be if all the other 
 NSMutableString methods modified the underlying string data via 'setString:', 
 or issued 'will/didChangeValueForKey:' pairs. I'd bet they don't.

You have a good point there. It definitely comes into the classification of a 
kludge :-) Nonetheless, I a not expecting anything to be observing the change 
to the string property; after all, the whole point of the exercise is mainly 
to allow manipulation and editing of lists of NSMutableString instances in 
controls, rather than being KVC-compliant as in editing properties of other 
objects.

 The other issue is that it almost always turns out that the string fits in a 
 larger design which makes it natural for the string *value* to be a property 
 of some other object, so the hack of making it a property of NSMutableString 
 isn't really necessary. That's why I think your example is a bit academic. 
 (Of course, you can probably find some real examples where the string 
 property approach feels natural.)

Agreed; see my comments above :-)

 I don't understand why you're using 'will/didChangeValueForKey:@values 
 withSetMutation:NSKeyValueUnionSetMutation usingObjects: ...' for a property 
 that's a NSArray. The documentation says these methods are for unordered 
 collection properties -- i.e. NSSet properties. Chances are it's harmless 
 doing this the wrong way, but I wouldn't be surprised to see some UI 
 misbehaviors show up at some point.

Hmmm, yes I did realise the difference in terminology but… it works!!! Would it 
be sufficient to simply use will/didChangeValueForKey, without the set mutation 
part, to prompt the NSArrayController to update itself?

 I think there's also a conceptual problem in your use of NSMutableString 
 objects to populate your list. In a lot of cases, when a property value is to 
 be thought of as an attribute or simple value, the property value objects 
 should be immutable. (Consider, for example, the problem you'd face if you 
 tried to rework your tutorial to be a list of NSNumber objects.) What happens 
 if one of your mutable strings escapes from the list context (is returned 
 as a NSString* value of some method, for example), and is used elsewhere? 
 Would it be correct that mutating the original string in its list should 
 modify the value that had been passed on to a different context? Maybe yes, 
 maybe no. There's a small can of worms lurking there.

Oh yes, plenty of worms :-) But that's what you end up with when you are trying 
to help people get out of their all in one approach to software design and 
into techniques like MVC.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Editing a list of NSMutableStrings

2011-03-02 Thread Joanna Carter
Hi Quincey

 Use 'will/didChange:valuesAtIndexes:forKey:'.

Now how did I miss that? :-)

The trouble is, when you have spent years learning Delphi's VCL, then even more 
years learning the.NET libraries, the brain starts to get a bit crammed :-)

Joanna

--
Joanna Carter
Carter Consulting

___

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: Editing a list of NSMutableStrings

2011-03-02 Thread Joanna Carter
Hi Corbin

Long time no speak!! The last time we met in person, was when Borland paid for 
us (TeamB) to come out to Scotts Valley.

 Delphi developers may not have heard of it, but they do it by accident. They 
 place all of their controller code in a TForm subclass; rarely do they do 
 something in the TForm subclass that actually modifies what a standard TForm 
 does. Instead, the subclass exists only as controller code for the form (aka: 
 the view). They typically do have the model somewhere else (ie: 
 TDataModule), and interact with it in the Form subclass. Indirectly, they do 
 Model View Controller by the way Delphi is designed.

Yeh, definitely more by accident than design :-)

The problem with this particular Delphiite is that they think it is good 
separation to add strings to list view, which is definitely not part of the 
controller, nor the model.

 NSTableView is not like a Win32 Listcontrol, which is what Delphi's 
 TTreeView/TListView is based off of. It is more like TVirtualTreeView, where 
 the content is always queried, instead of placed inside.

Absolutely. But what this particular person seems to see is that it is more 
work to have to declare the data in the controller before hooking up the UI to 
it ??!!

 A good Delphi - AppKit tutorial would probably be showing people how to hook 
 up the File's Owner, add outlets, add actions, and the hook them up in IB. 
 All those things you basically got for free in Delphi by dropping down a 
 component and double clicking on it.

Yes, I've already done that in presentations and articles for the UK Developers 
Group.

 --corbin
 (known in the Delphi world about 6 years ago)

I bet you're glad you're not there any more ;-)

Joanna

--
Joanna Carter
Carter Consulting

___

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: context-aware bindings

2011-02-27 Thread Joanna Carter
Le 27 févr. 2011 à 10:07, Andy Lee a écrit :

 On Feb 27, 2011, at 3:19 AM, Mikkel Eide Eriksen wrote:
 I have a property on an object that would ideally return either its value or 
 nil, depending on the context it's being called from.
 
 Can you tell us the name of the object and the property, and describe the 
 different contexts? I'm having trouble imagining such a requirement.
 
 I could do this with multiple selectors, but was wondering if there was a 
 cleaner way of determining how it is being called.
 
 It seems to me a property that can return multiple values isn't really a 
 property. It's either a method you pass a parameter to (to specify context 
 -- which of course won't work for bindings), or it's multiple properties 
 (i.e., multiple selectors -- what's not clean about that?).

There is certainly a design problem here. Why would two different callers 
expect a different result from a property, when one of those results is going 
to be nil?

If one of the callers is expecting nil returned, why bother calling the 
property?

Some idea of the code would be useful.

Joanna

--
Joanna Carter
Carter Consulting

___

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: context-aware bindings

2011-02-27 Thread Joanna Carter
Le 27 févr. 2011 à 15:25, Mikkel Eide Eriksen a écrit :

 It would only return nil in some cases. I'm working on some Gedcom - Core 
 Data code. All objects in Gedcom have a tag identifier. One such object is 
 an Event, with the generic tag EVEN. There are multiple subtypes of Event, 
 such as BIRT (birth), DEAT (death), CONF (confirmation), etc.
 
 An Event can also have a type, which in the case of generic EVENs is 
 something for which no specific tag exists. So:
 
 Event with type Birth should become:
 1 BIRT
 2 DATE ...
 2 PLAC ...
 
 generic Event with some type should become:
 1 EVEN
 2 TYPE Event Type
 2 DATE ...
 2 PLAC ...
 
 My current implementation of the type getter on the Event object checks to 
 see if the type is one of the known tags (Birth, etc), and returns nil so as 
 to avoid redundant data:
 
 1 BIRT
 2 TYPE Birth
 2 DATE ...
 2 PLAC ...
 
 I think I'll probably use a displayType property for bindings, and the 
 internal type property for writing out to Gedcom. Another option would be to 
 subclass Event into all the different types, but that seems overkill.

If you are displaying the event's tag, then all you need is to return the 
appropriate string; the event getter can check what to return.

But, if you are transforming to/from an event from/to something else that 
should contain the tag value, then what about using a variation of the Visitor 
design pattern?

Are you creating something from the event, or an event from something else? Can 
you let us see an idea of the two classes involved?

Joanna

--
Joanna Carter
Carter Consulting

___

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


Performing the selector from a stored IMP

2011-02-11 Thread Joanna Carter
Hi folks

I want to store a method pointer in a dictionary, recover it and call it from 
elsewhere in code.

So, I have code like this to store the method pointer:

{
  IMP anIMP = [anObject methodForSelector:@selector( myMethod: )];

  [myDictionary setObject:anIMP forKey:myKey];
}

… and then, elsewhere, I want to recover the IMP from the dictionary and invoke 
the selector on the self object that is held in the IMP.

Or have I misunderstood what IMPs do?

In C#, a delegate knows about the this, upon which the method will be called, 
within itself and can simply be called without having to go through any 
gymnastics to get the target object. Isn't this what IMPs do?

TIA

Joanna

--
Joanna Carter
Carter Consulting

___

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: Performing the selector from a stored IMP

2011-02-11 Thread Joanna Carter
Hi Jerry

 You've misunderstood what an IMP *is*.

Heheheh, I thought as much :-)

 If you want to store a method, you could probably wrap that the pointer value 
 of an IMP as an NSValue.  Read NSValue.  Or, for persistent storage, store 
 the method name you get from NSStringFromSelector(), then retrieve it with 
 NSSelectorFromString().  Use the latter technique sparingly because the 
 compiler cannot warn you about undefined methods, etc. - think JavaScript.

(Fortunately, I don't know anything much about JavaScript, so hopefully that's 
less confusing)

Anyway, from what you are saying, it would appear that NSSelectorFromString() 
would still need the target object in order to perform the selector, so that is 
just as useless :-)

Whilst waiting for replies I have been busy rationalising things out and have 
come to the solution of declaring a MyDelegates protocol with the three 
delegate methods on it, implementing the protocol on the class, upon which I 
want to call the methods, and storing idMyDelegates references in the 
dictionary.

This ensures that only a valid object, which implements the three delegates can 
be added to my static dictionary wrapper class and that that the wrapper class 
returns a valid (typesafe) instance with the three delegates available.

I really am going to have to do some more reading to find out if and when I 
might want to use an IMP.

Thank you

Joanna

--
Joanna Carter
Carter Consulting

___

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: Performing the selector from a stored IMP

2011-02-11 Thread Joanna Carter
Hi Matt

 Consider NSInvocation... m.

Hmmm, nice!

My only objection to using it in the circumstances I have is that it is a lot 
more code to setup than the idea of a protocol with three methods, implemented 
by the target class.

However, I am indebted to you for pointing out this class and shall remember it 
for future use. IMO, this is truly the next best thing to a delegate (as it is 
known in C#).

Joanna

--
Joanna Carter
Carter Consulting

___

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: Performing the selector from a stored IMP

2011-02-11 Thread Joanna Carter
Hi Matt

 But consider NSUndoManager. What its +prepareWithInvocationTarget:+ does is 
 almost exactly what you describe: you give it a target and send it a method 
 call, a method call that NSUndoManager itself cannot respond to. Instead of 
 complaining, it freeze-dries that method call and its parameters and the 
 target into an NSInvocation and puts it on the Undo stack. (This is the only 
 place where it differs from what you said; you said a dictionary.) When you 
 later say undo to the NSUndoManager, it pops that NSInvocation off the 
 stack, un-freeze-dries it, and calls it. So NSUndoManager has a completely 
 general way of freeze-drying *any* method call into an NSInvocation, on the 
 spot! It isn't doing this by magic; it's using Objective-C's wonderful 
 runtime. And so can you. m.

I would totally agree that it is a phenomenally powerful concept, giving just 
the kind of functionality I was originally looking for, as a replacement for 
method pointers. I will be using it as soon as I find a need that warrants it.

But, in my current code, I realise now that it was a lot easier to simply take 
the protocol/method approach.

In addition to pointing me to NSInvocation, you have lifted the mist from my 
eyes as to how NSUndoManager can work.

Once again, many thanks.

Joanna

--
Joanna Carter
Carter Consulting

___

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


NSViewWidthSizable causing problems?

2011-02-03 Thread Joanna Carter
Hi folks

I am trying to create a multi-tab NSTabView window, whose tab contents are only 
created when the tab is clicked on.

I have set the resizing on the tab view, in IB, to follow the size of the main 
form.

I have created another view, to be inserted into the NSTabViewItem, in a 
separate NIB and am trying to get it to resize as the parent form does.

- (void) tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem 
*)tabViewItem
{
  int tabViewItemIdentifier = [tabView indexOfTabViewItem:tabViewItem];
  
  switch (tabViewItemIdentifier)
  {
case 0:

  if (!myViewController)
  {
myViewController = [[MyViewController alloc] initWithNibName:@MyView 
bundle:nil];

[tabViewItem.view addSubview:[myViewController view]];

[tabViewItem.view setAutoresizesSubviews:YES];

[myViewController.view setAutoresizesSubviews:YES];

NSUInteger resizingMask = NSViewHeightSizable | NSViewWidthSizable;

[myViewController.view setAutoresizingMask:resizingMask];

NSRect frame = [tabViewItem.view bounds];

[myViewController.view setFrame:frame];
  }
…
}

The problem I have is that specifying NSViewWidthSizable as part of the 
resizing mask means that the parent form can no longer resize.

Have I missed something simple?

Joanna

--
Joanna Carter
Carter Consulting

___

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: NSViewWidthSizable causing problems? [Solved]

2011-02-03 Thread Joanna Carter
Hi folks

 The problem I have is that specifying NSViewWidthSizable as part of the 
 resizing mask means that the parent form can no longer resize.
 
 Have I missed something simple?

As it happens, this was simply due to the fact that something in the NIB file 
had gotten screwed up.

Once I recreated the NIB from scratch, everything worked as expected.

I have come across this kind of problem, where the NIB seems to get corrupted 
or something, before. Is it a well known problem?

Joanna

--
Joanna Carter
Carter Consulting

___

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: Binding an objects Enabled to a button in IB

2010-08-31 Thread Joanna Carter
Hi Jerry

 Le 30 août 2010 à 13:26, co...@wamundson.eu a écrit :
 
 Can this binding be done … completely in the nib file (in IB)?
 
 The answer is yes because the controller Joanna refers to may be an 
 NSObjectController from the Library in IB.
 
 Because the Bind to popup in Interface Builder's Inspector ▸ Bindings only 
 shows the controller objects to which controls are typically bound, you 
 cannot bind the Enabled binding of a text field directly to, say, the state 
 of a button in Interface Builder.  But sometimes Apple leaves little hooks 
 for the other 20% of us to do it Our Way.  Drop in an NSObjectController, 
 and bind the text field's Enabled binding instead to the object controller 
 with Controller Key = content.  Then, bind the Value binding of the button 
 to the same object controller with same Controller Key = content.  Voila.

Eeeuuuwww!!!

It might work but is it really code as we know it Jim? ;-)

This kind of application design is too reminiscent of environments like Delphi 
and VS, where people are encouraged to write all their business logic in the 
form class. At least, in Cocoa, we have the encouragement to use controller 
classes.

Surely, if you already have a controller for the form, it's not really that 
much effort to add an outlet property to the class and bind to that.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Binding an objects Enabled to a button in IB

2010-08-31 Thread Joanna Carter
Hi Mikael

 Joanna: do you mean that by applying Jerry's method, we put parts of the
 Controller's duty into the View?

Essentially, yes. The primary design idea behind MVC is that there should be 
absolutely no business logic in the View; the View should provide a means of 
interacting with the Controller and reflect the state of the Controller, 
nothing more.

To that end, it is a relatively simple matter to add a boolean property to the 
controller class, then the IB designer will be able to see that property and 
you can connect an enabling button and the edits to that property.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Binding an objects Enabled to a button in IB

2010-08-30 Thread Joanna Carter
Le 30 août 2010 à 13:26, co...@wamundson.eu a écrit :

 Can the following be done completely in the nib file (in IB)?
 
 I have a form field whos fields are bound to various attributes of an
 object (the object Person has attributes as firstName, lastName, etc.). In
 my view I would like lock these fields, prohibiting them from being
 changed, i.e. I'd like to be able to toggle the forms' Enabled-binding
 between YES and NO. For this I'd like to use a simple button named Lock.
 
 Can this binding be done in IB or do I need to add this functionality
 programatically?

The usual way to handle this would be to have a simple boolean property on the 
controller class and, assuming the Lock button is a two-state button, to bind 
the State property of the Lock button and the Enabled property of anything 
else to that boolean property, thus when the button's State is true, the other 
controls will be enabled.

Joanna

--
Joanna Carter
Carter Consulting

___

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: calling a function in one class from another

2010-08-05 Thread Joanna Carter
Hi Geoffrey

 If I have a class 'Foo' (containing the function 'Wabble'), which loads
 another class 'Bar', is it possible a function within 'Bar' to execute the
 'Wabble' function within the calling class 'Foo'?

Your first problem is that you are talking about classes without thinking about 
instances of those classes (objects).

Am I to take it that 'Wabble' is the method that creates and shows the view?

What you also need to consider is how you are going to get the address book 
data into the editing view. The easier way is to connect the controls on the 
form to properties of an object, using the bindings mechanism provided by Cocoa.

You need something like this:

@interface DataClass : NSObject
{
  // fields to hold data
}

@property NSString *name;

@property NSString *addressLine1;

…

- (void) showView;

@end

@implementation 

- (void) showView
{
  DataViewController *controller = [[DataViewController alloc] 
initWithData:self];

  ...
}

@end


@interface DataViewController : NSObject
{
  @private
DataClass *dataProvider;
}

- (DataViewController *) initWithData:(DataClass *)data;

…

@end

@implementation DataViewController

- (DataViewController *) initWithData:(DataClass *)data
{
  self = [super init…];

  if (self)
  {
dataProvider = data;
  }

  return self;
}

@end

Then you can bind the controls from the view to the properties of the DataClass 
instance that are available on the dataProvider field in the DataViewController 
class.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Using NSFetchRequest to fetch NSManagedObject subclasses

2010-07-11 Thread Joanna Carter
Hi Sean

I tried this and found that most of its functionality is already present in 
Xcode.

Also, the Autocustomize Entity Classes script doeszn't work in later versions 
of Xcode.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Using NSFetchRequest to fetch NSManagedObject subclasses

2010-07-10 Thread Joanna Carter
Hi Matt

 Wow, thank you so much.  I have no idea how I missed the Class column in 
 the xcdatamodel's UI.  From what I saw, none of the tutorials mentioned doing 
 this either.  Maybe I was reading the newbie stuff where they didn't get into 
 fun stuff like that.

I'm not sure why you would need to put a different name into the Class column 
of the modeller. Common practice is to simply name the entities as you would 
have them be in code.

e.g.

Customer
  [attributes]
  name: String
  address: String
  …

Invoice
  [attributes]
  date: Date
  …
  total: Decimal
  [relationships]
  customer: Customer
  lines: InvoiceLine

InvoiceLine
  [attributes]
  quantity: Integer16
  total: Decimal
  [relationships]
  product: Product

Product
  [attributes]
  code: String
  descriptive: String
  unitPrice: Decimal

The class for each entity will automatically be set to the same name as the 
entity. Then all you have to do is to select those entities in the designer and 
select File|New File… menu item to generate the Managed Object Classes for the 
entities.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Using NSFetchRequest to fetch NSManagedObject subclasses

2010-07-10 Thread Joanna Carter
Hi Matt

 After using this technique, I did have one more question related to automated 
 class generation.  Xcode automatically tried to add the class files to the 
 AppName.xcdatamodeld directory.  My initial assumption was that this was only 
 because I had it selected in the source list when I attempted to add the 
 class files, so I selected a new destination of the Classes folder where all 
 other classes are stored.

When you use the File|New File…|Managed Object Class route to create classes 
you get a dialog that asks you where to save the generated files. This usually 
defaults to saving the files, on disk, to the main project directory, but 
putting the files in the virtual Models folder in the project manager.

Personally, I tend to start every project by creating my own, preferred, folder 
hierarchy on disk, then changing the project manager folders to point to those 
folders.

Although you can, in theory, leave all the files, on disk, in the main project 
folder and simply work with project folders, which are only really logical 
groupings, I tend to use the following folder structure on disk (others may do 
it differently):

ProjectName
  Models
  Classes
  Resources
English.lproj
French.lproj
…

I then move the files, generated when the project was created, to those 
directories, except for the ProjectName-Info.plist and ProjectName_Prefix.pch 
files, which I leave in the root directory.

This will cause the files and folders to turn a delicate shade of red :-) First 
of all, select the Models folder, press Cmd-I and change the path of the 
project folder to point to that on disk. Then do the same to the other folders 
and files until the project knows where to find everything.

Needless to say, there is more than one way to tackle this folder management 
and others may have their own opinions.

Joanna

--
Joanna Carter
Carter Consulting

___

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: KVO oddity (or am I *really* idiot ?)

2010-06-09 Thread Joanna Carter
Hi Vincent

 Thanks Kyle. As I said (privately) to Graham...

No you didn't. I got that message with the list in the CC field. :-)

Joanna

--
Joanna Carter
Carter Consulting

___

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: Cross XIB references?

2010-06-06 Thread Joanna Carter
Le 6 juin 2010 à 09:12, Jean-François Brouillet a écrit :

 A few years ago when Spring came out in Java land, I had an Aha moment when
 I realised that it was just about creating singletons all over the place 
 (Spring
 calls them beans) without the benefit of a nifty editor, and remember 
 saying to
 myself, Gosh, here we go again, competition is catching up with Apple with a 
 10
 years delay. They've just reinvented NIB files

NIB (or XIB) files are not singletons, or do I misinterpret what you are trying 
to say?

Joanna

--
Joanna Carter
Carter Consulting

___

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: Managed Object Context Reference

2010-06-01 Thread Joanna Carter
Le 1 juin 2010 à 06:53, Quincey Morris a écrit :

 You've created another scenario by making your view need the managed object 
 context (probably during 'drawRect:' at least?).…

Richard, this really points to an abuse of the MVC design pattern :-)

If you look at some of the Cocoa controls, like NSTableView for example, you 
will see that there is also an NSTableViewDelegate protocol, with methods like 
-tableView:willDisplayCell:forTableColumn:row:, which have to be implemented, 
usually, in a Controller class.

This ensures separation between the View and the Model it is meant to be 
representing. Using a delegate to obtain the data required for drawing a View 
means that the view has no need to know anything about the Model, the MOC or 
anything else, apart from the fact that something, somewhere, will supply the 
necessary information in response to a request via the delegate methods.

So, for something simple like a CircleView, should also require a protocol like 
this:

@protocol CircleViewDelegate

- (void) circleView:(CircleView *)circleView willDisplayCircle:(Circle 
**)circle;

@end

This then is called from within the CircleView like this:

- (void) someMethod; // in CircleView that needs the Circle coordinates
{
 Circle *circle = nil;

 [delegate circleView:self willDisplayCircle:circle];

 // draw circle using circle.location and circle.radius.
}

Then the delegate method, in the Controller:

- (void) circleView:(CircleView *)circleView willDisplayCircle:(Circle **)circle
{
 NSPoint circleLocation = … get location from object in MOC

 CGFloat circleradius = … get radius from object in MOC

 circle = [Circle circleAtLocation:circleLocation withRadiusOf:circleRadius];
}

Of course, this is a very simplistic (and not very well written) example, but 
you should get the idea that any code that talks to the MOC can be located in 
the Controller and accessed from the View via a delegate.

Joanna

--
Joanna Carter
Carter Consulting
--
Joanna Carter
Carter Consulting

___

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


Writing an NNTP client

2010-06-01 Thread Joanna Carter
Can anyone tell me if Cocoa provides a ready made framework for accessing NNTP, 
or is there a third-party framework that is recommended?

Joanna

--
Joanna Carter
Carter Consulting

___

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: Managed Object Context Reference

2010-05-31 Thread Joanna Carter
Hi Richard

 Apple's documentation seems to indicate that if you have an object in a nib 
 with a managed object context outlet, that you can somehow set the outlet.
 
 The Core Data Programming Guide states If you are setting the reference to 
 the context in a nib file, make sure the appropriate outlet or binding is set 
 correctly.
 
 http://developer.apple.com/mac/library/documentation/cocoa/conceptual/CoreData/Articles/cdTroubleshooting.html#//apple_ref/doc/uid/TP40002320-SW23
 
 How do you set a managed object context outlet in a nib file?

The typical scenario when you would connect something in a NIB file to a MOC is 
when you set the binding for the MOC of an NSArrayController or 
NSObjectController, etc.

Normally, I find it easier to write read-only, lazy instantiating, properties 
for the Persistent Store Coordinator, MOM and MOC, in the Controller., Then it 
is easy to bind any objects in the NIB, that require the MOC.

 Suppose that I have a custom view with a managed object context outlet and I 
 want to bind it or set it in the nib to the managed object context of the 
 File's Owner which is a subclass of NSPersistantDoument. How would you do 
 this?

It would be unusual to have a MOC directly connected to a View. They are 
normally connected to array or object controllers in the controller.

To connect something like an array controller, simply go to the Bindings sheet 
of the Inspector for the array controller, expand the Managed Object Context 
section and bind to the File's Owner and the name of the MOC property that you 
declared, as the Model Key Path.

Joanna

--
Joanna Carter
Carter Consulting

___

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: subclass overwriting superclass ivar

2010-05-26 Thread Joanna Carter
Hi Jonathan

 A subclass ivar is apparently overwriting a super class ivar.
 When an instance of MGS_B sets stderrData the super class ivar tempFilePath 
 gets overwritten.

I'm not sure what you mean here by overwrite.

@interface Base : NSObject
{
  @private
  int i;
}

@end

@interface Sub : Base
{
  @private
  int i;
}

@end

This code demonstrates what I would understand by overwriting, and it fails to 
compile. Although, it should be possible to redeclare such private ivars, it 
certainly is in C# and Delphi.

Joanna

--
Joanna Carter
Carter Consulting

___

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: subclass overwriting superclass ivar

2010-05-26 Thread Joanna Carter
Hi Sean

 I think you are confusing some similar-sounding words: override and
 overwrite (and there's also overload).  By overwrite, he means the
 memory occupied by one ivar is being unexpectedly written to when
 writing to a different ivar.

Yes, I gathered that as the discussion evolved. Overwriting is just something 
that I would never imagine a decent compiler allowing, which is why I tended to 
avoid being thought of as stupid to assume it was possible.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Regarding MVC design pattern

2010-05-20 Thread Joanna Carter
Le 20 mai 2010 à 13:24, Alexander Spohr a écrit :

 Why not just using myFoo without the self-?
 To make it visible that you talk to an ivar?

Yes, because the ivar is synthesised, addressing myFoo would send the release 
message to the property, which is not recommended.

Apparently, self-myFoo is capable of reaching the synthesised ivar.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Regarding MVC design pattern

2010-05-19 Thread Joanna Carter
Hi Guys

Can I just suggest something more?

 @interface Controller : NSObject {
IBOutlet UIButton *beginButton;
IBOutlet UIButton *endButton;
IBOutlet UILabel *nameLabel;
IBOutlet UILabel *numberLabel;
MyModel *myModel;
 }
 
 @property (nonatomic, retain) IBOutlet MyModel *myModel;
 
 /* some methods defined here as well */
 @end


From what I have read, and from good object-oriented practice, it would be 
better to use Objective-C 2.0 properties for all your outlets. iVars really 
should be @private, if you are using them, but don't forget that properties 
will synthesize, not only the accessors, but the ivars as well.
@interface Controller : NSObject
{
}

@property IBOutlet UIButton *beginButton;

@property IBOutlet UIButton *endButton;

@property IBOutlet UILabel *nameLabel;

@property IBOutlet UILabel *numberLabel;


@property MyModel *myModel;

/* some methods defined here as well */

@end

@implementation Controller

@synthesize beginButton;

@synthesize endButton;

@synthesize nameLabel;

@synthesize numberLabel;

@synthesize myModel;

@end

Any outlets for controls (top level objects) in the Nib should be released in 
the dealloc method only for OS X apps but not for iPhone apps. Setting the 
properties to nil will ensure that the synthesized setter will be called, which 
releases the previous contents of the synthesized ivar before setting it to nil.

- (void) dealloc
{
  beginButton = nil;

  endButton = nil;

  nameLabel = nil;

  numberLabel = nil;

  myModel = nil;

  [super dealloc];
}

Joanna

--
Joanna Carter
Carter Consulting

___

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: Regarding MVC design pattern

2010-05-19 Thread Joanna Carter
Hi Sherm

 If you set the ivars directly, as above, the synthesized setters will
 NOT be called. For that to happen, you need to use dot-syntax, like
 this:

You are absolutely right. I keep slipping back to previous languages :-)

Joanna

--
Joanna Carter
Carter Consulting

___

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/iPad: Desktop wallpaper can't be set.

2010-05-19 Thread Joanna Carter
 Correct, this is not possible in the current API. I would recommend filing a 
 bug report asking for this capability.

There's an interesting post on MacRumours, that might save you the trouble of 
filing that report.

http://www.macrumors.com/2010/05/18/apple-releases-iphone-os-4-beta-4-and-sdk-to-developers/

Joanna

--
Joanna Carter
Carter Consulting

___

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: Why I can't see my localized nib?

2010-05-18 Thread Joanna Carter
Hi Gustavo

 I dunno about that.. I was just selecting French from the pop up list when I 
 clicked the Make localizable button under info of the xib file, and then I 
 put in the first position of the lang list under system preferences French 
 language... re build re run and nothing, I logout and login again the system 
 and all was in french (finder) but still when running I was seeing the 
 English version of the xib. I tried also for another lang sk_SK (for 
 Slovakia) and nothing also... 
 
 
 Its wird, Im not localizing  my app yet, but Im getting ready for the task 
 which will come very soonso thats why its urgent for me to at least make 
 a test app localized.

Do you fancy sending me your test app? I run OS X in French all the time and 
often localise from the default English to French.

Don't forget to clean out the Build folder before zipping and sending it :-)

Joanna

--
Joanna Carter
Carter Consulting

___

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: Regarding MVC design pattern

2010-05-18 Thread Joanna Carter
Hi Sal

 However, I declare a NSDictionary instance variable in my model object. This
 NSDictionary instance
 store some data I need. And I will create this NSDictionary instance by
 invoking:
 [NSDictionary dictionaryWithObjects:names forKeys:keys]
 Both names and keys are string NSArray. I will invoke this method inside my
 init method of my model
 object.

And this is where your problem could well be. If you create anything in the 
init method, and it references the Nib, then the connections won't be correctly 
made.

Try moving your dictionary creation code to the awakeFromNib method. This is 
called after the Nib is fully loaded.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Why I can't see my localized nib?

2010-05-18 Thread Joanna Carter
Hi Gustavo

 Ok I tried again with French lang, run it and din't work, clean target and 
 rerun and it worked.. Now I made for sk_SK lang same procedure as before, 
 (changing the lang of the system) and it didn't work. I took the codes from 
 the ISO docs and when I open the xib of slovak lang it says 'slovensky so 
 the code its being detected.
 
 MMM now I wonder if I have the localization installed... 

If you can change the OS language to French and restart any of the Apple apps 
in French, then that doesn't sound likely.

Send me the project.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Why I can't see my localized nib?

2010-05-18 Thread Joanna Carter
Hi Gustavo

 Joanna hello. here is the app.

I cannot get the Slovak localisation to work either. But, then I read that the 
localisation is not included in Snow Leopard by default and I don't want to 
have to buy the licence for it.

Sorry about that.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Why I can't see my localized nib?

2010-05-18 Thread Joanna Carter
Hi Gustavo

 In this case.. is tehre anyway to let teh user choose what lang to use?.. I 
 mean if I localize my app, but the user has no localization either, how to 
 make the app run in a given language (i.e sk)?

The only way I can think of is to delete the other localizations from the 
bundle. Maybe someone else knows better :-)

Joanna

--
Joanna Carter
Carter Consulting

___

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: Why I can't see my localized nib?

2010-05-18 Thread Joanna Carter
Hi Frédéric

 You can launch the application with AppleLanguages in the arguments or in the 
 app defaults.
 
 See :
 
 http://www.cocoabuilder.com/archive/cocoa/3862-changing-language-at-runtime.html?q=applelanguages#3861
 
 and
 
 http://www.cocoabuilder.com/archive/search/1?q=applelanguagesl=cocoa


Noted. Thank you.

Joanna

--
Joanna Carter
Carter Consulting

___

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: NSTreeController and remove:

2010-05-17 Thread Joanna Carter
Hi Tony

 Ok, here is the magical answer as to why the remove: didn't work.  Nice 
 little warning in the Cocoa Bindings Programming topic:
 
 Warning: Providing the count key path to an NSTreeController instance 
 disables the add:,addChild:, remove:, removeChild:, orinsert: methods.
 
 My object implemented a method to retrieve the count and I set it in the 
 controller.What the warning doesn't mention, it also causes CanAdd and 
 CanRemove to always return no.  So, if anyone is having problems with binding 
 these methods to their buttons and they are disabled, this can also be a 
 reason why.


Thank you for one of those superb little gems that can save so much time. I 
have filed it away under one of those things to remember before starting to 
tear my hair out :-)

Joanna

--
Joanna Carter
Carter Consulting

___

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: TIPS : Using Add2Project to organize your projects more effectively.

2010-05-17 Thread Joanna Carter
Hi Bill

 Cocoa - Using Add to Project to Organize Your Projects More Effectively.

I had already found out how to use this trick of dragging folders from Finder 
to Xcode to organise my projects, but your screenshots revealed something I 
didn't know - that I could drag applications to the Finder toolbar!! Thanks.

Joanna

--
Joanna Carter
Carter Consulting

___

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] File coping application

2010-04-28 Thread Joanna Carter
Hi Arun

Le 28 avr. 2010 à 13:53, Arun a écrit :

 I was thinking of an application that can mount the iPhone as a drive with
 read/write access.
 Using this app i would have had an file system interface which is inline
 with finder and makes easy to use the device.

Try this :http://avatron.com/apps/air-sharing/

Joanna

--
Joanna Carter
Carter Consulting

___

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: why doesn't the compiler complain?

2010-04-27 Thread Joanna Carter
Hi Matt

 I see now, however, *why* the compiler is silent: it's because it weren't,
 it would be too chatty. I turned on -Wselector and got 114 warnings... :)

You too eh? Wow, was that a surprise - my tutorial project gave me 3679!!!

Joanna

--
Joanna Carter
Carter Consulting
___

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: Creating temporary NSManagedObjects

2010-04-27 Thread Joanna Carter
Hi Vincent

 There is a simple reason: the objects in the Managed object context get 
 represented on a third window, whose contents are drawn from an Entity mode 
 NSArrayController that prepares its contents automatically. If I add my 
 temporary object to the MOC, it automatically gets fetched and displayed in 
 that window the very moment it is inserted; that's what I wanted to avoid 
 because it is confusing and thus undesirable.

Which is why I use the dictionary approach. It allows me to represent the 
single object, with all its relationships fetched from the MOC, without 
affecting the display of any other array controllers.

I have a tutorial that uses this approach. Would it help if I sent it to you?

Joanna

--
Joanna Carter
Carter Consulting

___

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: Creating temporary NSManagedObjects

2010-04-26 Thread Joanna Carter
Hi Vincent

 I need to create a short-lived NSManagedObject; ideally, I'd want it not to 
 be inserted in the Core Data underlying framework, because I need it only 
 during the display of an auxiliary window, and I don't want it saved anyway. 
 I've tried a simple alloc, an alloc and init, but to no avail: It seems to 
 create only the proxy object. Is there a way to do that?


Do you really need an NSManagedObject?

Do you ever need to store instances of this particular class?

If not, why not just create a class that derives from NSObject, or even just 
use an NSDictionary?

Joanna

--
Joanna Carter
Carter Consulting
___

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: Creating temporary NSManagedObjects

2010-04-26 Thread Joanna Carter
Hi Vincent

 Yes. That NSObject holds some properties associated with a graphical layer. I 
 have a lot of them, that I classically save in order to be able to restore 
 the state of the application at launch. Now, to highlight a specific item on 
 a given layer, I create a temporary layer, that I destroy once the user has 
 identified the highlighted item. To keep the drawing code orthogonal, I have 
 to create that temporary NSObject I mentioned, which is needed by my 
 drawInContext: method. 

In that case, try this:

Create a category on NSManagedObject -

@interface NSManagedObject (ObjectAsDictionary)

- (NSDictionary *) objectAsDictionary;

@end

@implementation NSManagedObject (ObjectAsDictionary)

- (NSDictionary *) objectAsDictionary
{
  NSDictionary *dictionary = [NSMutableDictionary dictionary];
  
  NSEntityDescription* entityDescription = [self entity] ;

  for (NSPropertyDescription *propertyDescription in entityDescription)
  {
id propertyValue = [self valueForKey:[propertyDescription name]];

[dictionary setValue:propertyValue forKey:[propertyDescription name]];
  }
  
  return dictionary;
}

@end

Then simply call the following code on the original managed object when :

{
  // assume an NSDictionary *editingWord property declared in your controller 
class

  editingValues = [editingWord objectAsDictionary];

  // set object controller content to be editingValues

  ...
}

... then after the edits have been made, use the following code to update the 
object to be stored:

{
  //assume your object to be stored is called originalObject

  [originalObject setValuesForKeysWithDictionary:self.editingValues];

  ...
}

 I hope it is a bit clearer, despite my rusty English.


I speak French if that helps? :-)

Joanna

--
Joanna Carter
Carter Consulting

___

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: Creating temporary NSManagedObjects (PS)

2010-04-26 Thread Joanna Carter
Hi Jack

 Good question.  I believe a simple release/autorelease will do.

If the object has been created by inserting into the context, then it would 
have to be removed from the contrext.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Creating temporary NSManagedObjects (PS)

2010-04-26 Thread Joanna Carter
Hi Jack

 Right, but we were talking about passing in nil as the context when
 creating the object, so there's no context to remove it from.

That's interesting. I have never tried using a nil context. Something more to 
add to my knowledge repository :-)

Thank you

Joanna

--
Joanna Carter
Carter Consulting

___

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: Creating temporary NSManagedObjects

2010-04-26 Thread Joanna Carter
Hi Vincent

 It would! :) No kidding, I really do not understand what is your dictionary 
 for. You don't have to tell me in French, I hope my English is sufficient, 
 but could you briefly explain me (in five lines or so) what your category is 
 supposed to do?

La catégorie rajoute une méthode, à la classe NSManagedObject, qui renvoie 
toutes les propriétés et leurs valeurs dans un NSDictionary.

Pourquoi ? Parce que  un NSDictionary répondrai à la programmation KVC, telle 
que valueForKey ou setValue:forKey, juste comme il était  n'importe quel objet 
qui est connecté aux composants visuels en utilisant les liaisons (bindings) 
Cocoa.

Ça veut dire qu'on peut remplacer un NSManagedObject avec un NSDictionary, 
comme contenu d'un NSObjectController et tous marchera comme d'habitude.

Après l'édition des valeurs qui se trouvent dans le dictionnaire, on peut 
affecter les valeurs du dictionnaire vers un vrai object avec la méthode 
setValuesForKeysWithDictionary:

 Sorry for seeming obtuse (after all, that may be *really* how I am :)).

C'est assez difficile d'apprendre la programmation mais, s'il faut le faire 
dans une langue étrangère, ça c'est beaucoup plus difficile :-)

Si je m'étais trompé en traduction, n'hésites pas de m'avertir.

Joanna

--
Joanna Carter
Carter Consulting
___

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: Creating temporary NSManagedObjects

2010-04-26 Thread Joanna Carter
Hi Vincent

 nice, thanks a lot for talking some time explaining me this.

De rien.

 Your French is almost perfect, congratulations!; far superior to my own 
 English.

I am glad my lack of skill in technical French didn't get in the way :-)

Joanna

--
Joanna Carter
Carter Consulting

___

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: Creating temporary NSManagedObjects

2010-04-26 Thread Joanna Carter
Hi Quincey

 Notwithstanding the discussion in this thread so far, I don't quite 
 understand why you wouldn't do this the easy way: create a NSManagedObject in 
 your managed context, and delete it when you're done with it.


If you are editing a list of objects, using a NSTableView, then one reason why 
you might not want to create temporary objects in the main context is that 
those objects get displayed in the NSTableView, even though you might not want 
them to be visible until the editing is finished.

If you work with the trick of using a secondary context for editing, then you 
have to manage the copying of property values to/from the temporary object, 
including relationships, which have to be resolved from the original context.

Which is why I use a temporary dictionary, because it allows me to freely 
interact with the property values, including relationships, without the need to 
work with a secondary context, as well as not affecting any UI components that 
might be displaying the original list.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Creating temporary NSManagedObjects

2010-04-26 Thread Joanna Carter
Hi Quincey

 Yes, I remember the discussion about this scenario: when the managed object 
 represents a *future* permanent resident of the Core Data object graph. 
 Outside of a discussion of that scenario, I wouldn't necessarily call this a 
 temporary object.
 
 In the OP's scenario, there is no suggestion he was trying to keep his 
 temporary object out of the user interface. (In fact, his later clarification 
 suggests the opposite.) That's why I was asking if the simple create 
 it/delete it pattern wouldn't work.

I would agree, in that case, it could be equally valid. The only other benefit 
I have found in using a dictionary, with the category, is the simplicity of 
copying the state to and from the original object.

But, I wouldn't make a doctrine out of it :-)

Joanna

--
Joanna Carter
Carter Consulting

___

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: NSManagedObject, retain count and dealloc:

2010-04-26 Thread Joanna Carter
Hi Vincent

 I am unable to see a NSManagedObject go through the dealloc: method, even 
 after its removal from the MOC. It seems these objects are created after a 
 initWithEntity:insertIntoMOC: with an initial retain count of 2, and, of 
 course, it is impossible to make the retain count (by honest means) drop 
 below 2. Is this normal expected behavior?

The docs state that the MOC retains a reference to the MO until it is saved, so 
with the reference you are holding, that should make 2.

Joanna

--
Joanna Carter
Carter Consulting

___

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: setValue:forKey: and to-many relationships

2010-04-23 Thread Joanna Carter
Hi Christian

 I would like to step in here for a related question. Is there any way to get 
 rid of the compiler warnings if you use the generated accessors without 
 writing a subclass of NSManagedObject and adding properties and method 
 declarations?

Normally, generating a subclass also generates a category that declares the 
necessary methods:

@interface One (CoreDataGeneratedAccessors)
- (void)addManyObject:(NSManagedObject *)value;
- (void)removeManyObject:(NSManagedObject *)value;
- (void)addMany:(NSSet *)value;
- (void)removeMany:(NSSet *)value;

@end

If you didn't want to generate a specific class, you can always write a 
category on NSManagedObject:

@interface NSManagedObject (CoreDataGeneratedAccessors)
- (void)addManyObject:(NSManagedObject *)value;
- (void)removeManyObject:(NSManagedObject *)value;
- (void)addMany:(NSSet *)value;
- (void)removeMany:(NSSet *)value;

@end

Joanna

--
Joanna Carter
Carter Consulting
___

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: updating property of fetched object and refetching

2010-04-20 Thread Joanna Carter
Hi Olivier

 I create an object and insert it into the context, then i update a couple
 properties.
 
 Later I i do a fetch request with a predicate on the property i updated
 after the insertion. If i do this fetch right after the update of the
 property (using the accessors provided by coreData), then the fetch does not
 find the object I created. If i wait longer then it finds it.
 
 Is there a way to commit the change so that the fetch will find the object
 without saving. I don't want to save every time i update a property.

Since a fetch request returns fully saved objects, I can't see how you can 
expect it to see unsaved changes.

Think about it in database terms - you wouldn't expect a SQL statement to 
return anything other than committed rows. Essentially Core Data is an OO 
database and, unless you write your own caching, I doubt if you are going to 
get what you want without saving.

Joanna

--
Joanna Carter
Carter Consulting

___

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: MVC question about updating the Model

2010-04-16 Thread Joanna Carter
Hi Matt

 I have multiple resource objects that are represented in an
 NSOutlineView. These resource objects can be updated by their own
 triggered timer or potentially on demand by the user via the View (a
 button is clicked in the UI).
 
 At first, I thought that the resource object should have the
 capability to update itself. Therefore, the resource has a method like
 so:
 
 [resource update];
 
 If the resource's timer fires, it calls it's update method like so:
 
 [self update];
 
 If the resource update button is clicked by the user, the selected
 resource item is updated by the NSWindowController with:
 
 [resource update];
 
 This is where I'm having difficulty determining what should be
 standard practice. Would it be better to post a notification that
 indicates the resource should update itself? Or is it good enough to
 leave it as is?
 
 One other approach I've considered is whether the Model should have
 the ability to update itself at all. Should the controller be
 responsible for updating the resource always?
 
 It seems that either approach is viable, but which is better?

When designing an OO system, the guiding principle should always be 
Responsibility Driven Design.

In other words, what determines when the resource should be updated? If the 
resource can be responsible for keeping itself updated, then that is where the 
update method belongs and it can be called from an internal timer method, if 
that is the only way to detect the new state.

If the resource doesn't know how to update itself, then the update method can 
be called from any other code, including a controller.

My guess is that you have a resource that know how to update its state and that 
change in state is observed by the controller/UI. However, you also want to be 
able to provide a user with an update button, in case they want to ensure that 
the state is up to date between automatic refreshes. In which case, the 
controller handles the action of the button and calls the update method on the 
resource.

Joanna

--
Joanna Carter
Carter Consulting

___

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 does an NSTextField know that it's value has changed?

2010-04-13 Thread Joanna Carter
Hi Brian

 The problem seems to be that I'm changing the value of the textfield 
 programatically, but some part isn't getting the message. 

And this is your problem. If you change the value of a text field by typing 
into it, then that value is sent to the property on the model, but this is not 
true for programatic changes. The MVC pattern and bindings work when you change 
the value in the model programatically, not the text field. As long as the 
property in the model is KVO compliant, the text field will follow the changes 
to the property.

Joanna

--
Joanna Carter
Carter Consulting

___

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 does an NSTextField know that it's value has changed?

2010-04-13 Thread Joanna Carter
Hi Brian

 And this is your problem. If you change the value of a text field by typing 
 into it, then that value is sent to the property on the model, but this is 
 not true for programatic changes. The MVC pattern and bindings work when you 
 change the value in the model programatically, not the text field. As long as 
 the property in the model is KVO compliant, the text field will follow the 
 changes to the property.

In other words, connect both your up and down buttons to actions on the 
controller, in which you set the value of the property to which the text field 
is bound.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Data managment

2010-04-12 Thread Joanna Carter
 I'm trying to find the best approach to data storage with a cocoa application.
 I've got my application working and saving document specific data to a file, 
 but I also need a larger data file of persistent data, that shouldn't be 
 duplicated. I'm considering imbedding an SQLite database into my application, 
 but wasn't sure if I could use core data some how.

Since Core Data uses SQLite, why not go that route?

Joanna

--
Joanna Carter
Carter Consulting

___

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: Data managment

2010-04-12 Thread Joanna Carter
Hi Billy

 Is it possible to get core data data models to save differently, one for a 
 document save which for example might be an XML format, and one into the 
 applications bundle as an SQLite file?
 
 That way when a document is saved the main database won't be duplicated, just 
 the document specific data.

You can have multiple Core Data stores, each with a different storage mechanism.

Joanna

--
Joanna Carter
Carter Consulting

___

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: MainMenu.nib won't load

2010-04-10 Thread Joanna Carter
Hi Ulf

 Could we have done something wrong using the MainMenu.nib? Are there any 
 known issues with Snowy and NSDocumentController?
 
 If you want to check the Barcody Resources, just grab the multi-lingual app 
 from here:
 
 http://www.dsd.net/prod/mac/barcody.php?lan=enpmode=download

We really can't tell too much from the built app bundle - the nibs are compiled 
and cannot be opened and the source files for the controller are not there.

The app runs here - Macbook Pro OS X 10.6.3 French. British English and (US) 
English

Joanna

--
Joanna Carter
Carter Consulting

___

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


Using a SOAP Web Service from iPhone

2010-04-09 Thread Joanna Carter
Hi folks

Well, I've just spent the last few days, getting to grips with consuming a web 
service.

I though I would try things out in an OS X app first, then move to the iPhone, 
which is the end target.

So, I decided to use WSMakeStubs on the WSDL - it did a reasonable job, apart 
from one or two minot bugs and niggles. Eventually, I got a test app working to 
prove that I could read the service.

Then I thought I would move the app to iPhone, only to discover that the 
classes generated by WSStubMaker would not compile and that I would have to 
find another way to create the stub classes for an iPhone app.

Can I ask what is considered the best route to go?

Joanna

--
Joanna Carter
Carter Consulting

___

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: Bindings ivars

2010-04-05 Thread Joanna Carter

Le 5 avr. 2010 à 19:53, Charles Burnstagger a écrit :

 Why, after I have connected a control in my nib. window using bindings can I 
 no longer access it from code?
 
 After connecting a checkbox control using bindings, when my window controller 
 loads, that control's ivar shows up as nil.

A binding is a mechanism whereby a property of something like a control can be 
linked to a property of another object. It allows the observing object to be 
updated when the value of the observed property changes. It is not meant to 
be a means of talking to an object in a NIB.

If you need access to an object in the N IB, then you need to add an IBOutlet 
to the controller class and hook it up to the appropriate object in the NIB.

If you want to use the observer mechanism of bindings, then you cannot use an 
ivar in the observed class, you need a KVO compliant property instead, 
otherwise the notifications of change will not get sent to the observing object.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Two text fields, one outlet?

2010-04-04 Thread Joanna Carter
Hi Jenny

 Is it possible to link multiple NSTextFields to one outlet? I have
 three views - one of A items, one of B items, and one of both A and B
 items. So the text boxes in the A view also exists in the AB view,
 and the value needs to be able to appear in both, though not at the
 same time. I have a method that calculates values and sets the textbox
 values (or label values, same concept) using an outlet, but I don't
 want it to set 2 outlets, I want it to just set 1.
 
 Is this possible using outlets or bindings??
 
 Or is there a way I can place two NSViews into one NSView so there's
 only one copy of everything?

You can certainly bind any number of UI objects to a single property of an 
object.

Specifying an IBOutlet is only necessary if you want to create a connection and 
can only be connected to one thing at a time. Simply specify a property and 
bind the NSTextFields to that.

@interface MyClass
{

}

@property (nonatomic, retain) NSString *aTextValue;

@end

@implementation MyClass

@synthesize aTextValue;

@end

With the later versions of the compiler, you don't even need to specify an 
ivar, it will be created for you.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Best way to selectively show objects in a tree controller/outlineview

2010-03-31 Thread Joanna Carter
Hi Tony

 Based on a user preference, I want to be able to selectively show/not show 
 items contained in the tree controller by an outline view. For example, 
 suppose the tree controller has these items: A,B,C,D,D,E,F,G,H.  The outline 
 view will normally display all of the items.  Now suppose the user sets a 
 preferences that he/she doesn't want to show item(s) 'D'.  The outline view 
 should now display: A,B,C,E,F,G,H. 
 
 One obvious method(albeit brute force) is to rebuild the tree controller list 
 and redisplay it.  For what I want to do, this is way too expensive of an 
 operation.  In addition, the user can toggle back and forth the preference.  
 There doesn't seem to be an obvious way to tell the outline controller, skip 
 or hide this item.

One obvious way is, not to work with the tree controller but, to work with the 
tree itself. If the data is retrieved from a Core Data store, you can mark each 
item with a Valid property and use a predicate on the fetch.

Joanna

--
Joanna Carter
Carter Consulting

___

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 to catch modal window appearance?

2010-03-27 Thread Joanna Carter
Hi Alexander

 I tried to achieve the next effect: some automatic process should be started 
 on the modal window appearance on screen. A popup panel with progress 
 indicator appears, etc. My idea was not to initiate such process from the 
 calling code (where modal window is called from), but do it asynchronously, 
 as soon as the modal window will appear on the screen.

I'm not sure if you realise how the MVC design pattern works. A window is just 
a view on data, it has no state or logic at all.

 Of course, I've solved the problem by calling this process from the calling 
 code just before [NSApp runModalForWindow:] call. But it is not pretty 
 correct from the OOP philosophy point of view, at least as I understand it.

Every window is managed by a Controller and it is from this Controller that 
you can run any process you want, as well as creating and showing a window.

There is nothing wrong with calling a process from a controller class; you can 
set to run in a secondary thread and display a progress indicator.

 What is over my mind is why Apple split main loop and modal loop. I see none 
 of benefits but headaches.. There may be only one modal window at a time, 
 isn't it?

I think you are used to Windows programming. Cocoa modal sheets are modal to 
the owning form, not the whole app.

Joanna

--
Joanna Carter
Carter Consulting

___

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 doesn't save toMany relations please HELP :S

2010-03-25 Thread Joanna Carter
Hi Quincey

 This is not a good approach to MVC programming. You're trying to take short 
 cuts by updating your data model by remote control -- that is, by 
 programming NSArrayControllers instead of your data model. That's a bit like 
 trying to disassemble a precision watch using a crowbar and a hammer. :)

Heheh :-)

 Here's the rule of thumb I use: any line of code that refers to an array 
 controller is a *last resort*, not a preferred solution, to be used only when 
 there is no alternative.

How about, with a Core Data app, getting the content of an NSObjectController 
after editing?
{
 ...

 Customer *editedCustomer = [self.customerController content];

 ...
}

Joanna

--
Joanna Carter
Carter Consulting
___

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: Prevent NSWindow from hiding with app

2010-03-25 Thread Joanna Carter
Hi Fabian

 Is it possible to prevent a window from hiding when NSApp is hidden, so it
 always stays on screen? I only want the menu bar to go away.

Simply uncheck the Hide on Deactivate option for the window in IB.

Joanna

--
Joanna Carter
Carter Consulting

___

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 doesn't save toMany relations please HELP :S

2010-03-25 Thread Joanna Carter
Hi Quincey

 Well, I'm probably missing your point, but why wouldn't you get the Core Data 
 object directly and leave the NSObjectController out of it? After editing, 
 the object has already been updated.

Yes, you're missing the point :-)

My rubbish example was to demonstrate that you might want to access the object 
that is the content of an NSObjectController, as that my be the only way to 
determine which object is being edited.

Or am I missing your point? :-)

Joanna

--
Joanna Carter
Carter Consulting

___

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 doesn't save toMany relations please HELP :S

2010-03-25 Thread Joanna Carter
Hi Quincey

 Or, I'd prefer to give my File's Owner object a currentObject property and 
 bind the object controller to that.

I can understand that. It's beginning to look like you're more anal about OO 
design than I am ;-)

 Or, if circumstances preclude either of these approaches, I'd probably invoke 
 the last resort clause and ask the object controller for its content.

Ah, anal, up to a point :-)

 * It doesn't really change the answer, but that's not how I use object 
 controllers anyway. Instead of switching the content object, I just bind the 
 object controller to the data model (or to, say, a window controller that 
 provide a suitable set of properties based on the data model), and use a 
 model key when binding a UI element to the object controller.

Gotcha.

As it is, I really like my new discovery of copying the object to a 
NSMutableDictionary. It avoids having to create a secondary MOC and manage the 
messing around with finding and copying objectIDs for relationships, as well as 
allowing Undo to work nicely.

But, this dictionary method does mean populating the dictionary before editing 
and then shoving it into the object controller, then doing the reverse after 
editing.

Unless, I bind the controls directly to the dictionary?

Joanna

--
Joanna Carter
Carter Consulting

___

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 to hide new objects in a NSTableView?

2010-03-24 Thread Joanna Carter
Hi folks

Well, I have found a very simple way to avoid secondary MOCs or new objects 
appearing in the table view, whilst adding new objects.

My example is to use a modal sheet to allow the editing of a new object.

In the NIB for the modal sheet, add a NSObjectController, set it to Class mode, 
leave the Class Name at NSMutableDictionary and check Prepares Content.

In the controller class, add the following method to respond to the + button 
being pressed on the main form:

- (IBAction) create:(id)sender
{
  if (panel == nil)
  {
NSBundle *bundle = [NSBundle bundleForClass:[self class]];

NSNib *nib = [[[NSNib alloc] initWithNibNamed:@NewWordSheet 
bundle:bundle] autorelease];

BOOL success = [nib instantiateNibWithOwner:self topLevelObjects:nil];

if (!success)
{
  // should present error
  return;
}
  }
  else
  {
[self.panel makeFirstResponder:self.panel];

[self.wordController setContent:[NSMutableDictionary dictionary]];
  }

  [NSApp beginSheet:self.panel
 modalForWindow:self.parentWindow
  modalDelegate:self
 didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo:NULL];
}

Then, add the sheet closure delegate:

- (void) sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode 
contextInfo:(void *)contextInfo
{
  // we are only interested in doing something with the edited word
  // if the Save button was pressed
  if (returnCode == NSOKButton)
  {
[[self.managedObjectContext undoManager] beginUndoGrouping];

@try
{
  [[self.managedObjectContext undoManager] setActionName:@Add Word];
  
  Word *newWord = [NSEntityDescription 
insertNewObjectForEntityForName:@Word

inManagedObjectContext:self.managedObjectContext];
  
  NSDictionary *editedValues = [wordController content];
  
  for (NSString *key in editedValues)
  {
id value = [editedValues valueForKey:key];

[newWord setValue:value forKey:key];
  }
  
  NSError *error;
  
  if (![self.managedObjectContext save:error])
  {
NSLog(@Could not save new Word);
  }
}
@finally
{
  [[self.managedObjectContext undoManager] endUndoGrouping];
}

[sourceListController fetch:nil];
  }

  // close the dialog
  [sheet orderOut:self];

  // clear temporary object from controller
  [wordController setContent:nil];
}

Of course, this doesn't account for 1..N relationships, but it certainly works 
with N..1.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Refreshing NSArrayController after Undo/Redo

2010-03-23 Thread Joanna Carter
Hi folks

Now which one of you here hasn't read the docs fully and properly before asking 
a question?  :-)

Jerry Krinock dropped me a private line and suggested that the title for this 
thread should have been  How to register Undo when syncing MOCs with 
mergeChangesFromContextDidSaveNotification:. Thank you Jerry, that was just 
the nudge I needed.

Regardless of any messing around with secondary MOCs in separate windows and 
controllers, the simple truth of the matter is:

The default implementation of Undo in a MOC only undoes *uncommitted* changes 
to that MOC. Once you've called save: on the MOC there is no (automatic) going 
back.

But, now I know what does and doesn't happen, I have a cunning plan...

I'll let you know when I get it sorted.

Joanna

--
Joanna Carter
Carter Consulting

___

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


How to hide new objects in a NSTableView?

2010-03-23 Thread Joanna Carter
Hi folks

So, now I have worked out how to manage Undo and Redo for adding and removing 
new managed objects from an NSTableView, fed by an NSArrayController.

In the end, I had to use the same MOC for the new object sheet that I used 
for the main browsing form.

Now, the only thing left, that is slightly distracting, is that you can see the 
new object in the underlying table view, whilst it is being populated in the 
sheet.

I have tried adding a predicate to the array controller objectID.isTemporaryID 
== NO but it doesn't seem to get respected.

Any other ideas please?

Joanna

--
Joanna Carter
Carter Consulting

___

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 to hide new objects in a NSTableView?

2010-03-23 Thread Joanna Carter
Hi Kyle

 This isn't the recommended approach. It's recommended that you use a
 scratch MOC for your data entry sheet, so that the object insertion is
 seen as an atomic operation in the main MOC.

Yes, I would agree and that is, in fact, what I was doing but that then meant 
that I couldn't Undo the addition or editing of an object as an atomic 
operation.

From my research, the mergeChangesFromContextDidSaveNotification: method, that 
has to be called on the main MOC, doesn't play nicely with the MOC's undo 
manager.

So, I am now left thinking the only way around this is to insert an editing 
object in a secondary MOC, then, upon saving, insert a second object in the 
main MOC, copy the properties over from the editing object to the object in the 
main MOC, before rolling back the inserted object in the secondary MOC.

Wow!!! that is a whole load of hassle.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Merge changes between two Managed Object Contexts

2010-03-22 Thread Joanna Carter
Hi Austin

 Thank you Joanna, that was very helpful.  So, from your experience, 
 mergeChangesFromContextDidSaveNotification: will not pick up adding a new 
 object, just editing an existing one?  It seems like the real pain point is 
 having to re-create the new object in the second managedObjectContext and 
 copy all it's properties.

My tutorial is meant to demonstrate several different techniques, to give 
people an idea of what is available, especially if they are coming from a 
different programming language.

I included the routine for copying the object contents, possibly because I too 
came across Tim Isted's blog and, at the time, thought that was what was 
necessary to ensure that object properties were populated from the correct MOC.

However, I have just checked and found that you can, indeed, use the same 
methodology for both editing and adding a new object. Here is some revised code 
that you can use in place of the sheetDidEnd:returnCode:contextInfo: method in 
the tutorial.

- (void) sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode 
contextInfo:(void *)contextInfo
{
  // we are only interested in doing something with the edited word
  // if the Save button was pressed
  if (returnCode == NSOKButton)
  {
NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];

[dnc addObserverForName:NSManagedObjectContextDidSaveNotification
 object:managedObjectContext
  queue:nil
 usingBlock:^(NSNotification *saveNotification)
 {
   [[sourceListController managedObjectContext] 
mergeChangesFromContextDidSaveNotification:saveNotification];

   [sourceListController fetch:nil];
 }];

NSError *error;

if (![managedObjectContext save:error])
{
  NSLog(@Error saving edited Word);
}

[dnc removeObserver:self
   name:NSManagedObjectContextDidSaveNotification
 object:managedObjectContext];
  }
  else
  {
// Cancel button pressed -
// rollback any changes to the temporary context
[managedObjectContext rollback];
  }
  
  // close the dialog
  [sheet orderOut:self];
  
  // clear temporary object from controller
  [wordController setContent:nil];
}

The only real difference here is that, within the callback block, you need to 
call [sourceListController fetch:nil] to ensure that the original browsing list 
is not just refreshed but that the sort descriptors are honoured to include the 
new object.

Regards

Joanna

--
Joanna Carter
Carter Consulting

___

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


Refreshing NSArrayController after Undo/Redo

2010-03-22 Thread Joanna Carter
Hi folks

I understand how to manage the NSUndoManager on a NSManagedObjectContext, but 
getting the visuals to react is proving elusive.

Example
===
Core Data application (not document-based)

Main form contains an NSTableView connected to an NSArrayController in Entity 
mode.

I can add and remove objects and the NSTableView is correctly updated when Undo 
and Redo are called on the MOC.

An Edit... button opens editing form.

Editing Form Controller hold a reference to the original MOC and creates 
secondary MOC. The controller handles NSManagedObjectContextDidSaveNotification 
to merge changes on the original context.

Changes are being saved back to the original MOC and the NSTableView is being 
updated correctly when the editing form closes.

The only thing that I can't get to work is to update the NSTableView when I 
call Undo after the saved edit.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Refreshing NSArrayController after Undo/Redo

2010-03-22 Thread Joanna Carter
OK, I've done some more digging and found where the problem appears to be 
happening.

The Undo isn't happening because there is nothing to undo!!!

The situation is happening because I am using a secondary MOC for editing.

Once the edited object is saved to the secondary MOC, I reconcile the main MOC 
by calling mergeChangesFromContextDidSaveNotification: in response to the save 
notification.

However, if I check the undoManager on the main MOC, the canUndo message 
returns NO, both before and after the merge.

So, is there any way to detect that a change has happened on the main MOC, when 
the change has only been saved to the secondary MOC and merged to the main one?

Joanna

--
Joanna Carter
Carter Consulting
___

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: Merge changes between two Managed Object Contexts

2010-03-21 Thread Joanna Carter
Hi Austin

 I've got a Core Data project and I have a window controlled by an 
 NSWindowController that is used to add or edit an NSManagedObject.  I wanted 
 to create a separate Managed Object Context in the NSWindowController so that 
 the changes made to the object aren't seen by the UI below and so I can just 
 throw away the changes if the user clicks Cancel.  If the user clicks 
 Save' I wanted to merge the changes from the temporary MOC to the main MOC 
 being used by the rest of the application.
 
 What is the best way to merge those changes back to the main MOC?  Do I have 
 to recreate the object in the main MOC as is done in this example: 
 http://www.timisted.net/blog/archive/multiple-managed-object-contexts-with-core-data?
   Or, can I use - (void)refreshObject:(NSManagedObject *)object 
 mergeChanges:(BOOL)flag to merge the changes?  If i use 
 refreshObject:mergeChanges, can I pass it my NSManagedObject from the 
 temporary MOC and do I need to call save: on the temporary MOC before doing 
 that?

I have created a basic tutorial that demonstrates both adding and editing and 
object. AFAICT, you need to take two different approaches. The tutorial is 
available at http://www.richplum.co.uk/magazine/dg201001.pdf

Joanna

--
Joanna Carter
Carter Consulting

___

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


  1   2   >