Re: NIB doesn't link to objects

2010-11-13 Thread Andy Lee
On Nov 13, 2010, at 8:50 PM, Quincey Morris wrote:
> 2. You didn't really hook up the outlets in IB. Only you can check that, and 
> you have, but it's worth keeping in mind that it's easy to talk yourself into 
> believing that you've done it right when you haven't. (Speaking from painful 
> personal experience here.)

This mistake might be especially easy to make in this case if you really have 
similarly named outlets like tileButton1, tileButton2, etc.  Also if you copy 
and paste objects in IB, the copies replicate some of the connections of the 
original, and it's easy to forget this.  And if you rename outlets in your code 
using find and replace, the nib file won't update accordingly -- you should use 
refactoring instead.

Right-click your view in IB.  Are there any yellow warning triangles?

> 3. You actually have 2 instances of the class, and you're seeing the 
> misbehaving code executing in the wrong one -- the one that didn't get its 
> outlets established -- while the one that had the correct outlets has been 
> leaked or deallocated.

This is a common bug especially with view instances, and the one I was going to 
suggest next.  Sometimes people's nib have a view in the view hierarchy and, 
because they misunderstand nibs, they also create a separate standalone 
instance of the view in the nib.

How many times is your view's init method being called?  You can try printing 
self in both your init method and awakeFromNib.  If you have some classes with 
similar names, you might want to print [self class] too, to make sure you're 
instantiating the class you think you are.

When "impossible" things happen in simple code, I like to check *all* my 
assumptions, even the ones that can't possibly be wrong.

If none of the above helps, please don't yell or be snippy with me.  Remember 
you're the one asking for help, and we are sincerely trying to give it.

--Andy

___

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: Ghost outlet

2010-11-13 Thread Jerry Krinock

On 2010 Nov 13, at 09:04, gMail.com wrote:

> I quit, relaunched Xcode and IB, reopened the project, verified that there
> is no "abc" string on all of my code, many times.

You didn't mention the action which *should* remove that outlet, which is to 
click in the menu File > Read Class Files… or Reload All Class Files…

> So, I have looked within the designable.nib file within the MainNib.nib file
> and I have found this trace of this ghost
> 
> 
> 
> Can I delete these lines?

Well, first of all I wonder if you really mean the "nib" file instead of the 
more modern "xib".

As to deleting it, the answer is that this is not recommended, and I wouldn't 
do it without very careful examination of the xml.  I would  just ignore these 
ghost outlets and maybe they'll go away by themselves, maybe in your next 
update of Xcode.

Or, ask on xcode-us...@lists.apple.com, a more appropriate forum for this 
question.

___

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: Strange result with NSView's convertPoint:toView:

2010-11-13 Thread Ken Ferry
Hi Eric,

I don't entirely follow this question, but I suspect I know what you're 
missing: the frame of a view is its location in the coordinate system of its 
superview. Its bounds is its location in its own coordinate system. 

So this is okay

[superview convertRect:[view frame]...

And this is okay:

[view convertRect:[view bounds]...

But treating a view's frame as if it's in the coordinate system of itself is 
not alright. 

-Ken

On Nov 12, 2010, at 8:47 AM, Eric Gorr  wrote:

> I have changed the contentView of my NSWindow to be a NSView which return YES 
> for isFlipped.
> 
> If I place a NSButton in the contentView of a window, I can do the following:
> 
>NSRectr = [view frame];
>NSPointorigin;
> 
>origin = [view convertPoint:NSZeroPoint toView:[[view window] 
> contentView]];
> 
> The r.origin will say something like ( 20, 14 ) and, when I convert the 
> point, I get back what one would expect ( 20, 14 ).
> 
> The problem comes when I try to place a NSImageView in that same content view.
> 
> The r.origin will say something like ( 20, 14 ), but, when I convert the 
> point, I get back ( 20, 78 ). (The NSImageView is 64x64)
> 
> I am confused as to why this would be happening. Anyone have an idea?
> 
> I should be able to easily provide some sample code if that is required in 
> this case.
> 
> 
> 
> ___
> 
> 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/kenferry%40gmail.com
> 
> This email sent to kenfe...@gmail.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Problem saving in a Core Data application

2010-11-13 Thread Jerry Krinock

On 2010 Nov 13, at 15:23, Kyle Sluder wrote:

> The only common race condition I can think of off the top of my head is the 
> delay performing that NSController does.

Maybe that's it.  I just remember that when I first started using Core Data, my 
first instinct was to uncheck those "Optional" boxes when a property was 
required.  I frequently got "save" errors as described by Paul until I checked 
them back on.  I vaguely remember debugging one case and found that Core Data 
was doing its validation before my business logic received the notification 
which triggered setting the non-optional property, or something like that.  On 
another occasion, I tried implementing some of Core Data's built-in validation 
methods, assuming that they would give me some hooks to recover from the 
validation errors, but was disappointed to find that, instead, it just 
displayed these obnoxious error dialogs.

> I've avoided Core Data for anything more than toy apps (our apps had all 
> moved off Core Data by the time I showed up).

Looks like we're having another Dump On Core Data Weekend.  Let's try and clean 
this up before Monday morning, eh  :)

