Re: Outlets Not Connected In awakeFromNib

2011-03-08 Thread Matt Neuburg

On Mar 5, 2011, at 11:00 AM, Matt Neuburg wrote:

> On Fri, 04 Mar 2011 10:21:38 +0100, Andreas Grosam  
> said:
>> 
>> Unfortunately, due to the problem described previously, -awakeFromNib does 
>> not seem to be always appropriate for its intended use as described in the 
>> reference. There are also subtle differences between iOS and Mac OS.
>> 
> I'm not grasping where there can be any source of confusion here. 
> awakeFromNib is very simple: it is sent to an object after that object is 
> instantiated from a nib. That's straightforward and dependable and clear - 
> provided you know what a nib is, of course. The only "subtle difference" 
> between Mac OS X and iOS in this regard is that in iOS you are enjoined to 
> call super in your implementation. (There are some memory management 
> differences for objects instantiation from nibs between Mac OS X and iOS, but 
> that's a different matter.)

Okay, I was just wrong about this. On iOS, a UIViewController's awakeFromNib is 
called if the UIViewController is instantiated from a nib. But on Mac OS X, an 
NSViewController's awakeFromNib is called both if the NSViewController is 
instantiated from a nib and if a nib is loaded with that NSViewController 
(already in existence, obviously) as owner. That is a *profound* difference 
between the two. Sorry about that. m.

--
matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
Programming iOS 4! http://www.apeth.net/matt/default.html#iosbook
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.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


[MEET] CocoaHeads-NYC this Thursday -- please RSVP ASAP

2011-03-08 Thread Andy Lee
This month, Demitri Muna will be talking about how to use crash reports.

** IMPORTANT **

Starting this month, CocoaHeads-NYC will be meeting at Google. If you're 
coming, please RSVP literally like right this minute. Details are on the 
group's web page:



--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: How to wait for methods with result/completion blocks to finish?

2011-03-08 Thread Kyle Sluder
On Tue, Mar 8, 2011 at 6:13 PM, Kyle Sluder  wrote:
> Allowing the user to perform an action that requires some work isn't
> punishing the user. Now allowing them to cancel the operation without
> a good reason is punishing the user.
>

Of course, I meant to say "not allowing."

--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: How to wait for methods with result/completion blocks to finish?

2011-03-08 Thread Kyle Sluder
On Tue, Mar 8, 2011 at 5:45 PM, Matt Neuburg  wrote:
>> when they tap the "photo library"
>> button, we (as Kyle said) "throwing up a modal 'please wait' UI"
>
> Rather, I'd ask myself why the user is able to tap the photo library button 
> at all, if the photo library is not available. Don't make the user wrong by 
> providing a button and then punishing the user for tapping it. The button 
> should instead disappear, perhaps, or become inactive, or be replaced by a 
> spinning activity indicator. This is why we're maintaining state in the 
> controller; at any given moment, the interface should reflect the state of 
> things and the range of possible steps that the user can perform, and the 
> controller can consult its state to make it so. Even if you were to switch 
> temporarily to a modal view that just says Saving, that's better than having 
> a button that slaps the user's hand. That's my philosophy, anyway... But this 
> is no longer an architectural matter, but a sheer problem of philosophy and 
> how you want the user to feel about your app. m.

Allowing the user to perform an action that requires some work isn't
punishing the user. Now allowing them to cancel the operation without
a good reason is punishing the user.

There's no reason to load all the camera roll contents before the user
requests the camera roll. Let the user tap the button and throw up a
*non-modal* progress indicator that still allows them to back out of
the camera roll if they don't want to wait. If they haven't backed out
by the time the background loading is complete, take away the progress
indicator and show them the contents.

--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: How to wait for methods with result/completion blocks to finish?

2011-03-08 Thread Matt Neuburg

On Mar 8, 2011, at 1:44 PM, Chris Markle wrote:

> 1. Camera used to take picture or video (UIImagePickerController).
> Want to save image that was taken to the camera roll like happens with
> the camera app. That saving process starts when the user returns from
> the camera. If they then go to the Photo Library (again with
> UIImagePickerController), we don't let them do that until the image is
> fully saved since we want them to be able to see them image in the
> library that they just shot. So when they tap the "photo library"
> button, we (as Kyle said) "throwing up a modal 'please wait' UI" until
> the save to photo library function is completed, at which point we
> show the photo library.

I'll just use this as an example of how my own thinking runs when faced with 
this sort of situation. I confront the matter in terms of MVC:

* The actual saving of the image into the camera roll is model - this is your 
data. If you use UIImageWriteToSavedPhotosAlbum you can arrange to be notified 
asynchronously by setting the completionTarget, completionSelector, and 
optionally the contextInfo. The iOS 4 calls with completion handler are 
parallel.

* Doing something in response to the situation with the model is the job of the 
controller. So, to communicate between the two, I'd use a notification (from 
the model) just before we start to save and another notification (from the 
model) when the save is completed. The controller's job is then to maintain 
state; you could have an ivar, photoLibraryUnavailable, and set it to YES in 
response to the first notification and to NO in response to the second.

* The problem of what the user should see is view, but the controller is in 
charge of it. Presumably the controller will respond to the two notifications 
appropriately. The question is then what's appropriate. That's a design 
decision; many opinions are valid. Personally I would shun the notion you 
express:
 
> when they tap the "photo library"
> button, we (as Kyle said) "throwing up a modal 'please wait' UI"

Rather, I'd ask myself why the user is able to tap the photo library button at 
all, if the photo library is not available. Don't make the user wrong by 
providing a button and then punishing the user for tapping it. The button 
should instead disappear, perhaps, or become inactive, or be replaced by a 
spinning activity indicator. This is why we're maintaining state in the 
controller; at any given moment, the interface should reflect the state of 
things and the range of possible steps that the user can perform, and the 
controller can consult its state to make it so. Even if you were to switch 
temporarily to a modal view that just says Saving, that's better than having a 
button that slaps the user's hand. That's my philosophy, anyway... But this is 
no longer an architectural matter, but a sheer problem of philosophy and how 
you want the user to feel about your app. m.

--
matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
Programming iOS 4! http://www.apeth.net/matt/default.html#iosbook
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.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: Updating binding on release of slider (but update text field continuously)?

2011-03-08 Thread Rick Mann
Thanks, Quincy, I'll try that.

On Mar 8, 2011, at 17:30:45, Quincey Morris wrote:

> On Mar 8, 2011, at 17:18, Rick Mann wrote:
> 
>> I have a UI with an editable text field and a slider. I want the two to 
>> represent the same model property. I only want the model updated when the 
>> user exits the text field or lets go of the slider (which is what it does 
>> now).
>> 
>> However, I'd like it if the text field would update continuously as the 
>> slider is dragged.
>> 
>> I don't think it's possible to do this with bindings, is it?
> 
> Not exactly. To get the UI behavior you want, you need to create in 
> intermediate property in the window controller, and bind the text field and 
> the slider to that.
> 
> You can make this property dependent on the model property using 
> '+keyPathsForValuesAffecting...'.
> 
> All that remains is to defer updating the model until the editing or sliding 
> operation is complete. I don't think you can do that with bindings.
> 
> Probably the simplest way to put an action on the text field and the slider. 
> That'll get triggered at the end of text editing, and during sliding. 
> Something like this (in the window controller subclass):
> 
> - (IBAction) valueChanged: (id) sender {
>   model.value = self.value;
> }
> 
> - (IBAction) sliderValueChanged: (id) sender {
>   [NSObject cancelPreviousPerformRequestsWithTarget: self selector: 
> @selector (valueChanged:) object: nil];
>   [self performSelector: @selector (valueChanged:) withObject: nil 
> afterDelay: 0];
> }
> 
> The second method (the slider's action method) is a hack to defer the action 
> until the user lets go of slider.
> 
> (note: code typed in Mail)
> 
> 

___

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: Updating binding on release of slider (but update text field continuously)?

2011-03-08 Thread Quincey Morris
On Mar 8, 2011, at 17:18, Rick Mann wrote:

> I have a UI with an editable text field and a slider. I want the two to 
> represent the same model property. I only want the model updated when the 
> user exits the text field or lets go of the slider (which is what it does 
> now).
> 
> However, I'd like it if the text field would update continuously as the 
> slider is dragged.
> 
> I don't think it's possible to do this with bindings, is it?

Not exactly. To get the UI behavior you want, you need to create in 
intermediate property in the window controller, and bind the text field and the 
slider to that.

You can make this property dependent on the model property using 
'+keyPathsForValuesAffecting...'.

All that remains is to defer updating the model until the editing or sliding 
operation is complete. I don't think you can do that with bindings.

Probably the simplest way to put an action on the text field and the slider. 
That'll get triggered at the end of text editing, and during sliding. Something 
like this (in the window controller subclass):

- (IBAction) valueChanged: (id) sender {
model.value = self.value;
}

- (IBAction) sliderValueChanged: (id) sender {
[NSObject cancelPreviousPerformRequestsWithTarget: self selector: 
@selector (valueChanged:) object: nil];
[self performSelector: @selector (valueChanged:) withObject: nil 
afterDelay: 0];
}

The second method (the slider's action method) is a hack to defer the action 
until the user lets go of slider.

(note: code typed in Mail)


___

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: About notification NSWindowDidMiniaturizeNotification

2011-03-08 Thread Ivan Chen
Yes, Just heard that from one of my Mac team friends 'o-
Is there any other way to observer such interprocess window events?




Thanks
Ivan Chen

On Mar 9, 2011, at 9:20 AM, Quincey Morris wrote:

> On Mar 8, 2011, at 16:17, Ivan Chen wrote:
> 
>> What I really want to observer is the app iCal, when I register the 
>> notification the iCal may not be launched yet.
>> So I have to pass nil to observer every window, but it just doesn't work 
>> 'o-!!!
>> Why?
> 
> Because you can't get notifications from windows not in your own application.
> 
> 

___

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: About notification NSWindowDidMiniaturizeNotification

2011-03-08 Thread Quincey Morris
On Mar 8, 2011, at 16:17, Ivan Chen wrote:

> What I really want to observer is the app iCal, when I register the 
> notification the iCal may not be launched yet.
> So I have to pass nil to observer every window, but it just doesn't work 
> 'o-!!!
> Why?

Because you can't get notifications from windows not in your own application.


___

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


Updating binding on release of slider (but update text field continuously)?

2011-03-08 Thread Rick Mann
I have a UI with an editable text field and a slider. I want the two to 
represent the same model property. I only want the model updated when the user 
exits the text field or lets go of the slider (which is what it does now).

However, I'd like it if the text field would update continuously as the slider 
is dragged.

I don't think it's possible to do this with bindings, is it?

TIA,
Rick

___

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


Assertion failure in -[MPMoviePlayerControllerNew _moviePlayerDidBecomeActiveNotification:]

2011-03-08 Thread Steve Christensen
I'm seeing the above assertion in an app running on iOS 4.2.1. It then throws 
an NSInternalInconsistencyException with the reason: "movie player 
 has wrong activation state (1)."

The setup has a MPMoviePlayerController instance that is playing a local audio 
file. There is also a UIWebView whose HTML contains an  tag. When the 
play control is tapped, I see a MPMoviePlayerPlaybackDidFinishNotification 
notification with a reason of MPMovieFinishReasonPlaybackEnded, then gdb shows 
the assertion failure and exception and dumps the backtrace (below).

If I start playing the HTML's audio then start the MPMoviePlayerController's 
audio, the HTML's audio fades out and the MPMoviePlayerController's plays, so 
there's probably some subtle difference I'm missing. Any ideas what I might be 
doing wrong or what to look at? Everything is working great except when it 
comes time for dueling audio.

steve

-
0   CoreFoundation  0x314d0987 __exceptionPreprocess + 114
1   libobjc.A.dylib 0x319a149d objc_exception_throw + 24
2   CoreFoundation  0x314d07c9 +[NSException raise:format:arguments:] + 68
3   Foundation  0x31d1629f -[NSAssertionHandler 
handleFailureInMethod:object:file:lineNumber:description:] + 62
4   MediaPlayer 0x360b1571 -[MPMoviePlayerControllerNew 
_moviePlayerDidBecomeActiveNotification:] + 124
5   Foundation  0x31cd8623 _nsnote_callback + 142
6   CoreFoundation  0x31457123 __CFXNotificationPost_old + 402
7   CoreFoundation  0x31456dc3 _CFXNotificationPostNotification + 118
8   Foundation  0x31cc7d23 -[NSNotificationCenter 
postNotificationName:object:userInfo:] + 70
9   MediaPlayer 0x360b0e09 -[MPMoviePlayerControllerNew 
_postNotificationName:object:userInfo:] + 72
10  MediaPlayer 0x360b0e41 -[MPMoviePlayerControllerNew 
_postNotificationName:object:] + 24
11  MediaPlayer 0x360b0fc1 -[MPMoviePlayerControllerNew _resignActive] + 52
12  MediaPlayer 0x360b2fb7 -[MPMoviePlayerController _resignActive] + 66
13  CoreFoundation  0x31473fc7 -[NSObject(NSObject) performSelector:] + 18
14  CoreFoundation  0x3147cd51 -[NSArray makeObjectsPerformSelector:] + 388
15  MediaPlayer 0x360b44a1 +[MPMoviePlayerController 
allInstancesResignActive] + 32
16  MediaPlayer 0x360bc143 -[UIMoviePlayerController _ensureActive] + 62
17  MediaPlayer 0x360b8d17 -[UIMoviePlayerController 
videoController:tappedButtonPart:] + 18
18  MediaPlayer 0x36115cfb -[MPInlineVideoViewController 
transportControls:tappedButtonPart:] + 78
19  MediaPlayer 0x360e4f75 -[MPTransportControls _handleTapForPart:] + 112
20  MediaPlayer 0x360e54ad -[MPTransportControls buttonUp:] + 60
21  CoreFoundation  0x31477fed -[NSObject(NSObject) 
performSelector:withObject:withObject:] + 24
22  UIKit   0x338c14ad -[UIApplication sendAction:to:from:forEvent:] + 
84
23  UIKit   0x338c144d -[UIApplication 
sendAction:toTarget:fromSender:forEvent:] + 32
24  UIKit   0x338c141f -[UIControl sendAction:to:forEvent:] + 38
25  UIKit   0x338c1171 -[UIControl(Internal) 
_sendActionsForEvents:withEvent:] + 356
26  UIKit   0x338c19cf -[UIControl touchesEnded:withEvent:] + 342
27  UIKit   0x338b7355 -[UIWindow _sendTouchesForEvent:] + 368
28  UIKit   0x338b6ccf -[UIWindow sendEvent:] + 262

___

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: About notification NSWindowDidMiniaturizeNotification

2011-03-08 Thread Ivan Chen
Hi,
Guys

What I really want to observer is the app iCal, when I register the 
notification the iCal may not be launched yet.
So I have to pass nil to observer every window, but it just doesn't work 'o-!!!
Why?

The truth is I also register lots of notification like :
[self registerDefaultNotification:CalEventsChangedExternallyNotification 
withSelector:@selector(calEventsChanged:) onObject:[CalCalendarStore 
defaultCalendarStore]];
[self registerWorkspaceNotification:NSWorkspaceDidLaunchApplicationNotification 
withSelector:@selector(applicationLaunched:) onObject:[NSWorkspace 
sharedWorkspace]];
They all work 'o-   (the registerXXXNotification is method write by myself)




Thanks
Ivan Chen


On Mar 8, 2011, at 8:42 PM, Jim McGowan wrote:

>>> with "onObject:nil" you are not providing an NSWindow instance to observe
>> 
>> 
>> Not so - passing nil means "observe all windows".
> 
> Ah yes, of course it does

___

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 Intermittently Blocked Over AFP?

2011-03-08 Thread Steve Steinitz

Hi M,

On 8/03/11, A.M. wrote:


If that's true, then can you confirm this by switching to a different
remote FS protocol (smb)?


Good idea, thanks.


Or does the file locking required for this unsupported design no
longer properly function over other protocols?


Yes, according to Ben and others, it only works reliably over 
AFP.  But still, I could check for the slowness on another protocol.


Thanks again,

Steve

___

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


Core Data Intermittently Blocked Over AFP?

2011-03-08 Thread Steve Steinitz

Hello,

Our Core Data App Runs on seven machines, five of them pretty 
active, all sharing a store on a Network drive over AFP.  
Previously I've accepted constructive criticism of that 
architecture and ideas on alternative architectures, but in this 
thread I'd like to focus on one particular anomaly.  Namely:


The machines appear to become "blocked", i.e. fetches that 
usually take a few hundredths of a second begin take 15 seconds 
or more.  It happens after another machine saves to the 
database.  Only relaunching the App fixes it - until another 
machine saves.


There appears to be no intermediate slowness: the fetches take 
either well less than a second or, oddly, almost exactly 17 or 
28 seconds, sometimes 33 seconds.


It may be relevant that he slowness usually appears on one 
complex entity: Sale.  Sales have payments, lineItems, bikes, 
customer, employee, risk log entries.  Bikes and lineItems have 
products which have models.  Models have categories and brands, 
brands have suppliers.  Core Data's built-in prefetch path can't 
follow relationships after a to-many relationship and I haven't 
hand-coded those prefetches (per the old 10.4 prefetch 
workaround), so none of the objects related beyond lineItems and 
bikes get prefetched.  The problem occurs with or without prefetching.


The problem occurs regardless of the network drive: Synology, 
Thecus, Mac Mini.


This problem originally reared its head with Mac OS X 10.6.  
Then, the slowness was more dramatic: fetch times would 
sometimes increase to 3 minutes, a couple of times I saw 30 minutes.


At that time Ben Trumbull came to the rescue.  After examining 
shark and other lower-level instrument output, he suggested that 
I "wave a dead chicken over the problem": increase the sqlite 
page_size from the default of 1024 to the maximum of 16384.  
That immediately solved the problem and all was well for six 
months.  Then, the problem appeared again and I determined 
experimentally that setting the page_size to 4096 fixed it.


Last Friday, after rebuilding some indexes, the problem appeared 
again.  Fetches of Sale take either less than 0.1 seconds or 15 
- 30 seconds.  Again, it sticks to a value: if it starts out at 
25 seconds, it stays 25 seconds.


No page_size setting fixes it.  I've tried a number of network 
tweaks etc.  I also noticed that if I artificially produced a 
scenario where Sale was never queried, the problem eventually 
appeared on simpler entities.


My working hypothesis (based on Ben's musings) is that AFP 
begins to "starve" or lower the priority of clients which 
haven't written for a while, and that that is only apparent in 
a  complex fetch with many faults firing.


Anyway, before I raise a bug report for an intermittent problem 
on an architecture that's now more or less frowned upon, I'm 
open for any on-topic comments.


Cheers,

Steve

___

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


Fwd: NSXMLParserDelegateAbortedParseError

2011-03-08 Thread Josh Caswell
> So you are not getting a parsing error, you're using the wrong mechanism.

I think I see what you are saying. When my parser encounters an
element called "Error", I know that I don't need any more parsing done
no matter what else is in the data, so it seemed sensible to have the
delegate stop the parser right then. But in fact, -abortParse is
intended to be used for other circumstances?
___

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 wait for methods with result/completion blocks to finish?

2011-03-08 Thread Chris Markle
Matt, Kyle,

Thanks for the guidance and pointers to other doc. I am having trouble
wrapping my head around the asynch patterns, especially since I am
working with a code base that I inherited that is not doing a good job
of leveraging these patterns.

There are two cases (at least) in that app (which uploads images and
videos from the Photo Library or Camera using a proprietary protocol)
where it seems like we need to "wait". Maybe you can help me mentally
refactor these two...

1. Camera used to take picture or video (UIImagePickerController).
Want to save image that was taken to the camera roll like happens with
the camera app. That saving process starts when the user returns from
the camera. If they then go to the Photo Library (again with
UIImagePickerController), we don't let them do that until the image is
fully saved since we want them to be able to see them image in the
library that they just shot. So when they tap the "photo library"
button, we (as Kyle said) "throwing up a modal 'please wait' UI" until
the save to photo library function is completed, at which point we
show the photo library.

2. When all the picture taking or choosing from the library choosing
has happened, and the user ultimately has picked an image/video to
upload, they press "upload". If it's a video, we have the file already
that we need to transfer. But if it's an image we would like to get
the JPEG representation (via ALAsset / ALAssetRepresentation) into a
file so that we can transfer that file (the uploader system is
file-based). That's where some form of that code with the resultBlock
from my original post comes into play. It has the resultBlock that
returns the asset and I need to wait for that block to complete so
that I have the JPEG representation available that I can then put into
a file to transfer.

Any thoughts about how I can adjust my thinking and the app's design
to deal with these cases would help me understand this better.

Thanks in advance.

Chris
___

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

2011-03-08 Thread Kevin Bracey
Hi Josh,

So you are not getting a parsing error, you're using the wrong mechanism. By 
calling abort you are setting the parsers error code, that code has nothing to 
do with the fact you are parsing some XML with "error" in it. I think you are 
confusing a Parsing Error and a valid XML stream with an Error Message, these 
are not the same thing. Your parser should handle both types of streams without 
posting a "parser error". Then you handle the results, If it was full data, do 
stuff, if it was "Error" data then do error stuff.

cheers
Kevin

On 9/03/2011, at 10:13 AM, Josh Caswell wrote:

> Hi Kevin,
> 
> Thanks for your reply.
> 
> Sorry, maybe my explanation is not clear enough (I may have left out
> too many details). It's not a network error that I am talking about,
> but, as you say, an API error for which the server returns valid XML.
> 
> The specifics:
> I'm requesting weather data for a location by latitude and longitude.
> If I give the server a request that has, for example, a bad latitude,
> it will return valid XML, which parses fine, with an error element and
> a message describing the problem with the request:
> 
> http://www.w3.org/2001/XMLSchema-instance";
> xsi:noNamespaceSchemaLocation="http://na.unep.net/swera_ims/WS/SWERA.xsd";>110Latitude
> point must be between -90 and 90
> 
> If my parser comes upon an Error element, the delegate tells it to get
> the ErrorMessage contents and then aborts the parsing. Then the
> message ("Latitude point must be between...") is used for an alert
> sheet as I described.
> 
> I'm just wondering why, after my delegate aborts the parse, the parser
> changes the error code.
> 
> -- Josh Caswell

___

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

2011-03-08 Thread Josh Caswell
>This error is the parser state, which since you explicitly aborted ?>the 
>parse, will be something like >"NSXMLParserDelegateAbortedParseError" -512.

Yes, as I said in my original post. The parser's delegate gets error
512, NSXMLParserDelegateAbortedParseError, in the delegate method
-parser:parseErrorOccurred:, but when I check the error code _later_,
after returning from [myParser parse], it is error 1,
NSXMLParserInternalError.
___

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

2011-03-08 Thread glenn andreas

On Mar 8, 2011, at 3:13 PM, Josh Caswell wrote:

> Hi Kevin,
> 
> Thanks for your reply.
> 
> Sorry, maybe my explanation is not clear enough (I may have left out
> too many details). It's not a network error that I am talking about,
> but, as you say, an API error for which the server returns valid XML.
> 
> The specifics:
> I'm requesting weather data for a location by latitude and longitude.
> If I give the server a request that has, for example, a bad latitude,
> it will return valid XML, which parses fine, with an error element and
> a message describing the problem with the request:
> 
> http://www.w3.org/2001/XMLSchema-instance";
> xsi:noNamespaceSchemaLocation="http://na.unep.net/swera_ims/WS/SWERA.xsd";>110Latitude
> point must be between -90 and 90
> 
> If my parser comes upon an Error element, the delegate tells it to get
> the ErrorMessage contents and then aborts the parsing. Then the
> message ("Latitude point must be between...") is used for an alert
> sheet as I described.
> 
> I'm just wondering why, after my delegate aborts the parse, the parser
> changes the error code.
> 

Probably because the parser is reporting the "parse aborted" error?  From the 
header:

- (void)abortParsing;   // called by the delegate to stop the parse. The 
delegate will get an error message sent to it.

So you are getting an error because you aborted the parser (which knows not a 
thing about your concepts of "Error" and "ErrorMessage" as returned by the 
server):

- (NSError *)parserError;   // can be called after a parse is over to 
determine parser state.

This error is the parser state, which since you explicitly aborted the parse, 
will be something like "NSXMLParserDelegateAbortedParseError" -512.


Glenn Andreas  gandr...@gandreas.com 
The most merciful thing in the world ... is the inability of the human mind to 
correlate all its contents - HPL

___

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

2011-03-08 Thread Josh Caswell
Hi Kevin,

Thanks for your reply.

Sorry, maybe my explanation is not clear enough (I may have left out
too many details). It's not a network error that I am talking about,
but, as you say, an API error for which the server returns valid XML.

The specifics:
I'm requesting weather data for a location by latitude and longitude.
If I give the server a request that has, for example, a bad latitude,
it will return valid XML, which parses fine, with an error element and
a message describing the problem with the request:

http://www.w3.org/2001/XMLSchema-instance";
xsi:noNamespaceSchemaLocation="http://na.unep.net/swera_ims/WS/SWERA.xsd";>110Latitude
point must be between -90 and 90

If my parser comes upon an Error element, the delegate tells it to get
the ErrorMessage contents and then aborts the parsing. Then the
message ("Latitude point must be between...") is used for an alert
sheet as I described.

I'm just wondering why, after my delegate aborts the parse, the parser
changes the error code.

-- Josh Caswell
___

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: Crash with extra [CFString release] after changing a bound value in NSTextField

2011-03-08 Thread Quincey Morris
On Mar 8, 2011, at 12:24, John Link wrote:

> NSNumber *myNum = [[NSNumber alloc] init];
> myNum = [prefs valueForKey:MinimumValue]; // retrieve NSNumber from shared 
> defaults
> // do stuff
> [myNum release];
> 
> I thought I was releasing the NSNumber I had created, but if I understand 
> correctly the second line just points myNumber at the autoreleased value 
> returned from valueForKey. So in addition to the overrelease caused by the 
> last 
> line, the NSNumber I originally created is orphaned, right? 

Right. :)

___

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: Crash with extra [CFString release] after changing a bound value in NSTextField

2011-03-08 Thread John Link
Thank you Quincey for your help! Looks like I was reading too much into the 
trace, thinking it was a bindings problem. Turns out I had done something like 
this:

NSNumber *myNum = [[NSNumber alloc] init];
myNum = [prefs valueForKey:MinimumValue]; // retrieve NSNumber from shared 
defaults
// do stuff
[myNum release];

I thought I was releasing the NSNumber I had created, but if I understand 
correctly the second line just points myNumber at the autoreleased value 
returned from valueForKey. So in addition to the overrelease caused by the last 
line, the NSNumber I originally created is orphaned, right? 

- Original Message 
From: Quincey Morris 
To: John Link 
Cc: cocoa-dev@lists.apple.com
Sent: Tue, March 8, 2011 12:08:17 AM
Subject: Re: Crash with extra [CFString release] after changing a bound value 
in 
NSTextField

On Mar 7, 2011, at 14:01, John Link wrote:

> The app launches with the previously used values in the text fields (as 
> desired). Immediately clicking the button works fine--text is generated as 
> expected. But if I change the value in a text field before clicking the 
> button, 
>
> the app crashes. (This happens whether or not I first tab out of the field to 
> commit the edit before clicking the button.) The error is:
> 
> -[CFString release]: message sent to deallocated instance 0x164d7fd0

So you know this is a memory management error -- a string has been 
overreleased. 
What's your code to "change the value in a text field"?


  
___

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: Notifications and Subclassing

2011-03-08 Thread Gordon Apple
Yup.  Right you are.  Thanks.

This was originally a singleton class where it wouldn't have shown up. That
changed in redesign when we started switching different subclasses, which
caused the problem.


On 3/8/11 10:07 AM, "glenn andreas"  wrote:

> 
> On Mar 8, 2011, at 9:42 AM, Gordon Apple wrote:
> 
>> Class A:  NSObject, has methods:
>> 
>> -  (void)foo:(Notification*)notification {
>>...
>> }
>> 
>> - (void)addObservers {
>>[[NSNotificationCenter defaultCenter] addObserver:self
>> selector:@selector(foo:)
>> name:notificationName
>>   object:nil];
>> }
>> 
>> 
>> Class B: subclass of A.  This is the class used.
>> 
>> Notification sent from elsewhere.  Console:
>> 
>> -[NSCFString foo:]: unrecognized selector sent to instance 0x69807c0
>> 
>> 
>> Is this due to confusion of of which class received the notification?  Or is
>> this a compiler/linker bug?  I even tried declaring foo in A¹s headers, to
>> no avail.  This same overall procedure is used elsewhere (without
>> subclassing), with no problems.  What am I missing?
>> 
>> 
>> 
> 
> That's a classic memory management problem.
> 
> Most likely, you're forgetting to unregister your observer when you are
> deallocating it (resulting in a notification center to have a stale pointer
> that is later reused by an NSString).
> 
> 
> Glenn Andreas  gandr...@gandreas.com
> The most merciful thing in the world ... is the inability of the human mind to
> correlate all its contents - HPL
> 



___

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

2011-03-08 Thread Bill Bumgarner

On Mar 8, 2011, at 12:33 AM, Bruno Causse wrote:

> the performance is not a problem, all my threads are waiting for a answer to 
> a request.

That is potentially still a big problem as every thread uses kernel resources, 
reserves memory for a stack, and otherwise pollutes the kernel's scheduling 
information.

A far better approach is to having a single thread that handles all the waiting 
and then spews off the work to be done to a [reasonably sized] pool of threads.

An even better approach than that would be to use GCD.   Do the waiting threads 
wait on something that is covered by dispatch sources?  If so, that solution 
will be significantly cleaner and more efficient than anything you could do 
using the lower level APIs [since GCD can collude with the kernel].   If not, 
dispatching the units of work via the GCD APIs will likely be more efficient 
and generally be simpler than managing a pool of threads.

> 
> my program is a kind of working's Distributor.
> 

___

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 wait for methods with result/completion blocks to finish?

2011-03-08 Thread Matt Neuburg
On Mon, 07 Mar 2011 21:00:33 -0800, Chris Markle  said:
>This is on iOS... Say I have use a method that has some kind of
>result/completion block like ALAssetsLibrary assetForURL In the
>example below, in the assetForURL result block, the JPEG
>representation of the asset is read into a buffer and the NSData form
>of that buffer is assigned to a property. I need the property to be
>set before my code continues past his point. How do I go about
>accomplishing that?

You put "my code" in the completion block. That's what a completion block *is*: 
it's where you do the stuff that depends upon this operation having completed. 
See also the docs (Preparing an Asset for Use):

> To load a value for one or more properties, you invoke 
> loadValuesAsynchronouslyForKeys:completionHandler:. *In the completion 
> handler*, you take whatever action is appropriate depending on the property's 
> status. 


And after all, as that same paragraph in the docs tells you (along with the 
subsequent example), the attempt to get the property's value might also fail. 
The only sensible place to handle all the things that can happen is the 
completion block.

Sure, this means you have to break up your procedure into steps, but block 
syntax can actually help you to clarify this. m.

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

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

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

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

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


Re: kvo

2011-03-08 Thread Matt Neuburg
On Tue, 08 Mar 2011 01:23:18 +0200, Ariel Feinerman  
said:
>Hi,
>
>I wish to use kvo to get data from NSOperation and observe isFinished but on
>witch thread is - observeValueForKeyPath:ofObject:change:context: executed?

Why not use NSLog and find out? :)

Basically, you shouldn't make *any* assumptions about this. If you need to do 
something in response to isFinished that has to be on a particular thread (such 
as the main thread), then jump out to that thread in your implementation of 
observeValueForKeyPath:...

The same is true if you post a notification from the NSOperation.

m.

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

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

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

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

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


Re: Why do I have to initialize NSError ?

2011-03-08 Thread Kevin Perry
This is a bug in the framework. NSError-returning methods should not need to 
check the value of the dereferenced pointer before setting it.

Please file a bug for this.

-KP

On Mar 8, 2011, at 7:22 AM, Gerriet M. Denkmann wrote:

> I thought that NSError is just an output parameter, which is set only in case 
> of errors.
> 
> But in my completion handler block (see below) NSError MUST be initialized to 
> nil, or it will NOT be set.
> 
> The same code works as expected when NOT inside a block.
> 
> 
> #define   REMOVE_BUG  //  if this is NOT defined, we get:
> 
> [...] __-[Alias_TestAppDelegate openAliasFile:]_block_invoke_1 outError1 
> 0x10057f3b0 (NOT initialized)
> [...] __-[Alias_TestAppDelegate openAliasFile:]_block_invoke_1 outError2 
> 0x10057f3b0 (after error return)
> [...] -[NSOpenPanel recoveryAttempter]: unrecognized selector sent to 
> instance 0x10057f3b0
> 
> 
> Here is the code:
> 
> - (IBAction)openAliasFile: sender;
> {
>   (void)sender;
>   
>   NSOpenPanel *openPanel = [ NSOpenPanel openPanel ];
>   [ openPanel setAllowsMultipleSelection: NO ];
>   [ openPanel setCanChooseDirectories: NO ];
>   [ openPanel setResolvesAliases: NO ];
>   [ openPanel setMessage: @"Select Alias File" ];  
> 
>   [ openPanel beginSheetModalForWindow:   self.window
>   completionHandler:  
> ^(NSInteger result)
>   {
>   if (result == NSOKButton) 
>   {
>   NSURL *bookmarkFileURL = [ 
> openPanel URL ];
>   
>   [ [ self window ] 
> setTitleWithRepresentedFilename: [ bookmarkFileURL path ] ];
>   
>   [ openPanel orderOut:self]; // close panel 
> before we might present an error
> 
>   //  if  is 
> NOT an alias file,  will be nil, but 
>   //  is NOT set. Works 
> correctly if we initialise   to nil.
>   
>   #ifdef REMOVE_BUG
>   NSError *outError = nil;
>   #else
>   NSError *outError;
>   NSLog(@"%s outError1 %p (NOT 
> initialized)",__FUNCTION__, outError);
>   #endif
>   
>   NSData *bookmarkData =  [ NSURL 
> bookmarkDataWithContentsOfURL:  bookmarkFileURL 
>   
> error:
>   &outError 
>   
> ];
>   if ( bookmarkData == nil )  
> //  error
>   {
>   NSLog(@"%s outError2 %p 
> (after error return)",__FUNCTION__, outError);
> 
>   [ self  presentError:   
> outError 
>   
> modalForWindow: [ self window ] 
>   
> delegate:   nil 
>   
> didPresentSelector: NULL  
>   
> contextInfo:NULL 
>   ];
>   
>   return;
>   };  
> 
> 
>   //  do something with valid 
> bookmarkData
>   
>   }
>   else//  cancelled
>   {
>   self.dataString = @"-- 
> Cancelled --";
>   };
>   }
>   ];
> }
> 
> 
> Kind regards,
> 
> Gerriet.
> 
> P.S. Tested on 10.6.6
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> C

NSXMLParserDelegateAbortedParseError

2011-03-08 Thread Kevin Bracey
Hi Josh,

I'm not sure that is the best place to be checking for a server/network error. 
If there was an API error, I would have thought the server would have returned 
valid XML with the error details, which should parse and not cause an parser 
error. I'd look at downloading the file, determine if it's a API error or some 
other network error, then use NSXMLDocument, at lest until you work out the 
error handling.

cheers
Kevin___

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: easy way to store table-like data

2011-03-08 Thread Matt Neuburg
On Mon, 07 Mar 2011 12:29:27 -0800, Dave DeLong  said:
>If you have an array of dictionaries, you can use 
>-filteredArrayUsingPredicate, and pass in the NSPredicate with the format 
>string of @"type = 'website'".  You'll get back all the dictionaries where 
>[[dictionary objectForKey:@"type"] isEqual:@"website"];
>
>On Mar 7, 2011, at 12:26 PM, Martin Batholdy wrote:
>
>> Is it also possible to filter the entries of an NSDictionary like in SQL?
>> 
>> for example I have a key "type" and different entries.
>> 
>> Is it possible to get an Array of all elements where "type" is equal to 
>> "website" (or something like that)?

I am surprised that no one has mentioned blocks. For example, if you restrict 
yourself to Mac OS X 10.6 or later, or iOS 4 or later, you can call 
keysOfEntriesPassingTest:, and similarly for arrays. Your best bet is to look 
over the documentation (e.g., if you want to know what you can do with an 
NSDictionary, read the class reference for NSDictionary; if you want to know 
what you can do with an NSArray, read up on NSArray; etc.).

However, I'd also point out that you may be combining two or three different 
issues in the way your original question is posed. How your data are stored is 
one thing (could be sqlite; on the other extreme, could be simple tab-delimited 
text). How they are manipulated is another (could be NSDictionary, NSArray, 
etc., or, as Dave DeLong rightly suggests, a class devoted to data structured a 
particular way). How they are presented in the interface is yet another. m.

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

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

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

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

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


Re: Notifications and Subclassing

2011-03-08 Thread glenn andreas

On Mar 8, 2011, at 9:42 AM, Gordon Apple wrote:

> Class A:  NSObject, has methods:
> 
> -  (void)foo:(Notification*)notification {
>...
> }
> 
> - (void)addObservers {
>[[NSNotificationCenter defaultCenter] addObserver:self
> selector:@selector(foo:)
> name:notificationName
>   object:nil];
> }
> 
> 
> Class B: subclass of A.  This is the class used.
> 
> Notification sent from elsewhere.  Console:
> 
> -[NSCFString foo:]: unrecognized selector sent to instance 0x69807c0
> 
> 
> Is this due to confusion of of which class received the notification?  Or is
> this a compiler/linker bug?  I even tried declaring foo in A’s headers, to
> no avail.  This same overall procedure is used elsewhere (without
> subclassing), with no problems.  What am I missing?
> 
> 
> 

That's a classic memory management problem.

Most likely, you're forgetting to unregister your observer when you are 
deallocating it (resulting in a notification center to have a stale pointer 
that is later reused by an NSString).


Glenn Andreas  gandr...@gandreas.com 
The most merciful thing in the world ... is the inability of the human mind to 
correlate all its contents - HPL

___

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


Notifications and Subclassing

2011-03-08 Thread Gordon Apple
Class A:  NSObject, has methods:

-  (void)foo:(Notification*)notification {
...
}

- (void)addObservers {
[[NSNotificationCenter defaultCenter] addObserver:self
 selector:@selector(foo:)
 name:notificationName
   object:nil];
}


Class B: subclass of A.  This is the class used.

Notification sent from elsewhere.  Console:

-[NSCFString foo:]: unrecognized selector sent to instance 0x69807c0


Is this due to confusion of of which class received the notification?  Or is
this a compiler/linker bug?  I even tried declaring foo in A¹s headers, to
no avail.  This same overall procedure is used elsewhere (without
subclassing), with no problems.  What am I missing?




___

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


Why do I have to initialize NSError ?

2011-03-08 Thread Gerriet M. Denkmann
I thought that NSError is just an output parameter, which is set only in case 
of errors.

But in my completion handler block (see below) NSError MUST be initialized to 
nil, or it will NOT be set.

The same code works as expected when NOT inside a block.


#define REMOVE_BUG  //  if this is NOT defined, we get:

[...] __-[Alias_TestAppDelegate openAliasFile:]_block_invoke_1 outError1 
0x10057f3b0 (NOT initialized)
[...] __-[Alias_TestAppDelegate openAliasFile:]_block_invoke_1 outError2 
0x10057f3b0 (after error return)
[...] -[NSOpenPanel recoveryAttempter]: unrecognized selector sent to instance 
0x10057f3b0


Here is the code:

- (IBAction)openAliasFile: sender;
{
(void)sender;

NSOpenPanel *openPanel = [ NSOpenPanel openPanel ];
[ openPanel setAllowsMultipleSelection: NO ];
[ openPanel setCanChooseDirectories: NO ];
[ openPanel setResolvesAliases: NO ];
[ openPanel setMessage: @"Select Alias File" ];  

[ openPanel beginSheetModalForWindow:   self.window
completionHandler:  
^(NSInteger result)
{
if (result == NSOKButton) 
{
NSURL *bookmarkFileURL = [ 
openPanel URL ];

[ [ self window ] 
setTitleWithRepresentedFilename: [ bookmarkFileURL path ] ];

[ openPanel orderOut:self]; // close panel 
before we might present an error

//  if  is 
NOT an alias file,  will be nil, but 
//  is NOT set. Works 
correctly if we initialise   to nil.

#ifdef REMOVE_BUG
NSError *outError = nil;
#else
NSError *outError;
NSLog(@"%s outError1 %p (NOT 
initialized)",__FUNCTION__, outError);
#endif

NSData *bookmarkData =  [ NSURL 
bookmarkDataWithContentsOfURL:  bookmarkFileURL 

error:  
&outError 

];
if ( bookmarkData == nil )  
//  error
{
NSLog(@"%s outError2 %p 
(after error return)",__FUNCTION__, outError);

[ self  presentError:   
outError 

modalForWindow: [ self window ] 

delegate:   nil 

didPresentSelector: NULL  

contextInfo:NULL 
];

return;
};  


//  do something with valid 
bookmarkData

}
else//  cancelled
{
self.dataString = @"-- 
Cancelled --";
};
}
];
}


Kind regards,

Gerriet.

P.S. Tested on 10.6.6

___

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: About notification NSWindowDidMiniaturizeNotification

2011-03-08 Thread Jim McGowan
>> with "onObject:nil" you are not providing an NSWindow instance to observe
> 
> 
> Not so - passing nil means "observe all windows".

Ah yes, of course it does
___

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: About notification NSWindowDidMiniaturizeNotification

2011-03-08 Thread Graham Cox

On 08/03/2011, at 10:45 PM, Jim McGowan wrote:

> with "onObject:nil" you are not providing an NSWindow instance to observe


Not so - passing nil means "observe all windows".

--Graham


___

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: About notification NSWindowDidMiniaturizeNotification

2011-03-08 Thread Jim McGowan
> 
> I write the following code and try to observe the window miniaturized 
> notification, it doesn't work, can anyone tell me why?
> ...
> // Observing window status
>   [self registerDefaultNotification:NSWindowDidMiniaturizeNotification 
> withSelector:@selector(windowMiniaturized:) onObject:nil];
> 

with "onObject:nil" you are not providing an NSWindow instance to observe

Jim
___

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 relationship to checkbox

2011-03-08 Thread Amy Gibbs

Sorry, I'm obviously being a bit dim here,

I have got array controllers for both the categories tableview and the  
products tableview,


As I want to list ALL the categories in the tableview I have bound the  
name column to the categories. array controller, arrangedObjects,  
categoryName


Then the checkbox column needs to bind to?

Thanks
On 7 Mar 2011, at 5:28PM, Jerry Krinock wrote:



On 2011 Mar 07, at 08:55, Amy Gibbs wrote:


I still can't work out how I could bind the checkboxes


As I said earlier, think: "array controller".

___

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: Event Tap(CFMachPortRef) problem for Hot Key- callback is not invoked

2011-03-08 Thread Bill Cheeseman
On Mar 7, 2011, at 10:40 PM, Deepa wrote:

> But, sometimes (randomly) the callback is not invoked; Hot Key does not work 
> and hence the feature seems to be not working. 

I haven't analyzed your code, but I would suggest that you revise it to capture 
all the errors that the event tap functions might generate, then see what you 
see.

Also, one possibility is that the system might occasionally disable the event 
tap, if it gets overloaded. The Quartz Event Services Reference document 
explains how to test in your callback for system disabling or user disabling 
the event tap. When the system disables it, your code can simply re-enable it 
immediately. Every event tap callback should do this to avoid the problem you 
are seeing.

-- 

Bill Cheeseman - b...@cheeseman.name
___

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: Event Tap(CFMachPortRef) problem for Hot Key- callback is not invoked

2011-03-08 Thread Deepa
Hi Daniel,

Thank you for the response.

Our app provides the user with an option of using system shortcut keys for 
capturing.
For example, 
Suppose Cmd+Shift+4 is the system shortcut used to capture the full screen; 
user can use the same combination of keys to capture the full screen from my 
app.
If I use the Hot key API RegisterEventHotKey(), I cannot override the system 
behavior with my app behavior for the shortcut Cmd+Shift+4.
So, I am using the tapping mechanism if user wants to override system behavior.

But, sometimes I do not get any callback. How do I solve this?

Regards,
Deepa

On 08-Mar-2011, at 2:31 PM, Jean-Daniel Dupas wrote:

> 
> Le 8 mars 2011 à 04:40, Deepa a écrit :
> 
>> Hi,
>> 
>> I am developing a desktop application that supports one of the feature 
>> through Hot Key. I am using Event Tap for this to work. 
>> 
>> But, sometimes (randomly) the callback is not invoked; Hot Key does not work 
>> and hence the feature seems to be not working. 
>> 
>> Could someone help me out in identifying the problem here.
>> 
>> Following is the code snippet:
>> 
>>  -( void )startEventTapinThread //Called in a separate thread.
>>  {
>>  NSAutoreleasePool *pool =[ [ NSAutoreleasePool alloc] init];
>>  
>>  CFRunLoopRef runloop =(CFRunLoopRef)CFRunLoopGetCurrent();
>>  CGEventMask interestedEvents = 
>> CGEventMaskBit(kCGEventFlagsChanged)|CGEventMaskBit(kCGEventKeyDown);
>>  CFMachPortRef eventTap = CGEventTapCreate(kCGSessionEventTap, 
>> kCGHeadInsertEventTap, 0, interestedEvents, myCGEventCallback, self); 
>> //self is the object pointer our method
>>  CFRunLoopSourceRef source = 
>> CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventTap, 0);
>>  CFRunLoopAddSource((CFRunLoopRef)runloop , source, 
>> kCFRunLoopCommonModes);
>>  CFRunLoopRun();
>>  [ pool release];
>>  }
>> 
>>  CGEventRef myCGEventCallback(CGEventTapProxy proxy, CGEventType type, 
>> CGEventRef event, void *refcon)
>>  {
>>  CGEventType eventType = CGEventGetType(event);
>>  //execute the code related to feature
>>  }
> 
> 
> 
> Why you don't use the HotKey API instead (RegisterEventHotKey()) ? It does 
> not require root access or accessibility enabled and it works quite well.
> 
> 
> -- Jean-Daniel
> 
> 
> 
> 
> 

---
Robosoft Technologies - Come home to Technology

Disclaimer: This email may contain confidential material. If you were not an 
intended recipient, please notify the sender and delete all copies. Emails to 
and from our network may be logged and monitored. This email and its 
attachments are scanned for virus by our scanners and are believed to be safe. 
However, no warranty is given that this email is free of malicious content or 
virus.
___

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: Event Tap(CFMachPortRef) problem for Hot Key- callback is not invoked

2011-03-08 Thread Jean-Daniel Dupas

Le 8 mars 2011 à 04:40, Deepa a écrit :

> Hi,
> 
> I am developing a desktop application that supports one of the feature 
> through Hot Key. I am using Event Tap for this to work. 
> 
> But, sometimes (randomly) the callback is not invoked; Hot Key does not work 
> and hence the feature seems to be not working. 
> 
> Could someone help me out in identifying the problem here.
> 
> Following is the code snippet:
> 
>   -( void )startEventTapinThread //Called in a separate thread.
>   {
>   NSAutoreleasePool *pool =[ [ NSAutoreleasePool alloc] init];
>   
>   CFRunLoopRef runloop =(CFRunLoopRef)CFRunLoopGetCurrent();
>   CGEventMask interestedEvents = 
> CGEventMaskBit(kCGEventFlagsChanged)|CGEventMaskBit(kCGEventKeyDown);
>   CFMachPortRef eventTap = CGEventTapCreate(kCGSessionEventTap, 
> kCGHeadInsertEventTap, 0, interestedEvents, myCGEventCallback, self); 
> //self is the object pointer our method
>   CFRunLoopSourceRef source = 
> CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventTap, 0);
>   CFRunLoopAddSource((CFRunLoopRef)runloop , source, 
> kCFRunLoopCommonModes);
>   CFRunLoopRun();
>   [ pool release];
>   }
> 
>   CGEventRef myCGEventCallback(CGEventTapProxy proxy, CGEventType type, 
> CGEventRef event, void *refcon)
>   {
>   CGEventType eventType = CGEventGetType(event);
>   //execute the code related to feature
>   }



Why you don't use the HotKey API instead (RegisterEventHotKey()) ? It does not 
require root access or accessibility enabled and it works quite well.


-- Jean-Daniel




___

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: Length of NSWindow's stringWithSavedFrame result?

2011-03-08 Thread Graham Cox

On 08/03/2011, at 4:38 PM, John Bartleson wrote:

> I'm suspicious, though, that the 50 bytes I've allowed for the
> string returned by getxattr in the second method above might not be enough on 
> a multi-monitor
> system.


You could just make it bigger - it's a very transient piece of memory on the 
stack (or, if that's a problem, just malloc and free a chunk). Since getxattr 
allows you to pass in the max size of the buffer, it's also safe from a buffer 
overflow attack.

--Graham


___

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 wait for methods with result/completion blocks to finish?

2011-03-08 Thread Kyle Sluder
On Mar 7, 2011, at 9:00 PM, Chris Markle  wrote:

> I guess in general I an wondering how I correctly wait for things to
> happen that I absolutely positively need to be done before I
> continue...

You rework your approach to not require these things to be complete before your 
code continues.

Throwing up a modal "please wait" UI until the callback gets executed is a 
common approach whenever the user can't logically expect to proceed until the 
app is done with some processing. An asynchronous API is preferable because it 
lets you return to the runloop and process user events, rather than get stuck 
in a busy loop that is indistinguishable to the OS from a hung process.

--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: how to start rainbow cursor

2011-03-08 Thread Kyle Sluder
On Mar 7, 2011, at 11:45 PM, "Yu, Min"  wrote:

> Hi list
> 
> how to start rainbow cursor?

This should never, ever, ever be a desired goal. Ever.

What are you actually trying to do? For what purpose did you want to display 
the beachball?

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

2011-03-08 Thread Bruno Causse
the performance is not a problem, all my threads are waiting for a  
answer to a request.


my program is a kind of working's Distributor.


Le 8 mars 11 à 08:20, Bill Bumgarner a écrit :



On Mar 7, 2011, at 12:27 PM, Bruno Causse wrote:


hi all,

how many NSThread i can create?


Quite a few more than are useful, performant, or optimal...

b.bum

___

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/bcausse%40lepoint.fr

This email sent to bcau...@lepoint.fr



___

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


[ANN] LuaCocoa v.0.2 released

2011-03-08 Thread Eric Wing
I am happy to announce the second public release of LuaCocoa (v. 0.2).
This version is faster, smaller, and better.

LuaCocoa is a next generation Lua/Objective-C bridge that uses
BridgeSupport and libffi on Mac OS X to provide full automatic
bindings to Objective-C and the more difficult areas of the platform
such as functions, structs, constants, enums, etc.


Release Notes for v 0.2: (Faster, Smaller, Better)

- Big performance improvements over 0.1.
- Optimized initialization/load times. Names are now resolved through
a metatable (which calls LuaCocoa.resolveName) so launch times are now
very fast.
- Cached parsed XML data so repeated method calls don't have to
reparse XML data.

- The LuaCocoa core framework is now over 30% smaller
- Removed ParseKit dependency

- Added LuaCocoa.toCocoa and LuaCocoa.toLua functions to convert
between Cocoa and Lua types within Lua scripts.

- Started formalizing support for instance variables in Lua
subclassing. (Put your variables in a special table named __ivars.)
(Thanks to Jonathan Mitchell for feedback, testing, and patches for this.)

- Bug fixes, logging clean ups

- Initial Doxygen for Obj-C & C APIs. Xcode DocSet Documentation provided too.


To learn more about LuaCocoa and grab the binaries, please visit:
http://playcontrol.net/opensource/LuaCocoa/


-Eric
-- 
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/
___

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