___

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: More stoopid questions...

2010-11-13 Thread Kyle Sluder
On Nov 13, 2010, at 5:35 PM, William Squires  wrote:

> 1) Why is it, when you create a new Cocoa Application (or even some iOS 
> Applications) in Xcode, does it generate AppDelegate (.h and .m) 
> files, instead of calling them Controller (.h and .m)? Since these 
> tie to the .xib - according to MVC paradigm - shouldn't it be a 
> controller object for the view(s) in the xib (a controller that just so 
> happens to be a delegate)? After all, it's not called the MVD 
> (Model-View-Delegate) paradigm! Yeah, I realize this is just a stylistic 
> thing, but hey, it gives me an excuse to ask this question! Likewise, when 
> you open the xib in IB, you see a proxy object called  App 
> Delegate. Again, shouldn't this be  Controller to maintain the 
> 'feeling' that you're designing according to the MVC paradigm?

The controller layer is a very thick layer, containing many kinds of objects. 
The purpose of the class created for you is to act as the (NS|UI)Application's 
delegate, and it conforms to that protocol accordingly.

Every controller object in your app could be described as a "MyAppController." 
"MyAppApplicationDelegate" names the class with the specific role of its 
instances.

The thing in the nib isn't a placeholder. That's the actual app delegate 
instance.

> 
> 2) How come some NSControls have both a delegate API and a data source API? 
> I'm thinking mostly of NSTableView and its ilk, such as UITabView. Why not 
> just have one delegate API that has the data source 'messages' in that 
> implemented protocol?

Because it can be handy to have different objects fulfill each of these roles. 
You might have a strictly data-related controller act as the data source, but 
have the window controller fulfill the delegate role.

--Kyle Sluder___

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: NIB doesn't link to objects

2010-11-13 Thread Quincey Morris
On Nov 13, 2010, at 15:20, Charlie Dickman wrote:

> Notably, I executed using GDB and watched it get to the method and fail to 
> assign values.

FWIW, there are perhaps 3 "ordinary" causes of this sort of thing:

1. You try to do this at a point in time when the outlets haven't been 
established yet. This is the one Andy talked about. Although you already moved 
the code to 'awakeFromNib', it's worth trying to check *later* in your 
application's execution to see if the outlets are set eventually. If not, this 
probably wasn't your problem.

2. You didn't really hook up the outlets in IB. Only you can check that, and 
you have, but it's worth keeping in mind that it's easy to talk yourself into 
believing that you've done it right when you haven't. (Speaking from painful 
personal experience here.)

3. You actually have 2 instances of the class, and you're seeing the 
misbehaving code executing in the wrong one -- the one that didn't get its 
outlets established -- while the one that had the correct outlets has been 
leaked or deallocated.


___

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


More stoopid questions...

2010-11-13 Thread William Squires
1) Why is it, when you create a new Cocoa Application (or even some  
iOS Applications) in Xcode, does it generate AppDelegate  
(.h and .m) files, instead of calling them Controller (.h  
and .m)? Since these tie to the .xib - according to MVC  
paradigm - shouldn't it be a controller object for the view(s) in the  
xib (a controller that just so happens to be a delegate)? After all,  
it's not called the MVD (Model-View-Delegate) paradigm! Yeah, I  
realize this is just a stylistic thing, but hey, it gives me an  
excuse to ask this question! Likewise, when you open the xib in IB,  
you see a proxy object called  App Delegate. Again,  
shouldn't this be  Controller to maintain the 'feeling'  
that you're designing according to the MVC paradigm?


2) How come some NSControls have both a delegate API and a data  
source API? I'm thinking mostly of NSTableView and its ilk, such as  
UITabView. Why not just have one delegate API that has the data  
source 'messages' in that implemented protocol?


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Problem saving in a Core Data application

2010-11-13 Thread Kyle Sluder
On Nov 13, 2010, at 1:34 PM, Jerry Krinock  wrote:

> 
> On 2010 Nov 13, at 13:24, Paul Johnson wrote:
> 
>> So, what I understand is that there are some "race conditions" within Core 
>> Data that make it impossible to specify that a property be required and that 
>> it is necessary to include in one's code any checks for the presence of 
>> values.
> 
> No; the race conditions are in the interaction between the business logic, 
> bindings, etc. in your design and Core Data.

The only common race condition I can think of off the top of my head is the 
delay performing that NSController does. Is there more that I'm not aware of? 
I've avoided Core Data for anything more than toy apps (our apps had all moved 
off Core Data by the time I showed up).

--Kyle Sluder___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Problem saving in a Core Data application

2010-11-13 Thread Paul Johnson
Yes, I should have included my own program as it all has to work together.
Still, it makes the "Optional" switch rather useless, if you ask me. Perhaps
there is a way to introduce some synchronization that I'm not aware of.

On Sat, Nov 13, 2010 at 3:34 PM, Jerry Krinock  wrote:

>
> On 2010 Nov 13, at 13:24, Paul Johnson wrote:
>
> > So, what I understand is that there are some "race conditions" within
> Core Data that make it impossible to specify that a property be required and
> that it is necessary to include in one's code any checks for the presence of
> values.
>
> No; the race conditions are in the interaction between the business logic,
> bindings, etc. in your design and Core Data.
>
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Problem saving in a Core Data application

2010-11-13 Thread Jerry Krinock

On 2010 Nov 13, at 13:24, Paul Johnson wrote:

> So, what I understand is that there are some "race conditions" within Core 
> Data that make it impossible to specify that a property be required and that 
> it is necessary to include in one's code any checks for the presence of 
> values.

No; the race conditions are in the interaction between the business logic, 
bindings, etc. in your design and Core Data.

___

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


NSConnection memory leak when SSH Tunnelled connection

2010-11-13 Thread Mike Silva
I am using a socket-based NSConnection between machine.  Instead of a direct 
connection I use an SSH-tunnelled TCP connection for the NSConnection transport.

Basically I have a local NSConnection socket client that I connect to server 
localhost:59595 (for example).  At localhost:59595 is a SSH tunnelled 
connection to the remote machine.  On the remote machine there is an 
NSConnection server at port 6.

This works, except that every request sent across the NSConnection leaks some 
memory here:

   0 CoreFoundation _CFRuntimeCreateInstance
   1 CoreFoundation __CFArrayInit
   2 CoreFoundation -[__NSPlaceholderArray initWithCapacity:]
   3 CoreFoundation -[__NSPlaceholderArray init]
   4 Foundation -[NSConnection initWithReceivePort:sendPort:]
   5 Foundation +[NSConnection connectionWithReceivePort:sendPort:]
   6 Foundation -[NSConcretePortCoder connection]
   7 Foundation +[NSDistantObject newDistantObjectWithCoder:]
   8 Foundation -[NSConcretePortCoder decodeRetainedObject]
   9 Foundation _NSWalkData2
  10 Foundation -[NSConcretePortCoder decodeReturnValue:]
  11 Foundation -[NSConnection sendInvocation:internal:]
  12 Foundation -[NSDistantObject forwardInvocation:]
  13 CoreFoundation ___forwarding___
  14 CoreFoundation _CF_forwarding_prep_0


If I setup the SSH tunnel to use localhost:6 (i.e. so the local server and 
the remote server use the same port number) then the connection leaks no 
memory.  It seems that NSConnection has some knowledge or dependency on the 
actual server port vs. the port I'm having it connect to and this is causing a 
problem.

Has anyone ever done anything like this?  any ideas on how to eliminate this 
memory leak per request?

Thanks.

Mike



Statement of Confidentiality
The contents of this e-mail message and any attachments are confidential and 
are intended solely for the addressee. The information may also be legally 
privileged. This transmission is sent in trust, and the sole purpose of 
delivery to the intended recipient. If you have received this transmission in 
error, any use, reproduction or dissemination of this transmission is strictly 
prohibited. If you are not the intended recipient, please immediately notify 
the sender by reply e-mail or at 508.683.2500 and delete this message and its 
attachments, if any.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Problem saving in a Core Data application

2010-11-13 Thread Paul Johnson
Thank you, Jerry!

So, what I understand is that there are some "race conditions" within Core
Data that make it impossible to specify that a property be required and that
it is necessary to include in one's code any checks for the presence of
values. Now that's interesting. Seems like a deficiency to me. Thanks a lot
for this very important piece of information!

On Sat, Nov 13, 2010 at 2:31 PM, Jerry Krinock  wrote:

>
> On 2010 Nov 13, at 11:29, Paul Johnson wrote:
>
> > 
> Oh, that's good because this error message is much easier to deal with than
> the one in your original post.
>
> Apparently, in you data model you have un-checked the 'Optional' box for
> the property 'selectedType', and either the value has not been set, or, more
> likely, it's being set a few microseconds *after* Core Data checks for it
> and barfs, and the error is therefore a false alarm.
>
> My advice is:  Never un-check any of those 'optional' boxes in a data
> model.  Besides checking too early, these checkboxes, and other validation
> methods built into Core Data, present incomprehensible and embarrassing
> error dialogs like that.  They are OK for in-house work, but not for a
> finished product.  Instead, implement business logic and design your user
> interface so that it is not possible to enter invalid data.  In cases where
> you can't avoid validation, write your own code to detect and recover
> appropriately.
>
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Problem saving in a Core Data application

2010-11-13 Thread Jerry Krinock

On 2010 Nov 13, at 11:29, Paul Johnson wrote:

> http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: RTFDFromRange returns different data

2010-11-13 Thread Kyle Sluder
On Sat, Nov 13, 2010 at 11:02 AM, Keary Suska  wrote:
> On Nov 13, 2010, at 9:50 AM, Kyle Sluder wrote:
>
>> You really shouldn't be using NSKeyedArchiver for persisting data out
>> to disk, anyway. What happens if you try to load the data on an older
>> version of the OS?
>
> This statement as I understand it is contrary to the documentation, as well 
> as some implied API contracts with regards to data serialization, to whit: 
> file:///Developer/Documentation/DocSets/com.apple.adc.documentation.AppleSnowLeopard.CoreReference.docset/Contents/Resources/Documents/index.html#documentation/Cocoa/Conceptual/Archiving/Articles/compatibility.html%23//apple_ref/doc/uid/20001055-BCICFFGE
>
> Unless there is something else you are referring to...

It's really just annoying. Implementing keyed archiving in a way that
generates on-disk files that are backward-compatible is just as much
work as defining a neutral representation format and using that.

Using an actual, versioned file format is preferable for those times
when you really do need to break backward compatibility.

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Problem saving in a Core Data application

2010-11-13 Thread Paul Johnson
Repost (I had a spurious line in the previous one.):

Save and Save As always fails if I've deleted one or more row from the
tableview.

It's something incorrect or incomplete in my use of Core Data, I believe. I
have two Entities and there are two tableviews. In one tableview I select an
item and that selection causes the display of items in the second tableview.
When I have deleted a row in the second tableview I'm unable to do a save.
(The row(s) disappear but I can't save. I do get an error dialog window with
the message:  I also get the console message that I gave in my initial
post.)

I hope that explanation more clearly describes the problem I'm experiencing.

On Sat, Nov 13, 2010 at 12:50 PM, Jerry Krinock  wrote:

>
> On 2010 Nov 13, at 09:21, Paul Johnson wrote:
>
> > If there is more I need to state to define the problem, please tell me.
>
> State the steps for reproducing a successful save vs. the steps for
> reproducing an unsuccessful save.
>
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Problem saving in a Core Data application

2010-11-13 Thread Paul Johnson
Save and Save As always fails if I've deleted one or more row from the
tableview.

The document “Portfolio Set 1x” could not be saved as “Portfolio Set 1y”.
portfolio is a required value.

It's something incorrect or incomplete in my use of Core Data, I believe. I
have two Entities and there are two tableviews. In one tableview I select an
item and that selection causes the display of items in the second tableview.
When I have deleted a row in the second tableview I'm unable to do a save.
(The row(s) disappear but I can't save. I do get an error dialog window with
the message:  I also get the console message that I gave in my initial
post.)

I hope that explanation more clearly describes the problem I'm experiencing.

On Sat, Nov 13, 2010 at 12:50 PM, Jerry Krinock  wrote:

>
> On 2010 Nov 13, at 09:21, Paul Johnson wrote:
>
> > If there is more I need to state to define the problem, please tell me.
>
> State the steps for reproducing a successful save vs. the steps for
> reproducing an unsuccessful save.
>
>
___

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: RTFDFromRange returns different data

2010-11-13 Thread Keary Suska
On Nov 13, 2010, at 9:50 AM, Kyle Sluder wrote:

> You really shouldn't be using NSKeyedArchiver for persisting data out
> to disk, anyway. What happens if you try to load the data on an older
> version of the OS?

This statement as I understand it is contrary to the documentation, as well as 
some implied API contracts with regards to data serialization, to whit: 
file:///Developer/Documentation/DocSets/com.apple.adc.documentation.AppleSnowLeopard.CoreReference.docset/Contents/Resources/Documents/index.html#documentation/Cocoa/Conceptual/Archiving/Articles/compatibility.html%23//apple_ref/doc/uid/20001055-BCICFFGE

Unless there is something else you are referring to...

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Problem saving in a Core Data application

2010-11-13 Thread Jerry Krinock

On 2010 Nov 13, at 09:21, Paul Johnson wrote:

> If there is more I need to state to define the problem, please tell me.

State the steps for reproducing a successful save vs. the steps for reproducing 
an unsuccessful save.

___

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: RTFDFromRange returns different data

2010-11-13 Thread Kyle Sluder
On Sat, Nov 13, 2010 at 9:41 AM, gMail.com  wrote:
> Ok I will not use archiving to compare unarchived objects, but, how can I
> compare  the data saved on the disk with the current mTextMutableString?

Define some standard of comparison and write code to make that
comparison. I'd probably compare the text and the attribute ranges.

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Problem saving in a Core Data application

2010-11-13 Thread Paul Johnson
I'm getting the following error message when I try to Save after deleting
rows from a tableview:

*AppKit called
rmdir("/private/var/folders/FA/FAQBcfcBF9icyTATSBmeVE+++TI/TemporaryItems/(A
Document Being Saved By MyApp)"), it didn't return 0, and errno was set to
66.*


Do I need to implement a  method in my Array Controller to fix this
problem? The content of the tableview depends on the selection in another
tableview. If there is more I need to state to define the problem, please
tell me. This is my first use of Core Data so I'm still weak on
implementation skills.
*
*
___

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


Ghost outlet

2010-11-13 Thread gMail.com
Hi,
I had an
IBOutlet idabc;
in my MYObject class header file.
This outlet "abc" was properly displayed on the Inspector Connection panel
on IB, when I selected the blue cube "MyObject". Well.

Lately I removed the abc outlet from the header, recompiled, run, etc...
But on IB I still see that outlet, disconnected, but still there and "not"
grayed out. It is black and selectable/linkable. The strange thing is that I
can see this outlet listed on the Inspector Connection panel even if I
select "any" other different blue cube, I mean, a different object whose
header does not contain that outlet name.

I quit, relaunched Xcode and IB, reopened the project, verified that there
is no "abc" string on all of my code, many times. Same problem. It looks
lika a case of a "ghost outlet", invading all the nib file...

So, I have looked within the designable.nib file within the MainNib.nib file
and I have found this trace of this ghost


[snip...]

id



abc
id



What's that? What should I do? Can I delete these lines?


Regards
Leonardo


___

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: RTFDFromRange returns different data

2010-11-13 Thread Kyle Sluder
On Sat, Nov 13, 2010 at 8:46 AM, gMail.com  wrote:
> Martin,
> are you saying that "is not sure that if I do not change mTextMutableString,
> and I call archivedDataWithRootObject several times, e.g. with one second
> interval, the stringData could be different? I hope no.

This is exactly what he is saying.

>
> I need to compare the data saved on the disk with the current
> mTextMutableString. Do you know any better way?

Either don't use archiving or compare the *unarchived* strings.

You really shouldn't be using NSKeyedArchiver for persisting data out
to disk, anyway. What happens if you try to load the data on an older
version of the OS?

--Kyle Sluder
___

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: RTFDFromRange returns different data

2010-11-13 Thread gMail.com
Martin,
are you saying that "is not sure that if I do not change mTextMutableString,
and I call archivedDataWithRootObject several times, e.g. with one second
interval, the stringData could be different? I hope no.

I need to compare the data saved on the disk with the current
mTextMutableString. Do you know any better way?

Regards
Leonardo

> Da: Martin Wierschin 
> Data: Fri, 12 Nov 2010 15:34:16 -0800
> A: "gMail.com" 
> Cc: Cocoa Dev List 
> Oggetto: Re: RTFDFromRange returns different data
> 
>> I workedaround the problem archiving the data directly from the
>> attributedString this way:
>> 
>> NSData* stringData = [NSKeyedArchiver
>> archivedDataWithRootObject:mTextMutableString];
> 
> That's not guaranteed to always give you the same NSData either. Maybe
> it works now for your small test case, but given more complex inputs,
> an OSX update, or any other number of little thing you have no control
> over, the data could change.
> 
>> And I think there should always be a way to get the "same" out-data,
>> given the same "in-variables".
> 
> That's not really how archiving is designed. The whole point is that
> you don't (and shouldn't) care about the archived data. As Glenn
> mentioned, the only thing you can be sure of is that you will restore
> the same content upon unarchiving.
> 
> ~Martin
> 


___

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: Numbers and mutable sets and retain counts, oh my!

2010-11-13 Thread Ken Thomases
On Nov 13, 2010, at 8:57 AM, William Squires wrote:

> Let's say I have some sample code that looks like:
> 
> -(NSMutableSet *)allOddNumbersExcept5Set
> {
> NSMutableSet *results = [[NSMutableSet alloc] initWithCapacity:1];
> 
> for (int i=1; i<=10; i+=2)
>  {
>  if (i != 5)
>{
>NSString *testNumber = [NSString stringWithFormat:"%d", i];
>// testNumber should now be an autoreleased NSString
>[results addObject:testNumber];
>}
>  }
> return results;
> }

You should use NSNumbers to represent numbers as objects.

You are leaking the set.  By the naming conventions, a caller of 
-allOddNumbersExcept5Set does not receive an ownership responsibility.  That 
leaves this method with the responsibility of discharging the ownership 
responsibility by releasing the set.  You'd do that by sending it -autorelease, 
since you want it to live long enough to reach the caller.


> 1) Do mutable containers (NSMutableArray, NSMutableDictionary, NSMutableSet) 
> always send the 'retain' message to objects added with the 'addObject:' 
> message?

Yes, but you shouldn't care.  What you care about is whether your code handles 
its responsibilities properly.  The collection classes are in charge of 
handling their responsibilities properly, and you should just assume that they 
do.

It is documented that they extend the life of the contained objects for as long 
as they are contained.

(And this is irrespective of their mutability.)

> 2) When you retrieve the results from the collection, does the object 
> reference you get back have the same retain count as the one in the 
> container? (i.e. if I add an object to an NSMutableArray (held in an 
> @property) in one method, and retrieve it in another, will I get a retain 
> count of 1 or 2?)

You _really_ don't care about retain counts.  Don't pay any attention to them.  
They will only mislead and confuse you.

Also, this juxtaposition of "the object reference you get back" vs. "the one in 
the container" is very confused. Object references don't have retain counts.  
Objects have retain counts.  You receive a pointer to the object that is in the 
container.  Since the object you receive a pointer to and the object in the 
container are one and the same, they have the same retain count.

> 3) Will the above code autorelease the 'testNumber' the second (and third, 
> and fourth...) times through the loop when it gets another autoreleased 
> NSString, or will it just re-use the existing one?

Each time through the loop, you are asking for a different string.  Whether 
that string is autoreleased or not is an open question (it might in fact be a 
singleton that lives for the life of the process).  What is definite is that 
you do not receive an ownership responsibility and so should not release it 
(unless you acquire an ownership responsibility by retaining it).  You can know 
this by the memory management rules and the naming conventions.

> 4) Would I be better off with:
> 
> -(NSMutableSet *)allOddNumbersExcept5Set
> {
> NSMutableSet *results = [[NSMutableSet alloc] initWithCapacity:1];
> 
> for (int i=1; i<=10; i+=2)
>  {
>  if (i != 5)
>{
>NSString *testNumber = [[NSString alloc] initWithFormat:@"%d", i];
>[results addObject:testNumber];
>[testNumber release];
>}
>  }
> return results;
> }
> 
> instead?

In this case, you do receive an ownership responsibility for the string 
(because you called +alloc), and you correctly discharge that responsibility by 
releasing it.  Both this and the previous code were correctly handling the 
memory management of the string.

This latter technique keeps the object out of the autorelease pool and so is 
slightly more efficient.  The efficiency gain is small enough that it doesn't 
matter when targeting Mac OS X, but Apple does recommend this approach in the 
more memory constrained environment of iOS apps.

The former technique is simpler (which counts for a lot), more convenient, and 
less prone to errors.  (For example, if you come back to a piece of code some 
time later and add in an early return path, it's easy to forget that you need 
to release the string.)

Regards,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Numbers and mutable sets and retain counts, oh my!

2010-11-13 Thread William Squires

Okay, so I'm getting a bit melodramatic...

Let's say I have some sample code that looks like:

-(NSMutableSet *)allOddNumbersExcept5Set
{
NSMutableSet *results = [[NSMutableSet alloc] initWithCapacity:1];

for (int i=1; i<=10; i+=2)
  {
  if (i != 5)
{
NSString *testNumber = [NSString stringWithFormat:"%d", i];
// testNumber should now be an autoreleased NSString
[results addObject:testNumber];
}
  }
return results;
}

Questions:
1) Do mutable containers (NSMutableArray, NSMutableDictionary,  
NSMutableSet) always send the 'retain' message to objects added with  
the 'addObject:' message?
2) When you retrieve the results from the collection, does the object  
reference you get back have the same retain count as the one in the  
container? (i.e. if I add an object to an NSMutableArray (held in an  
@property) in one method, and retrieve it in another, will I get a  
retain count of 1 or 2?)
3) Will the above code autorelease the 'testNumber' the second (and  
third, and fourth...) times through the loop when it gets another  
autoreleased NSString, or will it just re-use the existing one?

4) Would I be better off with:

-(NSMutableSet *)allOddNumbersExcept5Set
{
NSMutableSet *results = [[NSMutableSet alloc] initWithCapacity:1];

for (int i=1; i<=10; i+=2)
  {
  if (i != 5)
{
NSString *testNumber = [[NSString alloc] initWithFormat:@"%d", i];
[results addObject:testNumber];
[testNumber release];
}
  }
return results;
}

instead?

___

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] iterate through all the MKPolygons on my map view

2010-11-13 Thread Philip Vallone



Never mind - 

> overlay.title

does the trick - duh


On Nov 13, 2010, at 8:51 AM, Philip Vallone wrote:

> Hi,
> 
> I have added some MKPolygons to my map view. I want to loop through all my 
> polygons and delete the one that has a certain title. My question is; how do 
> I access the properties of the mkpolygon after the overlays have been added 
> to the map view.
> 
> This is how I am creating the MKPolygon 
> 
> MKPolygon* poly = [MKPolygon polygonWithCoordinates:points count:[myPoints 
> count]];
> poly.title = @"someName"; 
> self.strokeColor = [[UIColor redColor] colorWithAlphaComponent:0.5];
> [mapView addOverlay:poly];
> 
> In this loop, I am trying to access all the overlays, But I don't know how to 
> access the MKPolygon. How do I iterate through all the MKPolygons on my map 
> view?
> 
> for (id  overlay in mapView.overlays) {
>   
>  //todo access polygons title property
> 
> }
> 
> Thanks
> 
> Phil
> 
> 
> 
> 
> ___
> 
> 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/philip.vallone%40verizon.net
> 
> This email sent to philip.vall...@verizon.net

___

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: Default keyword selector type

2010-11-13 Thread Michael Hall

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


On Nov 13, 2010, at 6:41 AM, Ken Thomases wrote:

From :


∙ The default return and argument type for methods is id, not int  
as it is for functions. (However, the modifier unsigned when used  
without a following type always means unsigned int.)



Your links busted, redirects to a generic index.
But answers the question. I had seen return type at least sometimes  
defaulted but hadn't seen anywhere yet that argument type defaulted.


Thanks,

Mike Hallhallmike at att dot net
http://www195.pair.com/mik3hall
http://www195.pair.com/mik3hall/home.html
http://sourceforge.net/projects/macnative




-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)

iJwEAQECAAYFAkzel7kACgkQUvk/ZSaThTI5RAP/Us01/Fhj09Kp1f/axebLbS9R
RHNIeVyy0YimbuvfucfW2gFY1669iJQzjTnKXRW3vpLZb8Lj+FugpVW5t8xOX/39
xzKm0LbOF4b7LgL7pHBmXDWCV2ks3P6z/k+9yDEM0dcxApBFRNPadyxLhXI51kT9
yW+dg5IXRiWrYh6m9Vw=
=3Y4O
-END PGP SIGNATURE-
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


[iPhone] iterate through all the MKPolygons on my map view

2010-11-13 Thread Philip Vallone
Hi,

I have added some MKPolygons to my map view. I want to loop through all my 
polygons and delete the one that has a certain title. My question is; how do I 
access the properties of the mkpolygon after the overlays have been added to 
the map view.

This is how I am creating the MKPolygon 

MKPolygon* poly = [MKPolygon polygonWithCoordinates:points count:[myPoints 
count]];
poly.title = @"someName";   
self.strokeColor = [[UIColor redColor] colorWithAlphaComponent:0.5];
[mapView addOverlay:poly];

In this loop, I am trying to access all the overlays, But I don't know how to 
access the MKPolygon. How do I iterate through all the MKPolygons on my map 
view?

for (id  overlay in mapView.overlays) {  

  //todo access polygons title property

}

Thanks

Phil




___

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: Default keyword selector type

2010-11-13 Thread Ken Thomases
On Nov 10, 2010, at 9:17 PM, Michael Hall wrote:

> In looking at NSControl.h there is a NSKeyboardUI category definition with 
> the following instance method declaration
> 
> - -- (void)performClick:sender;
> 
> This category is defined a number of places and at least some of them 
> indicate that the type for sender should be (id)sender.
> How is it NSControl does nothing to indicate the type?
> Is id a default or is it somehow inherited in this situation?

From 
:

> • The default return and argument type for methods is id, not int as it is 
> for functions. (However, the modifier unsigned when used without a following 
> type always means unsigned int.)

Cheers,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Default keyword selector type

2010-11-13 Thread Michael Hall

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

In looking at NSControl.h there is a NSKeyboardUI category definition  
with the following instance method declaration


- -- (void)performClick:sender;

This category is defined a number of places and at least some of them  
indicate that the type for sender should be (id)sender.

How is it NSControl does nothing to indicate the type?
Is id a default or is it somehow inherited in this situation?

Mike Hallhallmike at att dot net
http://www195.pair.com/mik3hall
http://www195.pair.com/mik3hall/home.html
http://sourceforge.net/projects/macnative




-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)

iJwEAQECAAYFAkzbYEQACgkQUvk/ZSaThTI0dgP/eQQDjK36WJFsevQWWKnJS5tI
jUbdSOWQsU1j+fF1On5FBsYT6d3CLUlMIwAOQ2NLwBpWCdT+oLcXvf+BEnxbwIM1
c1zihDj62cQ9qlJ8YuRhhBDAzWDM5aHN53mHosR0fDB6Dzgvb55DNwJ+2RivyWA0
HwD/iUbB1Mzrjdk4FRg=
=OTdF
-END PGP SIGNATURE-
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com