Re: An API for Airplane mode on iOS?

2016-02-08 Thread Clark S. Cox III

> On Feb 8, 2016, at 13:55, Alex Zavatone  wrote:
> 
> On iOS, we're running into particular issues with one user who puts his 
> device in Airplane mode overnight.
> 
> I'm using reachability classes to determine if we can reach our web services 
> IP and monitoring all reachability enums, but would be "really nice™" is if 
> there is a published API to read the position of the Airplane Mode setting.
> 
> All my sniffing around tells me that there is no formal API for this.  Am I 
> correct in assuming that this is true?

I don't believe that there is. That said, it probably wouldn't help in this 
case. You can easily turn on Airplane Mode and then turn on WiFi and/or 
Bluetooth (i.e. you can still have a working internet connection even if 
Airplane Mode is on). As always, it is recommended to test for specific 
functionality (i.e. use reachability in this case) rather than reading settings 
and trying to interpret what each of their possible permutations actually means.


> Thanks in advance.
> 
> Alex Zavatone
> ___
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com
> 
> This email sent to clarkc...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: How to know if an NSView has pending draws

2016-02-04 Thread Clark S. Cox III

> On Feb 4, 2016, at 15:52, Jeff Evans  wrote:
> 
> Clark, it's a music app; a piece is composed and placed on the screen; 
> there's a lot of massaging going on as the music adjusts visually.

Instead of looking to the view system to know when your code is done laying 
things out, why not ask your layout code directly? Or why not have your layout 
code post a notification when it begins and another when it ends?

> I want the play of the example to begin once there are no more updates 
> remaining. That is no noticeable delay in terms of human time, but makes a 
> difference in the appearance.
> 
> So I figure: the system presumably knows if it is about to send more redraw 
> requests to that view. Is there any way I could know what it knows?

If you really wanted to, I suppose you could walk the window's entire view 
hierarchy and ask every visible view for the value of its needsDisplay 
property. (Though I would advise against it

> 
> Jeff
> 
> 
> On Feb 4, 2016, at 3:31 PM, Clark S. Cox III wrote:
> 
> 
> 
> 
> 
> 
>> On Feb 4, 2016, at 15:07, Jeff Evans  wrote:
>> 
>> Suppose one wants to do a task in an NSView only once it has no drawRect 
>> calls pending. Is there any way to tell, for a particular NSView, if there 
>> are any drawing events coming up? Whether, that is, the view is up to date?
>> 
>> I've tried counting my explicit uses of setNeedsDisplay and decrementing 
>> that count at drawRect, but the trouble is that one can call setNeedsDisplay 
>> many times and that will not translate into the same number of drawRects.
>> 
>> One idea was to call getRectsBeingDrawn at drawRect and hope that the number 
>> of rects is equal to the number of update requests combined into that call. 
>> But the number of rects does not appear to equal the number of draw requests.
> 
> Multiple invalid regions can be merged.
> 
>> But there must be some place that contains a queue of upcoming draw 
>> requests. If so, is there access to it? 
> 
> There really isn't any such queue. There are only areas of the view that are 
> marked as invalid.
> 
>> I'm hoping this is a dumb question.
>> 
>> Thanks, Jeff
> 
> I hate to be "that guy", but what are you actually trying to do?
> 
> 
> --
> If this email is spam, report it to
> https://support.onlymyemail.com/view/report_spam/MTAxOTYyOjE4NDk5MDE2Njc6amV2YW5zQGFycy1ub3ZhLmNvbTpkZWxpdmVyZWQ
> 
> 
> 
> ___
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com
> 
> This email sent to clarkc...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: How to know if an NSView has pending draws

2016-02-04 Thread Clark S. Cox III



> On Feb 4, 2016, at 15:07, Jeff Evans  wrote:
> 
> Suppose one wants to do a task in an NSView only once it has no drawRect 
> calls pending. Is there any way to tell, for a particular NSView, if there 
> are any drawing events coming up? Whether, that is, the view is up to date?
> 
> I've tried counting my explicit uses of setNeedsDisplay and decrementing that 
> count at drawRect, but the trouble is that one can call setNeedsDisplay many 
> times and that will not translate into the same number of drawRects.
> 
> One idea was to call getRectsBeingDrawn at drawRect and hope that the number 
> of rects is equal to the number of update requests combined into that call. 
> But the number of rects does not appear to equal the number of draw requests.

Multiple invalid regions can be merged.

> But there must be some place that contains a queue of upcoming draw requests. 
> If so, is there access to it? 

There really isn't any such queue. There are only areas of the view that are 
marked as invalid.

> I'm hoping this is a dumb question.
> 
> Thanks, Jeff

I hate to be "that guy", but what are you actually trying to do?
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Trying to understand a permissions failure when writing to ~/Desktop

2016-01-28 Thread Clark S. Cox III

> On Jan 27, 2016, at 22:08, Graham Cox  wrote:
> 
> 
>> On 28 Jan 2016, at 4:36 PM, Graham Cox  wrote:
>> 
>> Why would the OS think an app was sandboxed
> 
> 
> OK, I think I found the problem. In Build Settings->Code Signing, the “Code 
> Signing Entitlements” was set to a .entitlements file which is actually 
> nothing to do with this product. I don’t know where it got that setting from 
> (I’ve never set it), but it’s wrong. I deleted it and now my app seems to be 
> happy to write where it wants to and doesn’t create a container.
> 
> I’m supposing that the actual sandboxing entitlements are baked into the code 
> signature, not just read from a resource file, and that’s where the system 
> gets its info.

Correct. If you want to see the entitlements a given app was signed with, you 
can use:

codesign -d --entitlements - .app

e.g.

% codesign -d --entitlements - /Applications/Preview.app
Executable=/Applications/Preview.app/Contents/MacOS/Preview
��qq�
http://www.apple.com/DTDs/PropertyList-1.0.dtd";>


com.apple.application-identifier
com.apple.preview
com.apple.developer.maps

com.apple.developer.ubiquity-container-identifiers

com.apple.Preview

com.apple.private.bookkit

com.apple.security.app-sandbox

com.apple.security.application-groups

com.apple.PreviewLegacySignaturesConversion

com.apple.security.device.camera

com.apple.security.files.downloads.read-write

com.apple.security.files.user-selected.read-write

com.apple.security.print

com.apple.security.temporary-exception.mach-lookup.global-name

com.apple.systemuiserver.screencapture

keychain-access-groups

com.apple.AnnotationKit






> So Alex, you were right ;)
> 
> —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:
> https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com
> 
> This email sent to clarkc...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Obj-C - your thoughts on hiding data members?

2016-01-28 Thread Clark S. Cox III

> On Jan 28, 2016, at 03:14, Dave  wrote:
> 
> 
>> On 28 Jan 2016, at 00:34, Alex Zavatone  wrote:
>> 
>> Ahh, just a little testing shows that well, if it’s not ASCII, it’s not 
>> going to work, period.  
> 
> See? If it ain’t ASCII it ain’t Source Code! lol

But that was originally said in response to Unicode in *comments*, not in 
identifiers.

> 
> Dave
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com
> 
> This email sent to clarkc...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Obj-C - your thoughts on hiding data members?

2016-01-27 Thread Clark S. Cox III

> On Jan 27, 2016, at 11:49, Alex Zavatone  wrote:
> 
> 
> On Jan 27, 2016, at 6:38 AM, Dave wrote:
> 
>> 
 
> I'm going to step out on a limb and since Xcode has supported editing in 
> UTF-8 and 16, that we look into those character sets and pick some 
> symbols that accurately represent public, protected and private.
 
 Now you’re pulling our legs, right Alex?
>>> 
>>> Yeah, I know.  It's really non conventional, buuut… I've started using some 
>>> of the characters such as the block and non breaking line to make better 
>>> formatting for comments and logging.
>> 
>> Wow Man, you *do* like living on the wild-side. I hope it doesn’t come back 
>> to bite you! 
> 
> Wise words.  
> 
> I base this attempt on a fair amount of crash test dummies who have risked 
> this before me and constantly asking questions.  Is the character set 
> supported by Xcode?  By Git?

Both support UTF-8. Full stop.

> The popups in the right side of Inspector Panel with a setting for Text 
> Encoding and the amount of people who I've seen code in Japanese with the 
> UTF-16 encoding justified me asking this.

Just stick to UTF-8 and you'll be fine.
UTF-16 is a silly encoding to use for source code :)

> 
> But for those crazy Swift kids who are using smilies in variable names, I'm 
> going to let them drive the crash test vehicle. 
> 
>>> Other people who are on the Swift side of things are even using smilies and 
>>> emoticons in their code.  Or so they claim.  That scares me.
>> 
>> I’m more of a if its not in the ASCII set it ain’t Source Code brigade! lol
>> 
>> All the Best
>> Dave
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com
> 
> This email sent to clarkc...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Obj-C - your thoughts on hiding data members?

2016-01-27 Thread Clark S. Cox III

> On Jan 27, 2016, at 03:38, Dave  wrote:
> 
> 
>>> 
 I'm going to step out on a limb and since Xcode has supported editing in 
 UTF-8 and 16, that we look into those character sets and pick some symbols 
 that accurately represent public, protected and private.
>>> 
>>> Now you’re pulling our legs, right Alex?
>> 
>> Yeah, I know.  It's really non conventional, buuut… I've started using some 
>> of the characters such as the block and non breaking line to make better 
>> formatting for comments and logging.
> 
> Wow Man, you *do* like living on the wild-side. I hope it doesn’t come back 
> to bite you! 
> 
>> Other people who are on the Swift side of things are even using smilies and 
>> emoticons in their code.  Or so they claim.  That scares me.
> 
> I’m more of a if its not in the ASCII set it ain’t Source Code brigade! lol

That's awfully America-centric of you :)
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: delete stock apps

2016-01-25 Thread Clark S. Cox III

> On Jan 24, 2016, at 22:16, Rick C.  wrote:
> 
> Does anyone know if there’s a way to delete stock apps on 10.11 without 
> disabling SIP and rebooting the machine?

No.

>  Or, is there a way to disable SIP without rebooting?  Thanks!

No.

> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com
> 
> This email sent to clarkc...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: How to record screen in iOS

2016-01-22 Thread Clark S. Cox III
Unfortunately, what you ask is not possible. There are ways for your app to 
record *itself* (e.g. through ReplayKit), and there are ways for a connected 
computer to record the screen of any running app (e.g. through QuickTime 
Player). But there is no way for your app to record *another* app that you 
didn't develop.

> On Jan 22, 2016, at 03:41, ico  wrote:
> 
> The reason that not to use ReplayKit is simple, if the user play a game
> without ReplayKit feature then they can not record the video.
> If I can implement an app for recording, then users can do it no matter
> what game they play.
> 
> Actually I am not asking how to do this for a game I develop, I just want
> to build a website that user can upload their video for playing game
> (probably because users want to show how skilful they are) . The app is the
> tool so they can make the video.
> 
> 
> 
> On Fri, 22 Jan 2016 at 13:55 David Brittain  wrote:
> 
>> If a 3rd party solution will meet your needs the take a look at
>> https://lookback.io
>> 
>> Dave
>> 
>> On 21 January 2016 at 19:14, Alex Kac  wrote:
>>> Is there a reason you can’t use ReplayKit:
>>> 
>>> 
>> https://developer.apple.com/library/ios/documentation/ReplayKit/Reference/RPScreenRecorder_Ref/index.html#//apple_ref/occ/cl/RPScreenRecorder
>>> 
>>> I’ve been thinking of exploring this for support purposes (i.e let the
>> user hit a button to record the screen and send us the video), but to be
>> honest I haven’t even spent 2 seconds looking at ReplayKit beyond what I
>> saw at WWDC…so not sure if that’s possible.
>>> 
 On Jan 21, 2016, at 7:45 PM, ico  wrote:
 
 Hi,
 I know I can do this with QuickTime, but the problem is you need a
>> computer
 with you to do so, I want the users can do it whenever they want.
 ReplayKit maybe the choice, I will take a look.
 
 For the sandboxing reason, I know it possibly not to get it done.
>> However,
 what if there is some dark magic like private API, I use them to develop
 the app and not to upload it
 to app store, I just distribute the app to the users who want to use
>> it, is
 there any chance?
 
 Thank you.
 
 
 On Thu, 21 Jan 2016 at 00:41 Hunter Hillegas 
 wrote:
 
> Building a general purpose iOS app to do this is not possible for
> sandboxing/privacy reasons.
> 
> For your own apps, you can embed ReplayKit or you can connect to the
>> Mac
> and use QuickTime to record the screen.
> 
>> On Jan 20, 2016, at 1:21 AM, ico  wrote:
>> 
>> Hi All,
>> Is it possible to develop an app that can run in the background and
> record
>> the user's device screen. For example, user can use this app to
>> record a
>> video how they play a game and post the video on the web etc.
>> 
>> Anyone can point me to the right direction to get it done?
>> Thanks a lot.
> 
> 
> ___
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/jche128%40gmail.com
> 
> This email sent to jche...@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:
 https://lists.apple.com/mailman/options/cocoa-dev/alex%40webis.net
 
 This email sent to a...@webis.net
>>> 
>>> 
>>> Alex Kac - El capitán
>>> 
>>> 
>>> ___
>>> 
>>> 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:
>>> 
>> https://lists.apple.com/mailman/options/cocoa-dev/websites%40paperetto.com
>>> 
>>> This email sent to websi...@paperetto.com
>> 
>> 
>> 
>> --
>> David Brittain
>> da...@paperetto.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:
> https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com
> 
> This email sent to clarkc...@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

H

Re: Problem Archiving/Un-archiving Custom Objects

2016-01-22 Thread Clark S. Cox III

> On Jan 22, 2016, at 06:14, Dave  wrote:
> 
> 
>> On 21 Jan 2016, at 23:40, Quincey Morris 
>>  wrote:
>> 
>> On Jan 21, 2016, at 15:22 , Dave > > wrote:
>>> 
>>> I’m relying of the copy attribute for the NSString’s, do I need to change 
>>> these to do a [xxx copy] too
>> 
>> If you’re writing the setter yourself, you must do the copy yourself. If 
>> you’re using the synthesized setter, it’s done for you.
>> 
>> In your own code, you may as well be liberal with ‘copy’. It’s basically 
>> free (in run-time cost) in situations where you don’t need it. You don’t 
>> save anything by leaving it out.
>> 
> 
> I’ve always been confused over what *actually* happens when you do something 
> like this:
> 
> @property (copy)  NSString*   pString;
> 
> 
> self.pString = [anotherString copy];
> 
> Do two new NSString objects get created? (I mean using the synthesized setter)

The -copy method is called twice, but what that means in practical terms 
depends on the object being copied.
If you're talking about NSString specifically, zero copies get created, as 
-copy on immutable foundation types is equivalent to -retain (or is a no-op 
under ARC).

If "anotherString" is an NSMutableString, then one copy will be created by the 
explicit call to -copy in your example. But that copy will, itself, be an 
immutable NSString, so the second copy will be a no-op.

And, of course, if we were talking about some other class that doesn't have a 
similar optimization, two copies will be created.

Regardless of the circumstances, that explicit copy is redundant (but harmless) 
under ARC, and will cause a memory leak under MRR.
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Problem Archiving/Un-archiving Custom Objects

2016-01-22 Thread Clark S. Cox III

> On Jan 22, 2016, at 06:14, Dave  wrote:
> 
> 
>> On 21 Jan 2016, at 23:40, Quincey Morris 
>>  wrote:
>> 
>> On Jan 21, 2016, at 15:22 , Dave > > wrote:
>>> 
>>> I’m relying of the copy attribute for the NSString’s, do I need to change 
>>> these to do a [xxx copy] too
>> 
>> If you’re writing the setter yourself, you must do the copy yourself. If 
>> you’re using the synthesized setter, it’s done for you.
>> 
>> In your own code, you may as well be liberal with ‘copy’. It’s basically 
>> free (in run-time cost) in situations where you don’t need it. You don’t 
>> save anything by leaving it out.
>> 
> 
> I’ve always been confused over what *actually* happens when you do something 
> like this:
> 
> @property (copy)  NSString*   pString;
> 
> 
> self.pString = [anotherString copy];
> 
> Do two new NSString objects get created? (I mean using the synthesized setter)

The -copy method is called twice, but what that means in practical terms 
depends on the object being copied.
If you're talking about NSString specifically, zero copies get created, as 
-copy on immutable foundation types is equivalent to -retain (or is a no-op 
under ARC).

If "anotherString" is an NSMutableString, then one copy will be created by the 
explicit call to -copy in your example. But that copy will, itself, be an 
immutable NSString, so the second copy will be a no-op.

And, of course, if we were talking about some other class that doesn't have a 
similar optimization, two copies will be created.

Regardless of the circumstances, that explicit copy is redundant (but harmless) 
under ARC, and will cause a memory leak under MRR.
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: The joys of people using valueForKey to get objects out of a dictionary.

2015-11-10 Thread Clark S. Cox III

> On 2015/11/10, at 8:32, Alex Zavatone  wrote:
> 
> It's been about 4 or 5 years since I made this mistake but I've just seen a 
> massive swath of code where every access of a dictionary object is using 
> valueForKey instead of objectForKey.
> 
> I've got a few examples of why this is a "really bad idea"™, and certainly 
> might explain why lots of that code is wrapped in try/catch blocks.
> 
> Am I correct that using valueForKey will raise an exception if the key is 
> missing?

No; it returns nil.

> Looking for reasons why I can explain "yeah, I know it works, but here's why 
> it's a terrible idea to use to access a dictionary's objects".
> 
> Thanks in advance.
> ___
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com
> 
> This email sent to clarkc...@gmail.com

-- 
Clark Smith Cox III
clarkc...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Dead Reckoning

2015-10-13 Thread Clark S. Cox III

> On 2015/10/09, at 22:24, Michael de Haan   wrote:
> 
> let secondsToHours = 2.778E-4

Only tangentially related, but that value (i.e. 1 / 3600) has a hex 
representation that is almost too beautiful not to use:
0x1.23456789ABCDEFp-12

:)
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Fwd: Identifying a specific Mac model

2015-09-18 Thread Clark S. Cox III

> On 2015/09/16, at 1:38, Marek Hrušovský  > wrote:
> 
> Many thanks.
> What I have discovered is that they track model version as well:
> 
> Exported UTI
> com.apple.macbook-retina-silver
> com.apple.device-model-code
> MacBook8,1@ECOLOR=225,225,223
> 
> com.apple.macbook-retina-gold
> com.apple.device-model-code
> MacBook8,1@ECOLOR=235,215,191
> 
> com.apple.macbook-retina-space-gray
> com.apple.device-model-code
> MacBook8,1@ECOLOR=155,158,159
> MacBook8,1@ECOLOR=157,157,160
> 
> NSImage *image =[[NSWorkspace sharedWorkspace] iconForFileType:
> @"com.apple.macbook-retina-gold"];
> 
> What's shocking is that they left icons for the new hardware there before
> announcement:
> E.g this folder contains new watch colors/ iPhone6s/iPhone6s Plus and iPad4
> mini (not the TV 4rd)
> "
> /System/Library/CoreServices/CoreTypes.bundle/Contents/Library/MobileDevices.bundle/Contents/Resources
> “

FYI: The 
“System/Library/CoreServices/CoreTypes.bundle/Contents/Library/MobileDevices.bundle”
 bundle is installed by Xcode. Those icon's weren't there  on your machine 
before the announcement :)
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Thread-safe atomic property for array

2015-08-15 Thread Clark S. Cox III

> On Aug 15, 2015, at 05:21, Sandy McGuffog  wrote:
> 
> What guarantees that the current autorelease cycle doesn’t end in the middle 
> of this code?

Because that’s how autorelease pools work.

> Actually, as I think about it, technically, the [[hostObject myArray] retain] 
> should be wrapped in some kind of lock mechanism itself to make it atomic….

Nope. If, as has already been stated, myArray is an atomic property, that is 
already taken care of for you.

>> On Aug 15, 2015, at 2:10 PM, Mike Abdullah  wrote:
>> 
>>> On 15 Aug 2015, at 13:07, Sandy McGuffog  wrote:
>>> 
 On Aug 15, 2015, at 1:14 PM, Mike Abdullah  wrote:
 
 NSArray *array = [hostObject myArray];
 // run your checks, etc.
 NSString *someString = [array objectAtIndex:2];
>>> 
>>> Just to be safe:
>>> 
>>> NSArray *array = [[hostObject myArray] retain];
>>> // run your checks, etc.
>>> NSString *someString = [array objectAtIndex:2];
>>> [array release];
>>> 
>>> Or whatever other way of ensuring the array isn’t dealloced out from under 
>>> you, depending on how you’re doing memory management
>> 
>> No need. The OP has stated myArray is an atomic property. It’s guaranteed 
>> not to go away until the end of the current autorelease pool.
>> 
>> If the above code did actually add some protection, it would mean the first 
>> line of code had a race condition in it where you might not be able to 
>> retain in time. You’d just be hiding the problem and making it less likely, 
>> rather than actually fixing it.
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com
> 
> This email sent to clarkc...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: C Assert in BSD Static Library

2015-06-28 Thread Clark S. Cox III

> On Jun 23, 2015, at 17:24, Raglan T. Tiger  wrote:
> 
>> On Jun 23, 2015, at 5:48 PM, Scott Ribe  wrote:
>> 
>> Just to be clear, =1 is actually not necessary.
> 
> 
> Yes.  But of course Xcode puts DEBUG=1 in the debug configuration.
> 
> Just doing belt and suspenders.
> 
> What if the compiler did 
> 
> #ifdef NDEBUG
> 
> if ( NDEBUG == 1 ) 
> 
> #endif

If the compiler is doing that, then it is simply wrong. If NDEBUG is defined at 
all, then assert is disabled. This is guaranteed by the C standard.

-- 
Clark S. Cox III
clarkc...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: NSBezierPath + thin lines + antialias = :(

2015-02-10 Thread Clark S. Cox III

> On Feb 10, 2015, at 15:34, Clark S. Cox III  wrote:
> 
>> 
>> On Feb 10, 2015, at 12:20, Quincey Morris 
>>  wrote:
>> 
>> On Feb 10, 2015, at 11:23 , Jerry Krinock  wrote:
>>> 
>>> I’ve always wondered why, when you’re dragging a window around a non-Retina 
>>> screen, the anti-aliasing doesn’t show a “comb filter” kind of effect, with 
>>> different lines getting fuzzy and sharp as they are dragged on and off 
>>> their pixels.  Looking at this closely today, I think the explanation may 
>>> be that
>>> 
>>> (1) Although you need to look carefully, Apple has constrained
>>> dragging windows to “snap" to the grid of backing pixels.
>>> You cannot move a window by one half pixel.
>>> (2) A window’s intrinsic scrollers, title bars, etc. are also 
>>> on a 1-pixel grid.
>>> (3) Any control or view that you place into Interface Builder
>>> must be on a 1-pixel grid.  I just tried entering a decimal
>>> fraction, 139.5, and after I ended editing, it was rounded
>>> down to 139.
>> 
>> Case #3 is actually points, not pixels. Cases #1 and #2 may be points, too, 
>> but I don’t know.
>> 
>> Then there’s #1A and #3A — meaning: positioning those elements 
>> programmatically. Even though you can’t place a button off the 1-point grid 
>> in IB, you might be able to do it programmatically. Or not.
>> 
>> Also, be careful about conceptualizing backing “pixels”. On an iPhone 6+, 
>> the backing store is 2x, but the hardware is 3x. (Let’s hope I got that the 
>> right way round.)
> 
> You got it backwards :)
> 
> The app renders into a 3x backing store (i.e. each point is represented by a 
> 3x3 grid of pixels).
> 
> As far as the app is concerned, it is rendering to a 1242 x 2208 pixel 
> (414x736 point) screen, but that is scaled down to the hardware resolution of 
> 1080x1920 pixels.


A good visualization of this:

http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions 
<http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions>




smime.p7s
Description: S/MIME cryptographic 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: NSBezierPath + thin lines + antialias = :(

2015-02-10 Thread Clark S. Cox III

> On Feb 10, 2015, at 12:20, Quincey Morris 
>  wrote:
> 
> On Feb 10, 2015, at 11:23 , Jerry Krinock  wrote:
>> 
>> I’ve always wondered why, when you’re dragging a window around a non-Retina 
>> screen, the anti-aliasing doesn’t show a “comb filter” kind of effect, with 
>> different lines getting fuzzy and sharp as they are dragged on and off their 
>> pixels.  Looking at this closely today, I think the explanation may be that
>> 
>> (1) Although you need to look carefully, Apple has constrained
>>  dragging windows to “snap" to the grid of backing pixels.
>>  You cannot move a window by one half pixel.
>> (2) A window’s intrinsic scrollers, title bars, etc. are also 
>>  on a 1-pixel grid.
>> (3) Any control or view that you place into Interface Builder
>>  must be on a 1-pixel grid.  I just tried entering a decimal
>>  fraction, 139.5, and after I ended editing, it was rounded
>>  down to 139.
> 
> Case #3 is actually points, not pixels. Cases #1 and #2 may be points, too, 
> but I don’t know.
> 
> Then there’s #1A and #3A — meaning: positioning those elements 
> programmatically. Even though you can’t place a button off the 1-point grid 
> in IB, you might be able to do it programmatically. Or not.
> 
> Also, be careful about conceptualizing backing “pixels”. On an iPhone 6+, the 
> backing store is 2x, but the hardware is 3x. (Let’s hope I got that the right 
> way round.)

You got it backwards :)

The app renders into a 3x backing store (i.e. each point is represented by a 
3x3 grid of pixels).

 As far as the app is concerned, it is rendering to a 1242 x 2208 pixel 
(414x736 point) screen, but that is scaled down to the hardware resolution of 
1080x1920 pixels.

> Something similar is true of the Retina iMac/MacBook, too, though it’s 
> complicated by having multiple logical resolutions.
> 
> 
> 
> ___
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com
> 
> This email sent to clarkc...@gmail.com



smime.p7s
Description: S/MIME cryptographic 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: ARC query

2015-01-07 Thread Clark S. Cox III

> On Jan 7, 2015, at 12:55, Sean McBride  wrote:
> 
> On Wed, 7 Jan 2015 12:02:16 -0600, Ken Thomases said:
> 
>> Short answer: yes, the alert is retained.
> 
> Meaning that one must use the weak/strong dance pattern like this?

No. The weak/strong dance would only be needed if NSAlert held on to the 
completion handler for multiple calls. This is not the case here, the 
completion handler is called once and is then discarded

> NSAlert *alert = [NSAlert new];
> alert.alertStyle = NSWarningAlertStyle;
> alert.messageText =  @“Do not touch!";
> __weak NSAlert* weakAlert = alert;
> [alert beginSheetModalForWindow:self.window 
> completionHandler:^(NSModalResponse returnCode) {
> NSAlert *strongAlert = weakAlert;
>   [strongAlert orderOut:self];
> }];
> 
> I miss garbage collection.  None of that was necessary.  I still haven't got 
> my head around dealing with this under ARC...


-- 
Clark Smith Cox III
clarkc...@gmail.com



smime.p7s
Description: S/MIME cryptographic 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Debugging memory leak in NSURLSession with ARC

2015-01-01 Thread Clark S. Cox III

> On Jan 1, 2015, at 18:26, Graham Cox  wrote:
> 
> 
>> On 2 Jan 2015, at 12:48 pm, Quincey Morris 
>>  wrote:
>> 
>>  That usually means the block and the ‘self’ it captured mutually refer 
>> to each other. I’m betting this is what’s wrong in your case.
>> 
>> 
> 
> 
> Quincey, thanks for your lengthy and well-thought-out reply (as usual) :)
> 
> I think you've hit the nail straight on the head (as usual), with the 
> block/self problem. It's one I knew about before, but had forgotten again in 
> my excitement at getting the code running. The question is what to do about 
> it.
> 
> My handler block refers to 'self' quite extensively - it calls other methods 
> of self and also refers to properties such as self.delegate. I'm not quite 
> sure how I can rework it not to refer to self. Maybe I just need to not use 
> the completion block approach and use a delegate callback instead. I need to 
> go away and think about this... thanks for the slap about the head.
> 
> —Graham

One of the first things I define in any ARC codebase I’m going to be working on 
is:

#define DECLARE_WEAK_SELF  __weak __typeof__(self) weak_self = self;
#define DECLARE_STRONG_SELF__strong __typeof__(weak_self) self = weak_self;

And I use it like so:

- (void)method {
DECLARE_WEAK_SELF

self.someBlock = ^{
DECLARE_STRONG_SELF;
//Use “self” as usual here
};

self.someOtherBlock = ^{
DECLARE_STRONG_SELF;
//Use “self” as usual here
};
}

-- 
Clark Smith Cox III
clarkc...@gmail.com



smime.p7s
Description: S/MIME cryptographic 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: WTF is happening?

2014-12-15 Thread Clark S. Cox III
That does not mean that they're using "Object" only that they're using a base 
class other than "NSObject" or "NSProxy". Why can't you just ignore such 
classes?

Sent from my iPhone

> On Dec 14, 2014, at 23:31, Maxthon Chan  wrote:
> 
> My class scanning returned several OS* classes that does not conform to 
> NSObject protocol.
> 
>>> On Dec 15, 2014, at 00:29, Clark S. Cox III  wrote:
>>> 
>>> 
>>> On Dec 13, 2014, at 11:57, Maxthon Chan  wrote:
>>> 
>>> NSProxy checking actually work, but throwing those classes that derive from 
>>> Object class (note I used capitalised O here, the old Object class from 
>>> early NeXT times, also used heavily in OS X kernel, GCD and Mach ports)
>> 
>> What makes you think that Object is used in *any* of those places?
>> 
>>> into the mix means that no method can be sent before class is determined. I 
>>> would suggest Apple add one runtime function class_isSubclassOfClass() that 
>>> mirrors the functionality of NSObject and NSProxy method isSubclassOfClass 
>>> so that derivatives of the old Object class can be detected more easily.
>>> 
>>>> On Dec 14, 2014, at 03:49, Gary L. Wade  
>>>> wrote:
>>>> 
>>>> Are you saying that Apple's well-documented approach to see if an object 
>>>> is derived from NSProxy does not work? If that's the case, you need to 
>>>> submit a bug report to Apple. That's a serious issue that only Apple can 
>>>> help you with.
>>>> 
>>>> If you are using objects not derived from NSObject nor NSProxy, then 
>>>> change your design.
>>>> --
>>>> Gary L. Wade (Sent from my iPad)
>>>> http://www.garywade.com/
>>>> 
>>>>> On Dec 13, 2014, at 11:40 AM, Maxthon Chan  wrote:
>>>>> 
>>>>> Ain’t work! Will crash if an Object derivative showed up.
>>>>> 
>>>>> I am scanning ALL loaded classes and only subclasses of a certain class 
>>>>> is interested. But due to the nature of this class scanning before I can 
>>>>> make sure that the class derives from NSObject I cannot call any method 
>>>>> on it.
>>>>> 
>>>>>> On Dec 14, 2014, at 03:34, Gary L. Wade  
>>>>>> wrote:
>>>>>> 
>>>>>> If all you care about is if an object is a proxy or not, look at isProxy.
>>>>>> --
>>>>>> Gary L. Wade (Sent from my iPad)
>>>>>> http://www.garywade.com/
>>>>>> 
>>>>>>> On Dec 13, 2014, at 11:06 AM, Maxthon Chan  wrote:
>>>>>>> 
>>>>>>> What I am doing here is scanning all loaded classes for subclasses of a 
>>>>>>> certain class. Before any NSObject method can be issued I have to check 
>>>>>>> if it is actually NSObject or NSProxy derivative instead of an Object 
>>>>>>> derivative that does not support NSObject methods. This calls for 
>>>>>>> runtime equivalent for one of the following NSObject methods:
>>>>>>> 
>>>>>>> - [NSObject respondsToSelector:(SEL)aSelector] = 
>>>>>>> class_respondsToSelector(Class, SEL) // this crashed.
>>>>>>> + [NSObject conformsToProtocol:(Protocol *)aProtocol] = 
>>>>>>> class_conformsToProtocol(Class, Protocol *) // check for NSObject 
>>>>>>> protocol, this does not work.
>>>>>>> + [NSObject isSubclassOfClass:(Class)aClass] // no equivalent, have to 
>>>>>>> implement it myself
>>>>>>> 
>>>>>>> I ended up creating this:
>>>>>>> 
>>>>>>> BOOL class_isSubclassOfClass(Class cls, Class other)
>>>>>>> {
>>>>>>> for (Class c = cls; c; c = class_getSuperclass(c))
>>>>>>>   if (c == other)
>>>>>>>   return YES;
>>>>>>> return NO;
>>>>>>> }
>>>>>>> 
>>>>>>> If i remembered it right GNUstep runtime have this function. I will 
>>>>>>> file a bug report to Apple and ask them to add this, as it is useful in 
>>>>>>> class scanning and i am using this technique heavily in jailbreak 
>>>>>>> detection.
>>>>>>> 
>>>>>>>> On Dec 14, 2014, at 01:20, Kyle Sluder  wrote:
>>>>>>>> 
>>>>>>>>> On Sat, Dec 13, 2014, at 10:19 AM, Phillip Mills wrote:
>>>>>>>>> Why do you think the problem is with “respondsToSelector:”? The error
>>>>>>>>> says you’re accessing past the end of a string.
>>>>>>>> 
>>>>>>>> Because the crash happens in a call stack that originates in
>>>>>>>> class_respondsToSelector, and involves none of Maxthon's code.
>>>>>>>> 
>>>>>>>> --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:
>>> https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com
>>> 
>>> This email sent to clarkc...@gmail.com
> 


smime.p7s
Description: S/MIME cryptographic 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: WTF is happening?

2014-12-14 Thread Clark S. Cox III

> On Dec 13, 2014, at 11:57, Maxthon Chan  wrote:
> 
> NSProxy checking actually work, but throwing those classes that derive from 
> Object class (note I used capitalised O here, the old Object class from early 
> NeXT times, also used heavily in OS X kernel, GCD and Mach ports)

What makes you think that Object is used in *any* of those places?

> into the mix means that no method can be sent before class is determined. I 
> would suggest Apple add one runtime function class_isSubclassOfClass() that 
> mirrors the functionality of NSObject and NSProxy method isSubclassOfClass so 
> that derivatives of the old Object class can be detected more easily.
> 
>> On Dec 14, 2014, at 03:49, Gary L. Wade  wrote:
>> 
>> Are you saying that Apple's well-documented approach to see if an object is 
>> derived from NSProxy does not work? If that's the case, you need to submit a 
>> bug report to Apple. That's a serious issue that only Apple can help you 
>> with.
>> 
>> If you are using objects not derived from NSObject nor NSProxy, then change 
>> your design.
>> --
>> Gary L. Wade (Sent from my iPad)
>> http://www.garywade.com/
>> 
>>> On Dec 13, 2014, at 11:40 AM, Maxthon Chan  wrote:
>>> 
>>> Ain’t work! Will crash if an Object derivative showed up.
>>> 
>>> I am scanning ALL loaded classes and only subclasses of a certain class is 
>>> interested. But due to the nature of this class scanning before I can make 
>>> sure that the class derives from NSObject I cannot call any method on it.
>>> 
 On Dec 14, 2014, at 03:34, Gary L. Wade  
 wrote:
 
 If all you care about is if an object is a proxy or not, look at isProxy.
 --
 Gary L. Wade (Sent from my iPad)
 http://www.garywade.com/
 
> On Dec 13, 2014, at 11:06 AM, Maxthon Chan  wrote:
> 
> What I am doing here is scanning all loaded classes for subclasses of a 
> certain class. Before any NSObject method can be issued I have to check 
> if it is actually NSObject or NSProxy derivative instead of an Object 
> derivative that does not support NSObject methods. This calls for runtime 
> equivalent for one of the following NSObject methods:
> 
> - [NSObject respondsToSelector:(SEL)aSelector] = 
> class_respondsToSelector(Class, SEL) // this crashed.
> + [NSObject conformsToProtocol:(Protocol *)aProtocol] = 
> class_conformsToProtocol(Class, Protocol *) // check for NSObject 
> protocol, this does not work.
> + [NSObject isSubclassOfClass:(Class)aClass] // no equivalent, have to 
> implement it myself
> 
> I ended up creating this:
> 
> BOOL class_isSubclassOfClass(Class cls, Class other)
> {
> for (Class c = cls; c; c = class_getSuperclass(c))
>if (c == other)
>return YES;
> return NO;
> }
> 
> If i remembered it right GNUstep runtime have this function. I will file 
> a bug report to Apple and ask them to add this, as it is useful in class 
> scanning and i am using this technique heavily in jailbreak detection.
> 
>> On Dec 14, 2014, at 01:20, Kyle Sluder  wrote:
>> 
>> On Sat, Dec 13, 2014, at 10:19 AM, Phillip Mills wrote:
>>> Why do you think the problem is with “respondsToSelector:”?  The error
>>> says you’re accessing past the end of a string.
>> 
>> Because the crash happens in a call stack that originates in
>> class_respondsToSelector, and involves none of Maxthon's code.
>> 
>> --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:
> https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com
> 
> This email sent to clarkc...@gmail.com



smime.p7s
Description: S/MIME cryptographic 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Crash with ARC enabled on Xcode 6.1

2014-10-23 Thread Clark S. Cox III

> On Oct 23, 2014, at 15:26, Kyle Sluder  wrote:
> 
> On Thu, Oct 23, 2014, at 05:06 PM, Greg Parker wrote:
>> 
>>> On Oct 23, 2014, at 2:18 AM, Kevin Meaney  wrote:
>>> 
>>> From what I understand any code that is executed before main is called is 
>>> done so before the objective-c runtime is fully setup which means you have 
>>> no guarantees about what will work. In objective-c++ where you can create 
>>> static C++ objects that results in objective-c being called it is an easy 
>>> way to make difficult to track crashes.
>> 
>> The situation is much more favorable than that. Problems with Objective-C
>> initialization are uncommon.
>> 
>> The initialization order is generally like this:
>> 1. Everything in libraries you link to is initialized.
>> 2. Your classes' +load methods run. Each class runs +load before its
>> subclasses. (Timing of category +load is more complicated, but in most
>> cases they also run now.)
>> 3. Your C and C++ static constructors run.
>> 4. main()
> 
> Is it accurate to say that Objective-C +initialize methods happen, at
> the earliest, as part of Step 3?

No. +initialize is called the first time a particular class or its subclasses 
are sent a message (other than +load or +initialize). If you never call any 
methods on a class or its subclass, then that class’ +initialize will never be 
called.


-- 
Clark Smith Cox III
clarkc...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Can a 32bit only MacOS Application use 64bit-only Frameworks?

2014-10-01 Thread Clark S. Cox III
We couldn't provide the new runtime for 32-bit Intel (or PowerPC, for that 
matter) because that would break compatibility with all existing code. 32-bit 
arm didn't have that issue because the only existing code that mattered was 
Apple's own apps, and we could easily recompile those.

Sent from my iPhone

> On Oct 1, 2014, at 01:53, Motti Shneor  wrote:
> 
> Thank you Clark and Mike for the answer. I finally figured it out myself 
> getting enough link errors.
> 
> One small question though. How is it the new ObjC runtime (ARC and all...) 
> works fine on 32bit iOS builds, but not on Mac? Why did apple not deliver the 
> runtime for the Mac? Is it so different? I know the processors aren't the 
> same, but at the cost of some inefficiency in the runtime, developers would 
> have much easier time going to ARC and modern Objective-C.
> 
> Any idea why this situation?
> 
> Motti.
>> On 30 בספט 2014, at 23:54, "Clark S. Cox III"  wrote:
>> 
>> 
>> 
>>> On Sep 30, 2014, at 12:49, Motti Shneor  wrote:
>>> 
>>> Hello everyone. This seems to be an upside-down question, but bare with 
>>> me...
>>> 
>>> Our Mac Client-side application can (sadly) only be built and run in 
>>> 32bit-only. Reason is: bit parts of it are legacy 32bit-only C++ code 
>>> shared with other platforms (Windows, Android, Linux, etc.) client code as 
>>> well as the Windows-only server. This code contains  networking-protocol 
>>> code which is 64bit unsafe, and so it can't really be replaced. 
>>> 
>>> Until All platforms and products move together to 64bit, we're bound to 
>>> build our app 32bit only.
>>> 
>>> Now I'm building a new module for this application as an external private 
>>> dynamic framework. I would like to use ARC, and the new niceties of modern 
>>> Obj-C runtime for the new framework, but these are only available in 
>>> 64bit-only builds.
>>> 
>>> So… Could my 32bit-only Mac Application depend-on, load, link, and use, a 
>>> 64bit-only framework?
>> 
>> No.
>> 
>> You basically have two options:
>> 
>> 1) Build a helper app or tool that is 64-bit (and can therefore link 64-bit 
>> code) and call that too, from your 32-bit app
>> 2) Move your 64-bit-unsafe code into a helper tool and make the rest of the 
>> app 64-bit.
>> 
>> Both options rely on having two separate processes, one running 32-bit code 
>> and one running 64-bit code, and only differ in which you put in the main 
>> app and which you put in the helper.
>> 
>> 
>> -- 
>> Clark Smith Cox III
>> clarkc...@gmail.com
> 
> Motti Shneor
> e-mail: motti.shn...@gmail.com
> phone: +972-8-9267730
> mobile: +972-54-3136621
> 
> Ceterum censeo Microsoftinem delendam esse
> 
> 

___

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

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

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

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

Re: Can a 32bit only MacOS Application use 64bit-only Frameworks?

2014-09-30 Thread Clark S. Cox III


> On Sep 30, 2014, at 12:49, Motti Shneor  wrote:
> 
> Hello everyone. This seems to be an upside-down question, but bare with me...
> 
> Our Mac Client-side application can (sadly) only be built and run in 
> 32bit-only. Reason is: bit parts of it are legacy 32bit-only C++ code shared 
> with other platforms (Windows, Android, Linux, etc.) client code as well as 
> the Windows-only server. This code contains  networking-protocol code which 
> is 64bit unsafe, and so it can't really be replaced. 
> 
> Until All platforms and products move together to 64bit, we're bound to build 
> our app 32bit only.
> 
> Now I'm building a new module for this application as an external private 
> dynamic framework. I would like to use ARC, and the new niceties of modern 
> Obj-C runtime for the new framework, but these are only available in 
> 64bit-only builds.
> 
> So… Could my 32bit-only Mac Application depend-on, load, link, and use, a 
> 64bit-only framework?

No.

You basically have two options:

1) Build a helper app or tool that is 64-bit (and can therefore link 64-bit 
code) and call that too, from your 32-bit app
2) Move your 64-bit-unsafe code into a helper tool and make the rest of the app 
64-bit.

Both options rely on having two separate processes, one running 32-bit code and 
one running 64-bit code, and only differ in which you put in the main app and 
which you put in the helper.


-- 
Clark Smith Cox III
clarkc...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Updating iPad to 8.0 final

2014-09-22 Thread Clark S. Cox III

> On Sep 22, 2014, at 16:28, Rick Mann  wrote:
> 
> 
> On Sep 22, 2014, at 16:23 , Clark S. Cox III  wrote:
> 
>> 
>>> On Sep 18, 2014, at 10:36, Rick Mann  wrote:
>>> 
>>> I have an iPad, 3rd gen, Wi-Fi + Cellular (AT&T). It's model A1430. I 
>>> downloaded the appropriate .ipsw file (iPad3,2_8.0_12A365_Restore.ipsw), 
>>> but iTunes refuses to update it, saying "The iPad “XXX” could not be 
>>> updated because the firmware file is not compatible."
>> 
>> 
>> Are you sure you got the right image? I believe that iPad3,2 was the Verizon 
>> model, while iPad3,3 was the AT&T model.
> 
> It's very confusing. I know for certain it's an AT&T model. In the end, it 
> appears my iPad is already at 8.0 final, although I don't know when that 
> could have happened. Was b5 the same as final?

No. Beta 5 was 12A4345d, while the final GM is 12A365.

-- 
Clark Smith Cox III
clarkc...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Updating iPad to 8.0 final

2014-09-22 Thread Clark S. Cox III

> On Sep 18, 2014, at 10:36, Rick Mann  wrote:
> 
> I have an iPad, 3rd gen, Wi-Fi + Cellular (AT&T). It's model A1430. I 
> downloaded the appropriate .ipsw file (iPad3,2_8.0_12A365_Restore.ipsw), but 
> iTunes refuses to update it, saying "The iPad “XXX” could not be updated 
> because the firmware file is not compatible."


Are you sure you got the right image? I believe that iPad3,2 was the Verizon 
model, while iPad3,3 was the AT&T model.

-- 
Clark Smith Cox III
clarkc...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Arc: Switch case is in protected scope

2013-10-22 Thread Clark S. Cox III

On Oct 22, 2013, at 09:16, Scott Ribe  wrote:

> On Oct 22, 2013, at 9:50 AM, Sean McBride  wrote:
> 
>> I don't think you can quote the Standard about 'goto' and just wave your 
>> hands and say it applies to 'switch' also.  :)  The Standard's description 
>> of 'switch' should contain the answer
> 
> Switch is just a pile of goto, and I'm pretty sure the standard says so 
> somewhere.

It does not. Switch is defined without referencing goto at all.

-- 
Clark Smith Cox III
clarkc...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Arc: Switch case is in protected scope

2013-10-22 Thread Clark S. Cox III

On Oct 22, 2013, at 08:50, Sean McBride  wrote:

> On Tue, 22 Oct 2013 10:31:01 +0200, Daniel Höpfl said:
> 
>>> Was the old (non-arc) code faulty (but the compiler did not notice 
>>> this)?
>>> Why is the arc-version (with TRIGGER_ERROR defined) wrong?
>> 
>> It is wrong in the non-arc world, too. (ISO/IEC 9899:2011 AKA C11, 
>> 6.8.6.1: "A goto statement shall not jump from outside the scope of an 
>> identifier having a variably modified type to inside the scope of that 
>> identifier" - switch is a special case of goto.)
> 
> Daniel,
> 
> I don't think you can quote the Standard about 'goto' and just wave your 
> hands and say it applies to 'switch' also.  :)  The Standard's description of 
> 'switch' should contain the answer.

You are correct that that text doesn’t apply to switch statements. The closest 
is:

6.8.4.2 2:
“If a switch statement has an associated case or default label within the scope 
of an identifier with a variably modified type, the entire switch statement 
shall be within the scope of that identifier"

> However, it does seem to me there is a clang bug here somewhere.
> 
> I've made a shorter compilable example:
> 
> --
> #import 
> 
> int main (void)
> {
>   int x = 0;
>   switch(x)
>   {
>   case 1:
>   x++;
> #if 0 // toggle me
>   NSObject* foo = nil;
> #else
>   int* foo = 0;
> #endif
>   (void)foo;
>   break;
>   
>   default: 
>   x++;
>   };
> 
>   return 0;
> }
> --
> 
> Then build with both:
> $ xcrun clang -fsyntax-only -Weverything test.m
> $ xcrun clang -fsyntax-only -Weverything -fobjc-arc test.m
> 
> If 'foo' is int*, clang has no complaints in non-ARC and ARC.
> 
> If 'foo' is NSObject*, clang has no complaints in non-ARC, but errors in ARC.
> 
> IMHO, that's pretty weird!

The difference is that in non-ARC, both int* and NSObject* are allowed to be 
uninitialized, so jumping over the initialization of foo isn’t an issue. 
However, under ARC, object pointers must be initialized and cannot have an 
indeterminate value (even if you don’t provide an initial value at the 
definition, it is implicitly set to nil). It is not legal to jump over the 
initialization in that case (in much the same way as in C++ it is not legal to 
jump over the construction of a variable).

-- 
Clark Smith Cox III
clarkc...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: 3rd party executable in iOS project

2013-10-21 Thread Clark S. Cox III

On Oct 21, 2013, at 20:02, Maxthon Chan  wrote:

> No, this pipe/fork/dup2/exec is used in App Store apps -

No. I am sorry, but you are wrong.

> iSSH is an example as it used its separate PuTTY executable.

iSSH does not use a separate executable. It is not possible to do so from a 3rd 
party iOS app.

> Maybe straight fork() is not available but is there some replacement like 
> posix_spawn()? iOS itself need some sort of mechanism to fork/exec or there 
> will be no apps.

Any attempt to create a new process (whether by fork or posix_spawn or 
whatever) will fail if called from a 3rd party iOS app.

> 
> On Oct 22, 2013, at 10:56, Jens Alfke  wrote:
> 
>> 
>> On Oct 21, 2013, at 7:02 PM, ChanMaxthon  wrote:
>> 
>>> 2) You can still use classic UNIX function calls to pipe/fork/dup2/exec
>> 
>> I think this is another of those “…ok, only if you jailbreak your device or 
>> maybe if you’re building an enterprise-only app” things, right? You should 
>> really make that clear, because I bet the vast majority of people here are 
>> writing for the App Store.

-- 
Clark Smith Cox III
clarkc...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Any way to get a warning if a non-boolean type is used in an if expression?

2013-10-16 Thread Clark S. Cox III

On Oct 16, 2013, at 21:44, Rick Mann  wrote:

> 
> On Oct 16, 2013, at 21:16 , Keary Suska  wrote:
> 
>> "if (self.active)" should never flag a warning, because it is not only 
>> perfectly legal but also not in any way an odd construct. The compiler can't 
>> know that you might not be testing for a nil value, for instance. Some 
>> advocate always having an explicit r-value, e.g. "if (self.active != nil)", 
>> which always makes the intention clear, but it is only a convention one 
>> could use to avoid ambiguity. In your case, this convention might have 
>> helped since implicit pointer conversion is usually flagged.
> 
> I realize this, which is why I asked for a warning. clang is smart enough to 
> recognize (I think) if something is actually its BOOL type, and I'd settle 
> for this only working in Objective-C++. Maybe that's why it didn't work.
> 
> I never use the perfectly legitimate but IMO lazy test for nil; I always make 
> it explicit, and I accept this requirement when turning on the warning. 
> Forcing that is much better than missing things like the one I missed.

Note that it is more complex than just looking for a boolean type. Remember 
that operators such as “<“, “==“ or “!” return int, and not _Bool, so something 
like this:

> if (self.active != nil)


is an if statement using a non-boolean type (because "self.active != nil” is an 
“int", not “_Bool”, “BOOL" or “bool").

Either way, I would recommend filing a bug asking for your warning.

-- 
Clark Smith Cox III
clarkc...@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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: How to add device to Team Provisioning Profile?

2013-07-29 Thread Clark S. Cox III
I can understand the frustration, but under most circumstances, editing a team 
profile would be ill-advised, as any changes you made would be overwritten the 
next time anyone on the team connected via Xcode.

You can certainly make a case in a bug report, especially in light of the 
recent downtime, that it would still be useful to allow manually editing the 
team profile in spite of the risk of losing your changes.

Sent from my iPhone

> On Jul 29, 2013, at 23:04, Rick Mann  wrote:
> 
> 
>> On Jul 29, 2013, at 22:33 , Clark S. Cox III  wrote:
>> 
>> No, but you can create a new profile in the meantime with the same appid, 
>> all of your team's devices and all of your team's development certificates.
>> 
>> Once the Xcode integration is back up and running, you can just delete that 
>> profile and go back to using the automatically generated one.
> 
> Irritating that I can't manage the team profile from the web portal.
> 
> -- 
> Rick
> 
> 
> 


smime.p7s
Description: S/MIME cryptographic 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: How to add device to Team Provisioning Profile?

2013-07-29 Thread Clark S. Cox III
No, but you can create a new profile in the meantime with the same appid, all 
of your team's devices and all of your team's development certificates.

Once the Xcode integration is back up and running, you can just delete that 
profile and go back to using the automatically generated one.

Sent from my iPhone

> On Jul 29, 2013, at 21:25, Rick Mann  wrote:
> 
> Since Xcode provisioning is still down, is there another way to add a UDID to 
> the team provisioning profile?
> 
> -- 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/clarkcox3%40gmail.com
> 
> This email sent to clarkc...@gmail.com


smime.p7s
Description: S/MIME cryptographic 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: "byte orders" question

2011-12-13 Thread Clark S. Cox III

On Nov 26, 2011, at 4:23 PM, Kyle Sluder wrote:

> On Sat, Nov 26, 2011 at 4:17 PM, Greg Guerin  wrote:
>> Since you're just doing a memcpy(), you can simply cast the bits and avoid
>> the copying.  Try this:
>> 
>> float f = *((float*) &res);
>> 
>> Or try defining a C union:
>> 
>> union foo {  float f;  u_int32_t u;  };
>> union foo bar;
>> bar.u = CFSwapInt32HostToBig(value);
>> float f = bar.f;
> 
> Neither of these is legal.

Not true. The union solution is perfectly legal, and doesn't involve pointer 
aliasing.

> You are not allowed to alias a pointer to
> two different types (except pointer-to-char). See Section 6.5,
> paragraph 7 of the C99 standard:
> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf


See footnote 82:

"If the member used to access the contents of a union object is not the same as 
the member last used to store a value in the object, the appropriate part of 
the object representation of the value is reinterpreted as an object 
representation in the new type as described in 6.2.6 (a process sometimes 
called "type punning"). This might be a trap representation."

-- 
Clark S. Cox III
clarkc...@gmail.com

smime.p7s
Description: S/MIME cryptographic 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


Re: STAssertEquals and type-checking

2011-08-16 Thread Clark S. Cox III

On Aug 16, 2011, at 10:36 AM, Jens Alfke wrote:

> I’ve been using the STxxx test macros lately, as they’re the path of least 
> resistance, but I’m getting pretty frustrated with them. Worst is the way 
> that STAssertEquals is extremely picky about types (the actual and expected 
> parameters have to have exactly the same type), and worse, somehow manages to 
> defer the type checking until runtime, so you only find out when you get an 
> assertion failure.
> 
> So I keep making ‘mistakes’ like:
>   STAssertEquals(myArray.length, 32, nil);
> which compiles fine, but fails at runtime because -length returns an 
> NSUInteger and 32 is an int. Changing 32 to 32u works on 32-bit but not 
> 64-bit; the only form I’ve found that always works is the awkward
>STAssertEquals(digest.length, (NSUInteger)32, nil);
> Not surprisingly, I still forget to do this pretty often.

You could always define the NS_BUILD_32_LIKE_64 preprocessor macro. If you do 
that, then 32ul will be correct on all Mac/iOS platforms.


-- 
Clark S. Cox III
clarkc...@gmail.com



smime.p7s
Description: S/MIME cryptographic 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


Re: GC, plain C structs, and when to use __strong

2010-09-22 Thread Clark S. Cox III

On Sep 21, 2010, at 4:13 PM, Quincey Morris wrote:

> On Sep 21, 2010, at 15:37, Sean McBride wrote:
> 
>> If I have a plain C struct that contains some Obj-C object pointers like:
>> 
>> struct {
>> int boring;
>> NSString* string;
>> } MyStruct
>> 
>> What must I do to be safe in GC?
>> 
>> a) I know I must allocate my structs using NSAllocateCollectable and
>> NSScannedOption.
>> b) I'm pretty sure I don't need a '__strong' in my struct declaration.
>> (doc say "__strong is implicitly part of any declaration of an Objective-
>> C object reference type.")
>> c) I'm pretty sure if I use a pointer to this struct as an ivar, I must
>> tag it with __strong.
> 
> At risk of getting myself into trouble, I'd say correct, correct and correct.
> 
>> d) I'm not sure about passing pointers to this struct around.  Need I
>> tag all parameters and return values as __strong too?  ex:
>> 
>> void DoThing (__strong MyStruct* param) { ... }
> 
> At ditto risk, I'd say no to '__strong'. Variable 'param' is a stack variable 
> is therefore a *root* reference, and as such the concept of strong or weak 
> doesn't apply. (That is, AFAIK, applying '__strong' or '__weak' to a stack 
> variable *never* has any effect on its behavior in any way.)

Correct. As roots, the stack and registers (i.e. all ways that a parameter 
could be passed) are *always* effectively strong.


-- 
Clark S. Cox III
clarkc...@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: NSTreeController and insertObject:atArrangedObjectIndexPath:

2010-06-19 Thread Clark S. Cox III
You should only need add your object to your model (which needs to me KVO 
compliant). The tree controller will then notice, in response to the KVO 
notification that a new item was added.

You should rarely, if ever, be direcly adding objects to the controller layer 
like this. 

Sent from my iPhone

On Jun 18, 2010, at 18:53, Tony Romano  wrote:

> Scenario:  Adding a new node to a NSOutlineView backed by a NSTreeController.
> 
> 1. Create a new internal object add add it to the data store(file system).  
> This will be my representedObject in the treecontroller
> 2. Compute the path and call insertObject:atArrangedObjectIndexPath:
> 
> the treecontroller does 2 things during the call to insertObject:
> 
> 1. It calls my getter, children, and asks me for all the children under the 
> parent node I have added the new node to.  I give it the list INCLUDING the 
> newly created node since it is now in the store.
> 2. Then it calls the setter, setChildren,  and gives me the newChildren list. 
>  Which now has an additional copy of the new node, one from the getter call 
> and one from the insertAt call. I know this for a fact because I purposely 
> added some data to the newly created node for the insert to distinguish them.
> 
> From the UI, the outlineview is correct, but my internal child list has the 
> extra node.  It's not displayed because the treecontroller optimizes when to 
> ask me for a childlist.  I have a work around which I don't like to basically 
> lock out the getter method and just return the current child list(i.e the 
> previous child list which doesn't have the new node added from the file 
> system).  Anyone experience this before and have a recommendation?
> 
> TIA,
> -Tony
> 
> ___
> 
> 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/clarkcox3%40gmail.com
> 
> This email sent to clarkc...@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: autorelease: how does this work!? (if at all)

2010-06-18 Thread Clark S. Cox III
That depends on how you define "subsystem". I see nothing wrong with the way 
the op is structuring this (i.e. doing the transformation on one serial queue, 
and doing the writing on another queue. This allows many if the transformations 
to complete without ever waiting on the disk, yet still serializes the disk 
access in a nice, orderly fashion.

If this were all on a single serial queue, you'd end up with the queue blocked 
while writing to disk, when the CPUs are otherwise idle and could have already 
started doing useful work on the next image(s).

As Bill said, this is a very common GCD idiom. 

Sent from my iPhone

On Jun 18, 2010, at 12:44, Tony Romano  wrote:

> Because you make 2 queues, doesn't mean internally they will operate on 
> separate cores/threads.  GCD may coalesce these based on system resources.  I 
> agree with the best practice you outlined; however, the example in this email 
> thread has 2 queues within the same subsystem.  So there must be some "trick" 
> I am not groc'ing within the snippet of code.  Anyhow, I think the OP got the 
> answer to his original question.
> 
> -Tony
> 
> On Jun 18, 2010, at 12:34 PM, Bill Bumgarner wrote:
> 
>> 
>> On Jun 18, 2010, at 12:09 PM, Tony Romano wrote:
>> 
>>> First, the objects are retained by dispatch_async as others have mentioned. 
>>>  Second, I'm not sure why you used 2 queues for the tasks in your code, 
>>> seems overly complex.  Async queues are serialized, which means that you 
>>> can continue to add to the queue and the jobs will be done in order which 
>>> they were added. The next job will not start until the previous one in the 
>>> queue is completed.   
>> 
>> To be precise, it is the Blocks runtime that takes care of memory 
>> management, triggered by dispatch_async()s copying of the block passed to it.
>> 
>> As for their being two queues, that pattern is actually pretty common.  A 
>> best practice is to subdivide your application into subsystems and then have 
>> one (or more, depending on concurrency used) queue per subsystem.The 
>> queues both allow the application to do work across many cores 
>> simultaneously while also providing a natural lock-less exclusion primitive 
>> per subsystem.
>> 
>> The trick is to keep the object graphs being acted upon within the 
>> subsystems relatively isolated from each other (with the points of 
>> contention being carefully considered).
>> 
>> b.bum
>> 
>> 
> 
> -Tony
> 
> ___
> 
> 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/clarkcox3%40gmail.com
> 
> This email sent to clarkc...@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: Calling allObjects memory allocation problem

2010-05-22 Thread Clark S. Cox III

On May 21, 2010, at 8:54 AM, Keary Suska wrote:

> On May 21, 2010, at 9:18 AM, Paul Sanders wrote:
> 
>>> Also be aware that just because memory is released, doesn't mean it is 
>>> returned to the system (e.g. you will not
>>> see your apps memory usage go down in Activity Monitor). In fact,  AFAIK, 
>>> it is never returned to the system,
>>> except perhaps in low memory situations.
>> 
>> I don't actually think that's true.  At least, it's not what I observe.  I 
>> think it's more accurate to say that you cannot predict when memory which 
>> has been allocated and then freed will be returned to the operating system, 
>> nor how much.  It happens, I believe, in 4k pages, but probably not one at a 
>> time and will be heavily dependent on fragmentation of the process's heap.  
>> No doubt there is much more to know.
>> 
>> I agree with the sentiment of keeping an eye on your peak memory usage.  I 
>> use Instruments for this, and it found one instance where memory usage was 
>> creeping steadily up when the app was playing audio but otherwise idle.
> 
> Maybe AFAIK should be "As Far As I have Observed", as although using tools 
> like instruments I have seen constant tiny increases and decreases, I have 
> yet to see peak memory reduce over the lifetime of an application. 
> Fragmentation could certainly play a role--I don't know of any means to check 
> that. If this truly is the issue most of the time, it seems to me that for 
> most practical points and purposes that the memory won't get returned anyway, 
> as fragmentation seems to be so common. 

Allocations below a certain size (which varies based on CPU and installed RAM 
and other factors) are unlikely to be returned to the OS. Instead, they are 
re-used for future allocations of similar size. Allocations above that size are 
allocated directly from the OS and are returned thereto upon deallocation. Of 
course, all of the parameters are subject to change (and have changed over 
various OS releases), but the general concept holds. This is, of course, why 
tools such as heap are much better for inspecting your process' memory usage 
than tools like Activity Monitor, as they are much better informed about the 
specific behavior of malloc.___

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: NSKeyedArchiver and NSPoints

2010-04-28 Thread Clark S. Cox III

On Apr 28, 2010, at 12:31 PM, Quincey Morris wrote:

> On Apr 28, 2010, at 11:42, Kyle Sluder wrote:
> 
>> Er? Unless there's some documentation about the precision of
>> NSStringFromPoint being less than that of the members,
>> NSStringFromPoint could certainly include just as much precision as
>> the actual float.
> 
> Assuming that the string contains a decimal floating point number, then both 
> the conversion to and from binary floating point involve (in general) 
> imprecision from rounding and/or truncation, since in both cases the result 
> could theoretically require an infinite number of decimal or binary places.
> 
> Keep in mind there are some binary floating point numbers with a finite 
> number of bits that have no exact representation in any finite decimal 
> string, and vice versa. It's certainly true that since both representations 
> are finite, then with enough decimal digits you could get very close (no more 
> error than 1 in the last binary digit), but very close is not the same as 
> exact.
> 
> Even if you could get back the original binary value by using enough decimal 
> digits, you'd still need to be certain that the binary to string conversion 
> in the frameworks was just that finicky (as opposed to, say, using a library 
> routine that defaults to a smallish maximum number of significant digits).
> 
> Plus, you'd have to expect that encoding doubles would require, in the worst 
> case, at least 309 significant digits, which is a much longer string than I 
> want in my archive.
> 
> So my original point stands: I want my original bit pattern back again after 
> unarchiving, and I don't believe that a finite decimal string will guarantee 
> that.


Then I would recommend using hex-float strings, as they are guaranteed to 
represent the exact value of the given floating point value (as binary fp to 
hex fp is lossless, unlike binary to dec):

[c...@ccox-macpro:~]% cat test.m
#import 

int main() {
NSPointp  = {3.141592653, 3.141592653};
NSString   *s = [NSString stringWithFormat: @"{%A, %A}", p.x, p.y];

NSLog(@"%@", s);

NSPointp2 = NSPointFromString(s);

if(memcmp(&p, &p2, sizeof p) == 0) {
NSLog(@"Bit-pattern was preserved");
} else {
NSLog(@"Bit-pattern was not preserved");
}

return 0;
}
[c...@ccox-macpro:~]% cc test.m -framework Foundation -fobjc-gc -arch x86_64 && 
./a.out
2010-04-28 14:06:19.396 a.out[90877:903] {0X1.921FB542FE938P+1, 
0X1.921FB542FE938P+1}
2010-04-28 14:06:19.399 a.out[90877:903] Bit-pattern was preserved
[c...@ccox-macpro:~]% cc test.m -framework Foundation -fobjc-gc -arch i386 && 
./a.out  
2010-04-28 14:06:22.478 a.out[90885:903] {0X1.921FB6P+1, 0X1.921FB6P+1}
2010-04-28 14:06:22.481 a.out[90885:903] Bit-pattern was preserved
[c...@ccox-macpro:~]% cc test.m -framework Foundation -fobjc-gc -arch ppc && 
./a.out   
2010-04-28 14:06:26.167 a.out[90893:903] {0X1.921FB6P+1, 0X1.921FB6P+1}
2010-04-28 14:06:26.204 a.out[90893:903] Bit-pattern was preserved

Since NSPointFromString isn't documented to work with hex-floats you may want 
to do the parsing yourself with NSScanner, but other than that, the principle 
is the same.


___

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: Localizing of print dialogs

2010-04-23 Thread Clark S. Cox III
Even the system resources only use the localized variant if the application 
itself is localized. If you don't have a Russian localization for your app, you 
wont get the russian system dialogs either. This keeps apps internally 
consistent. 

Sent from my iPad

On Apr 23, 2010, at 17:28, "danchik"  wrote:

> Hi, is there something that I need to do to make the dialogs (not the ones 
> included with app) come up localized?
> 
> For example, calling [printOperation runOperation] brings up the print dialog 
> always in English, even though the user language should be Russian for example
> 
> BUT doing print from say TextEdit does bring up the print dialog in Russian
> 
> I don't have anything localized at the moment, but I though that the system 
> resources like the print dialog would come up in the sysstem language??
> 
> Thank You
> Dan
> ___
> 
> 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/clarkcox3%40gmail.com
> 
> This email sent to clarkc...@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: ObjC question

2010-04-10 Thread Clark S. Cox III
You cannot. You will have a pointer of some kind in your Foo class that points 
to the current "container".

Sent from my iPad

On Apr 10, 2010, at 14:38, Tony Romano  wrote:

> Using the sample below,  how do I get the instance of the class in which I am 
> contained WITHOUT passing it as a parameter or using hacky sizeof tricks in 
> the method Foo:method?  Thanks people!  If this is not the correct alias for 
> this type of question, apologizes in advance.
> 
> 
> @interface Foo : NSObject
> {
>   id containerClass;
> }
> -(void) method;
> @end
> 
> @implementation Foo
> 
> -(void) method
> {
>   // set containerClass member to point to the instance in which I am 
> contained
>   // (i.e. the pointer to the instance of Bar.
>   // 'self' refers to an instance of Foo
> }
> @end
> 
> **
> 
> @interface Bar : NSObject
> {
>   Foo * f; // contains a Foo
> }
> @end
> 
> @implementation Bar
> - (id) init
> {
>   ...
>   
>   // Call 'method' on object 'f' of type Foo
>   [f method];
> 
>   ...
> }
> @end
> 
> 
> 
> -tony
> 
> 
> ___
> 
> 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/clarkcox3%40gmail.com
> 
> This email sent to clarkc...@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: CGPoint and KVO

2010-04-03 Thread Clark S. Cox III
The main issue with the original code is that it assumes that the value is a 
CGPoint. If it were anything smaller, you'd get garbage values in your point, 
and if it were any larger, you'd be stomping on memory as you ran off the end 
of your CGPoint variable.

Any time you use -[NSValue getValue:], you should check to make sure that the 
NSValue represents the correct type.

Sent from my iPad

On Apr 3, 2010, at 7:52, Roland King  wrote:

> Thanks
> 
> pointValue didn't work on iPhone OS but CGPointValue did, luckily, as that's 
> the one I needed. That seems to be a UIKit extension. I've switched to that. 
> 
> was my original method (apart from being clunky) wrong? It did work. 
> 
> 
> On 03-Apr-2010, at 10:43 PM, Kiel Gillard wrote:
> 
>> On 04/04/2010, at 1:40 AM, Roland King wrote:
>> 
>>> I have a property which is a CGPoint and I'm observing it. I didn't really 
>>> know what to expect in the change dictionary (I have NSKeyValueObservingOld 
>>> as the observation flags) so I stuck in a breakpoint and went looking. 
>>> After messing about in the debugger when the property was changed I found 
>>> the old value was an NSConcreteValue and the following code appears to work 
>>> to extract the CGPoint from it
>>> 
>>> CGPoint oldPoint; 
>>> id oldValue = [ change valueForKey:NSKeyValueChangeOld ]; 
>>> [ (NSValue*)oldValue getValue:&oldPoint ]
>>> 
>>> Is this correct? I've failed to find anything much in the KVO documentation 
>>> about CGPoint or how I should expect to receive structs or other primitives.
>> 
>> In the case of NSPoint/CGPoint:
>> 
>> CGPoint oldPoint = [oldValue pointValue];
>> 
>>> This is iPhone OS (incase that makes a difference). 
>>> ___
>>> 
>>> 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/kiel.gillard%40gmail.com
>>> 
>>> This email sent to kiel.gill...@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/clarkcox3%40gmail.com
> 
> This email sent to clarkc...@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: Allow only root/admin users to execute the cocoa app

2010-01-24 Thread Clark S. Cox III
Let me say: running Cocoa peograms as root is a *very* bad idea. There  
are many ways to get code loaded into applications, and if said  
program is running as root, that code will be running as root as well.


Show me a GUI application running as root, and I'll shoe you a  
trivially compromised system.


A much better idea would be to factor the code that needs to run with  
root privelages into a seperate tool, and to use Authorization  
Services to launch that tool as needed.


Sent from my iPhone

On Jan 24, 2010, at 1:19, Arun  wrote:


Hi All,

I want to allow my cocoa app to be only launched by root/admin users.
How can i achieve this?

Thanks
Arun
___

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/clarkcox3%40gmail.com

This email sent to clarkc...@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: There must be a better way

2009-12-25 Thread Clark S. Cox III
Of course they can. In the view's xib, the "File's Owner" object  
represents the object that is doing the loading of the xib. In this  
case, that is your view controller.


Sent from my iPhone

On Dec 23, 2009, at 16:18, Charlie Dickman <3tothe...@comcast.net>  
wrote:


Except  the view and the controller are in separate xib's so they  
can't be connected in this way.


On Dec 23, 2009, at 4:08 PM, Seth Willits wrote:


On Dec 23, 2009, at 11:19 AM, Charlie Dickman wrote:

In an iPod Touch/iPhone app where the view is in 1 xib and it's  
controller is in a different one, according to the view-controller- 
data paradigm, is there a better way to link the view to the  
controller than...


Surely the controller is File's Owner in the view's xib, so just  
use an outlet on the view and connect it to the controller.



--
Seth Willits



___

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/3tothe4th%40comcast.net

This email sent to 3tothe...@comcast.net


Charlie Dickman
3tothe...@comcast.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/clarkcox3%40gmail.com

This email sent to clarkc...@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: copyWithZone - if anyone could explain this to me ?

2009-11-30 Thread Clark S. Cox III



Sent from my iPhone

On Nov 30, 2009, at 17:26, Jeff Laing   
wrote:


In most cases, yes. However, copyWithZone: is special, the  
superclass'

implementation just blindly copies all of the raw bits in the source
object to the newly created one. If you were to use the normal
-setImage: call, that old value would be released one too many times.
Assigning to the instance variable in this case is the way to avoid
that.


Why would you not just do:

   [cell->image retain];

That makes it a lot clearer to me - since it was a bitwise copy,  
cell->image and image are identical values whereas the assignment  
looks like you are changing something.


Because it may *not* have been a bitwise copy. The superclass may have  
either done a bitwise copy of the whole object (the common case, I  
believe) or it may have only copied its *own* instance variables (in  
which case, cell->image will be nil). It's because of this uncertanty  
of which method the superclass uses that this, admittedly ugly, bit of  
code is used.


Generally, this is only an issue for people implementing copyWithZone:  
on an object that does not inherit directly from NSObject. 
___


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: different width in fastenumeration

2009-11-25 Thread Clark S. Cox III

You have the -Wconversion flag on.

Sent from my iPhone

On Nov 24, 2009, at 6:47, Hans van der Meer  wrote:


Doing NSDictionary *objects enumerate over its keys thus:
 for ( id key in [objects allKeys] ) {}

According to the documentation allKeys returns a NSArray and  
NSArray's conform to NSFastEnumeration. However on building this  
code generates the following warning:
 Passing argument 3 of 'countByEnumeratingWithState:objects:count'  
with different width due to prototype. [XCode 3.2.1 64-bit on 10.6.2]


What is happening? Am I doing something wrong here?

Hans van der Meer




___

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/clarkcox3%40gmail.com

This email sent to clarkc...@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: GC Re: Questions about Nib Object Retention

2009-10-21 Thread Clark S. Cox III
No, there is no race. While the nib is being loaded, there are plenty  
of references to the objects therein on the stack and in registers.  
These references will keep these objects alive during loading.


If you don't keep a strong reference to these objects during loading  
they will become garbage after nib loading is finished.


Sent from my iPhone

On Oct 21, 2009, at 7:45, Fritz Anderson   
wrote:


All this leads me to the paragraph about top-level objects under  
garbage collection:


===
Mac OS X - garbage collected memory model
Most objects in the graph are kept in memory through strong  
references between the objects. Only the top-level objects in the  
nib file do not have strong references initially. Thus, your code  
must create strong references to these objects to prevent the object  
graph from being released.

===

Does this mean that there's a race between the NIB loader's need to  
create a strong reference and the GC thread's imperative to collect  
the object before it is referenced?


   ― F

___

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/clarkcox3%40gmail.com

This email sent to clarkc...@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: Why does my font come out looking fuzzy?

2009-10-17 Thread Clark S. Cox III
There's also the possibility that the text isn't being drawn properly  
aligned to the pixel grid.


Sent from my iPhone

On Oct 17, 2009, at 19:52, Kyle Sluder  wrote:


You need to post a screenshot of what you're seeing.

I can think of two possibilities off the top of my head:
1) You're rendering text into a CALayer (especially a CATextLayer).
Without some tweaking, CALayer can't do subpixel antialiasing (aka LCD
antialiasing), because it doesn't have the existing backing store to
composite against.
2) You're overdrawing the text and are therefore ruining the
antialiasing, producing a distorted image.

Again, screenshot is pretty much mandatory here.

--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/clarkcox3%40gmail.com

This email sent to clarkc...@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: GC crash due to being naughty

2009-10-15 Thread Clark S. Cox III

That is simply not true. That code is perfectly well defined.

Sent from my iPhone

On Oct 15, 2009, at 17:10, Oftenwrong Soong  
 wrote:



Hi Ben,

You say the crash occurs in this line:

   individuals[individualCount++] = individualsForPop[i];

The problem may be in the post-increment (individualCount++). IIRC,  
there is no agreed-upon compiler standard as to whether the post- 
increment will occur before or after the assignment. It is possible  
that you're using the bytes after the end of the array as a pointer,  
which points to a random location rather than to your desired data.  
If you want the increment to happen after the assignment, do this:


   for (i = 0; i < individualCountForPop; ++i) {
   individuals[individualCount] = individualsForPop[i];
   individualCount++;
   }

If you want it before, just reverse the order of the two lines.

I've had many a headache in the past with things like this!!

Soong



- Original Message 
From: Ben Haller 
To: Greg Parker 
Cc: Cocoa List 
Sent: Thu, October 15, 2009 4:44:23 PM
Subject: Re: GC crash due to being naughty

On 15-Oct-09, at 7:30 PM, Greg Parker wrote:

A pointer value stored in an ordinary malloc block is neither a  
"strong" nor a "weak" reference. It is a dangling pointer. It can  
be used safely, but requires great care because the garbage  
collector has no knowledge of what you're doing.


The auto_zone_root_write_barrier() crash can occur when you take  
the address of a global variable, then store into the global  
indirectly via that address. What does the crashed line of code  
look like?


 OK, here's a bit of context.  The backtrace:

#0  0x95058d7b in auto_zone_root_write_barrier ()
#1  0x964e40a8 in objc_assign_strongCast_gc ()
#2  0x7198 in -[AKPopulation addIndividualsFromPopulation:]  
(self=0x102b740, _cmd=0xe76c, population=0x10a9250) at .../ 
AKPopulation.m:101


 That method:

- (void)addIndividualsFromPopulation:(AKPopulation *)population
{
   UInt32 individualCountForPop = [population individualCount];
   AKIndividual **individualsForPop = [population individuals];
   int i;

   if (individualCount + individualCountForPop > individualCapacity)
   {
   individualCapacity = (individualCount +  
individualCountForPop) * 2;


   individuals = realloc(individuals, individualCapacity * sizeof 
(AKIndividual *));

   }

   for (i = 0; i < individualCountForPop; ++i)
   individuals[individualCount++] = individualsForPop[i];
}

 The crash is in the last line of the method, in the assignment.
 The class as it stands right now:

@interface AKPopulation : NSObject
{
   NSString *title;

   UInt32 individualCount;
   UInt32 individualCapacity;
   AKIndividual **individuals;// malloc'ed array of  
AKIndividual *

}

@property (readwrite, copy) NSString *title;
@property (readonly) UInt32 individualCount;
@property (readonly) AKIndividual **individuals;

...
@end

 So the intent of the method is just to bulk-add individuals from  
one population into another population.


 Perhaps another way to ask the question is: suppose you wanted to  
implement a new collection class, akin to NSMutableArray but somehow  
different.  How would you safely do it under GC, without using any  
of the pre-made Cocoa collections internally?  That's all my  
AKPopulation really is: a poor man's (but a speedy man's!) re- 
implementation of something like NSMutableArray.  Ought to be  
possible, right?  So how do I manage this write barrier business to  
make it work properly?


Ben Haller
Stick Software

___

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/oftenwrongsoong%40yahoo.com

This email sent to oftenwrongso...@yahoo.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/clarkcox3%40gmail.com

This email sent to clarkc...@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: Code Sign verification on Leopard

2009-10-15 Thread Clark S. Cox III
The malicious code could just move the entire original bundle  
wholesale.  Code signature check still sees the original bundle.


Sent from my iPhone

On Oct 14, 2009, at 21:42, Charles Srstka   
wrote:



On Oct 14, 2009, at 11:40 PM, Jeff Laing wrote:

Actually, heck, you wouldn't even need that. All a virus would  
have to
do would be to move the binary somewhere else and put a binary in  
its
place that does something malicious and then launches the real  
binary,

and the user would never tell the difference.

Unless, of course, the app checked its code signature.


Ok, I'll bite.  How does the real binary checking its code  
signature detect the case you just described? Its 100% byte for  
byte the original executable, its just been moved somewhere else  
and as far as I'm aware, code signatures do not include your  
location on disk.


You check the signature of the .app bundle, not the executable itself.

Charles
___

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/clarkcox3%40gmail.com

This email sent to clarkc...@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: Manually updating a data bound value of a bound text field

2009-06-18 Thread Clark S. Cox III

Then change that and do the right thing. :)

Just add an intermediate NSObjectController to your nib in between  
your bound field and the file's owner.


Sent from my iPhone

On Jun 18, 2009, at 9:17, Ramakrishna Vavilala   
wrote:



Unfortunately, I used incorrect design by binding text field to
properties of the file's owner (which happens to be a
NWindowController) which does not respond to commitEditing message.
Any other ideas?

On Thu, Jun 18, 2009 at 8:21 AM, Ken Thomases  
wrote:

On Jun 18, 2009, at 9:49 AM, Ramakrishna Vavilala wrote:


I have a window (displayed as a sheet) with a text field and some
other controls. I can not set the binding mode to continuous so I  
use

non continuous binding. Everything works fine as long as I press tab
and switch to a different control. However when the the text field  
is

the key view and I press OK button, then the value of the text field
does not get reflected in the property to which it is bound. I  
want to

make sure that when the user clicks OK button the property value is
updated. How can I do that apart from making the binding continuous?


Send -commitEditingWithDelegate:didCommitSelector:contextInfo: (or  
just
-commitEditing) to the controller in the action method of the OK  
button.


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/clarkcox3%40gmail.com

This email sent to clarkc...@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: Surprising entanglement of UI lock during fetch request in background thread (NSViewHierarchyLock/MOC locking deadlock).

2009-02-20 Thread Clark S. Cox III
There aren't enough locks in the world to make it safe to update a  
table's bound model on a background thread. If you have a UI element  
bound to a another object, that object must never send KVO  
notifications on a bacgeohnd thread.


Sent from my iPhone

On Feb 20, 2009, at 11:57, Luke Evans  wrote:


Hi list,

I have a nasty deadlock caused by the condition lock used by - 
[NSViewHierarachyLock _lockForWriting:handler:] never getting  
acquired on a non-main thread.  This is on 10.5.6 BTW.


I can sort of see what's going on, but I'm not sure how one is  
supposed to fix it.


Here's what's happening:

My app has a table whose content shows files.  The files that get  
shown here are stored in Core Data, the table is bound to the Core  
Data model to show the appropriate stuff.
A background thread is started to spider through the file system  
looking for appropriate files.  When a new candidate file is  
spotted, the managed object context is locked, and the file is added  
to the 'store'.


Naturally, when a new item arrives in the MOC, the table that is  
bound to it tries to update.  This is when the deadlock occurs.

The state of the two threads when things lock up appears as follows:

The background thread has acquired the MOC lock, which minimally  
wraps a call to -[NSManagedObjectContext  
executeFetchRequest:error:].  It is doing a fetch request to see if  
a file that is being processed by the file system walker is already  
in the MOC.

Here's this thread's stack:


#00x94fef3ae in __semwait_signal
#10x9501a326 in _pthread_cond_wait
#20x95019d0d in pthread_cond_wait$UNIX2003
#30x937e6c77 in -[NSViewHierarchyLock _lockForWriting:handler:]
#40x937e6827 in -[NSViewHierarchyLock  
lockForWritingWithExceptionHandler:]

#50x931b7b79 in -[NSView setFrameSize:]
#60x931ae00a in -[NSControl setFrameSize:]
#70x932adcff in -[NSTableView setFrameSize:]
#80x932ad0c7 in -[NSTableView tile]
#90x932c6b05 in -[NSTableView rowsInRect:]
#100x933d8138 in -[NSTableBinder _visibleRowIndexesForObject:]
#110x933d79e7 in -[NSTableBinder  
observeValueForKeyPath:ofObject:change:context:]

#120x96e00b0e in NSKVONotify
#130x96d910a5 in -[NSObject(NSKeyValueObservingPrivate)  
_notifyObserversForKeyPath:change:]
#140x931b670a in -[NSController  
_notifyObserversForKeyPath:change:]

#150x931b660b in -[NSController didChangeValueForKey:]
#160x933d2920 in -[NSArrayController  
didChangeValuesForArrangedKeys:objectKeys:indexKeys:]
#170x933d5780 in -[NSArrayController  
_arrangeObjectsWithSelectedObjects:avoidsEmptySelection:operationsMask:useBasis: 
]

#180x933d06b6 in -[NSArrayController setContent:]
#190x936cf1a9 in -[_NSManagedProxy  
_managedObjectsChangedInContext:]

#200x96d7fe1a in _nsnote_callback
#210x94f078da in __CFXNotificationPost
#220x94f07bb3 in _CFXNotificationPostNotification
#230x96d7d080 in -[NSNotificationCenter  
postNotificationName:object:userInfo:]
#240x96595439 in - 
[NSManagedObjectContext(_NSInternalNotificationHandling)  
_postObjectsDidChangeNotificationWithUserInfo:]
#250x96595302 in - 
[NSManagedObjectContext(_NSInternalChangeProcessing)  
_createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes: 
]
#260x9659415b in - 
[NSManagedObjectContext(_NSInternalChangeProcessing)  
_processRecentChanges:]
#270x96592e70 in -[NSManagedObjectContext  
executeFetchRequest:error:]



I note here that while processing the fetch request on the MOC, the  
MOC chooses to notify its observers, which includes the  
NSTableBinder for table that shows the files.

Apparently, the table is unable to refresh its view because...

Over on the main thread, back at the ranch...

...the table is drawing, and guess what: it want to access the MOC  
to get the name of the file it's drawing.  Because accessing this  
attribute is a potentially faulting operation, this too is protected  
by a lock on the MOC, which is never acquired.


Here's the main thread stack:

-
#00x94fe8202 in semaphore_wait_trap
#10x94fefcf2 in pthread_mutex_lock
#20x9658bdf5 in -[_PFLock lock]
#30x9658bdca in -[NSManagedObjectContext lock]
#40x7849 in -[MYFileTracker managerForFile:] at  
MYFileTracker.m:261
#50x8831 in -[MYFileTracker identifyingDisplayTextForFile:]  
at MYFileTracker.m:523

#60xda26 in -[MYFile identifyingDisplayText] at MYFile.m:78
#70x96dd15fa in -[NSObject(NSKeyValueCoding) valueForKeyPath:]
#80x933947f0 in -[NSBinder  
_valueForKeyPath:ofObject:mode:raisesForNotApplicableKeys:]
#90x9346caed in -[NSBinder  
valueForBinding:atIndex:resolveMarkersToPlaceholders:]

#100x9346c91d in -[NSValueBinder _referenceBindingValueAtIndex:]
#110x933c98d3 in -[NSValueBinder  
_adjustObject:mode:observedController:observedKeyPath:context:editableState:adjustState: 
]
#120x9346c78c in -[NSValueBin

Re: Running out of memory on stack in C++ routine invoked within Cocoa NSOperation

2009-02-18 Thread Clark S. Cox III
I would strongly reccommend using std::vector instead of a raw array.  
That way you're immune from stack size issues.


Sent from my iPhone

On Feb 18, 2009, at 0:31, Leo Singer  wrote:


Actually, if the big array and the loop are moved from the C++ method
into the Objective C selector - (void) main then the same
EXEC_BAD_ACCESS occurs.  So the problem is not related to C++.  The
following source code still exhibits the same problem:

 TestOperation.h /
#import 

@interface TestOperation : NSOperation {
}
@end

 End of TestOperation.h /

 TestOperation.mm /
#import "TestOperation.h"

@implementation TestOperation
- (void) main
{
  int bigArray[256000];

  for (int j = 0 ; j < 256000 && ![self isCancelled] ; j ++)
  {
  bigArray[j] = 2*j;
  }
}
@end

 End of TestOperation.mm /

On Wed, Feb 18, 2009 at 3:16 AM, Leo Singer   
wrote:

Hi,

I have a C++ method that I am invoking from within the - (void) main
selector of an NSOperation.  My Cocoa application is crashing because
this particular C++ method puts a huge amount of data on the  
stack.  I

am getting an EXEC_BAD_ACCESS error.  However, the same C++ routine
works fine if I call it from within a command line C++ program.

I have contrived some sample code to illustrate the problem.
TestOperation is an (Objective C) subclass of NSOperation; I am
running the NSOperation in a separate thread by putting it into an
NSOperationQueue.  TestOperationImpl is a C++ class.  The NSOperation
is responsible for doing one thing only: calling the go() method on  
an

instance of TestOperationImpl.

Note the very large array of ints that is declared inside
TestOperationImpl::go().  If it is changed to an array of shorts or  
an
array of chars, then this example code works fine, no  
EXEC_BAD_ACCESS.


Is there any way for me to give my application more memory, or at
least give more memory to the thread that is running this C++ method?

Thanks,
Leo

 TestOperation.h /
#import 

class TestOperationImpl {
private:
  bool cancelled;
public:
  TestOperationImpl();
  void go();
  void cancel();
};

@interface TestOperation : NSOperation {
  TestOperationImpl* testOpImpl;
}
- initWithController: (TestOperationController*) controller;
@end

 End of TestOperation.h /

 TestOperation.mm /
#import "TestOperation.h"

TestOperationImpl::TestOperationImpl(TestOperationController*  
controller)

: cancelled(false)
{
}

void TestOperationImpl::go()
{
  int bigArray[256000];

  for (int j = 0 ; j < 256000 && !cancelled ; j ++)
  {
  bigArray[j] = 2*j;
  }
}

void TestOperationImpl::cancel()
{
  cancelled = true;
}

@implementation TestOperation
- initWithController: (TestOperationController*) ctrl
{
  if (self = [self init])
  testOpImpl = new TestOperationImpl(ctrl);
  controller = ctrl;
  return self;
}
- (void) dealloc
{
  delete testOpImpl;
  [super dealloc];
}
- (void) cancel
{
  testOpImpl->cancel();
  [super cancel];
}
- (void) main
{
  testOpImpl->go();
}
@end

 End of TestOperation.mm /


___

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/clarkcox3%40gmail.com

This email sent to clarkc...@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: Basic: How to go about implementing such a view?

2009-01-05 Thread Clark S. Cox III


On Dec 30, 2008, at 23:35, Matt Rajca  wrote:


Hi!

I am trying to figure out how to implement a 'Piano Roll' view in  
Cocoa. Attached is a screenshot of what I'm trying to accomplish.  
Disregard the keyboard on the left of the window and let's just  
focus on the area with the colorful rectangles, symbolizing notes.


1. When drawing the light and dark grey rows which make up a  
background, should I just use a loop with Quartz 2D/Cocoa Drawing  
calls?


Seems reasonable. The one thingbto be sure of is, for efficiency's  
sake, only draw the rows that intersect the rect passed to drawRect:




2. When drawing the vertical lines, should I just use a loop with  
Quartz 2D/Cocoa Drawing calls?


Same answer as #1 :)



3. Should I put the notes (colorful rectangles) each in a separate  
view (or Core Animation layer), or is it effective to just draw them  
directly in the main view (same view in which the rows are drawn)? I  
am eventually going to want to resize them and change their position  
by dragging them around.


This is up to you. Using a view per note is probably the simplest from  
an implementation standpoint, but it is likely to also be the least  
efficient. Were I to do this, I would probably use A CA layer per note.




4. How would I go about changing the view's width as more notes  
(rectangles) are added to the view? When enclosed in a NSScrollView,  
would manipulating the width of the view also hide/show the  
horizontal scrollbar appropriately?


Yes, this is exactly how scroll views work.




Thanks!

~Matt




___

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/clarkcox3%40gmail.com

This email sent to clarkc...@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: Question Regarding the Memory Address of Objects

2008-12-20 Thread Clark S. Cox III
The objective-c garbage collector does not move objects, so that is  
not an issue with using raw pointers.


Sent from my iPhone

On Dec 20, 2008, at 6:50, "Dong Feng"  wrote:


I have a concern that the direct use of a pointer as a memory address
may have a problem in the case of GC. In Java, object reference is not
a simple memory address because objects may be moved by GC. Does Cocoa
has a GC implementation avoid it?



2008/12/19 Carter R. Harrison :


On Dec 18, 2008, at 3:44 PM, David Duncan wrote:


On Dec 18, 2008, at 11:57 AM, Carter R. Harrison wrote:

  [dict setValue:@"button1" forKey:[NSString  
stringWithFormat:@"%x",

&button1]]; // "button1" is one of my IBOutlets.
  NSString *value = [dict valueForKey:[NSString
stringWithFormat:@"%x", &sender]];

It seems like the memory address of the sender is different than  
what it
should be.  I did some debugging and the address of the sender is  
always

bfffe2e8 which really shouldn't be possible at all.



Your confusing the pointer with the object itself. button1 is a  
pointer to
a button. sender is a pointer to the object that sent the message.  
When you
take the address of either pointer, you get the location of that  
pointer in
memory - not the location of the object. The pointer itself  
contains the

location of the object in memory.
--
David Duncan
Apple DTS Animation and Printing



David,

Once again you have saved me from pulling my hair out.  Thank you  
once again
for your assistance.  For the rest of the folks on the thread the  
solution

was to remove the "&" from the front of all my pointers.

Regards,
Carter
___

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/middle.fengdong%40gmail.com

This email sent to middle.fengd...@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/clarkcox3%40gmail.com

This email sent to clarkc...@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: how to pass arguments by reference

2008-12-10 Thread Clark S. Cox III
C, and by extension Objective-C, do not have references in the C++  
sense. You'll have to pass a pointer to the thing that you want your  
method to be able to modify.


Sent from my iPhone

On Dec 10, 2008, at 7:43, Nick Rogers <[EMAIL PROTECTED]> wrote:


Hi,
I have the following in my .m file:


- (UInt32)traverseTreeStraightReturnedDirection:(int&)treeDirection
 returnedTreeDepth:(int&)treeDepth
   returnedKey:(HPlusCatalogKey&)catKey
lookForKey:(HPlusCatalogKey)lastKey
{
// code here
}

But the error when compiling is "parse error before & token".
Is passing by reference not allowed or is there any other syntax  
that I should follow?


Thanks,
Nick

___

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/clarkcox3%40gmail.com

This email sent to [EMAIL PROTECTED]

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Leaking CGColor objects

2008-10-26 Thread Clark S. Cox III

You must do both, otherwise you will leak.

Sent from my iPhone

On Oct 26, 2008, at 10:58, DKJ <[EMAIL PROTECTED]> wrote:

Thanks to everyone for the replies. I have one (hopefully last)  
question (on this topic):


On 26 Oct, 2008, at 09:23, Clark Cox wrote:

As long as MyCALayer's dealloc is properly implemented (to release
foregroundColor, or set it to nil), you should never need to
explicitly do so in code that uses MyCALayer.



If I do this in MyCALayer's dealloc:

   self.foregroundColor = nil;

do I need to do this in init:

   CGColorRef temp = CGColorCreateGenericRGB( etc. );
   self.foregroundColor = temp;
   CFRelease( temp );

or can I just do this:

   self.foregroundColor = CGColorCreateGenericRGB( etc. );

For the time being, I'll do both.

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to count composed characters in NSString?

2008-09-28 Thread Clark S. Cox III



Sent from my iPhone

On Sep 28, 2008, at 21:52, Michael Gardner <[EMAIL PROTECTED]> wrote:


On Sep 28, 2008, at 1:17 PM, David Niemeijer wrote:


Michael,

On 28 sep 2008, at 14:41, Michael Gardner wrote:
Upon further investigation, I may be wrong. I based my assertion  
upon Apple's NSString documentation ("Returns the number of  
Unicode characters in the receiver"), and upon some quick tests I  
ran. But this reply made me look into the issue in greater depth.


I re-did my tests more throughly, and it does appear that -length  
returns the number of 16-bit words (code units), not the number of  
Unicode characters (code points), in the string. If this is true,  
I would call it a bug either in the code or in the documentation,  
which David should submit to Apple.


i think the docs are clear. In the discussion section for "length"  
it says: "The number returned includes the individual characters of  
composed character sequences, so you cannot use this method to  
determine if a string will be visible when printed or how long it  
will appear."


But composed character sequences aren't the problem; surrogate pairs  
are. Composed character sequences can be taken care of by using  
either -precomposedStringWithCanonicalMapping or - 
precomposedStringWithCompatibilityMapping.


Not true. Not all possible combinations of base characters followed by  
combining characters even have a mapping to a single precimposed  
character.


Essentially, what one wants to do is count all of the characters with  
a combining class of zero, however, even this isn't without issues.




In my opinion, -length should take surrogate pairs into account,  
which is what the docs seem to imply.


-Michael
___

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/clarkcox3%40gmail.com

This email sent to [EMAIL PROTECTED]

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: pointers in objective-c?

2008-08-01 Thread Clark S. Cox III
The NS prefix is used for just about every external symbol in the  
frameworks (classes, structs, enums, typedefs, etc.). NS just tells  
you where the symbol came from, not whether or not the symbol is a  
classname.


Sent from my iPhone

On Aug 1, 2008, at 13:07, "Giulio Cesare Solaroli" <[EMAIL PROTECTED] 
> wrote:


On Fri, Aug 1, 2008 at 10:01 PM, Clark Cox <[EMAIL PROTECTED]>  
wrote:
On Fri, Aug 1, 2008 at 12:38 PM, Arthur Coleman <[EMAIL PROTECTED]>  
wrote:

I hate to be dense, but what about C structs like NSRect?  There are
initialized on the stack aren't they?


They're C structs, they aren't Objective-C objects.


That's very true, but the common NS prefix used by both full obj-c
classes and simple C structures may lead to some confusion, mainly for
someone learning obj-c and Cocoa.

Giulio Cesare

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: pointers in objective-c?

2008-08-01 Thread Clark S. Cox III


On Aug 1, 2008, at 12:10 PM, Glenn English wrote:


Wayne Shao wrote:

It seems that every object is a pointer in the sample code I have
seen.  Is there any distinction between an object and its pointer?
In C++,  C* c; would be an uninitialized pointer. But the following
line will creates an object with the constructor C().
C c;
It seems that there is no such equivalent syntax in Objective-C.
objects are created either from factory pattern or  [[A alloc]
someInitMethod ];
so, is it possible to write?
NSString a;
NSNumber b;


Sure. And it'll even compile. But you'd better not try to do much  
with them:-)


No, it won't compile:

[EMAIL PROTECTED]:~]% cat test.m
#import 

int main()
{
NSString s;

return 0;
}
[EMAIL PROTECTED]:~]% cc test.m
test.m: In function ‘main’:
test.m:5: error: statically allocated instance of Objective-C class  
‘NSString’




--
Clark S. Cox III
[EMAIL PROTECTED]

___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: pointers in objective-c?

2008-08-01 Thread Clark S. Cox III
Correct, all objective-C objects are allocated on the heap (like using  
new in C++). The compiler will not allow you to allocate objects on  
the stack.


There are ways to trick the runtime into treating an area of the stack  
as of it were an object, but the caviats are a list as long as my arm-- 
it's just not worth it.


Sent from my iPhone

On Aug 1, 2008, at 11:43, "Wayne Shao" <[EMAIL PROTECTED]> wrote:


It seems that every object is a pointer in the sample code I have
seen.  Is there any distinction between an object and its pointer?

In C++,  C* c; would be an uninitialized pointer. But the following
line will creates an object with the constructor C().

C c;

It seems that there is no such equivalent syntax in Objective-C.
objects are created either from factory pattern or  [[A alloc]
someInitMethod ];
so, is it possible to write?

NSString a;
NSNumber b;

--Wayne
___

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/clarkcox3%40gmail.com

This email sent to [EMAIL PROTECTED]

___

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

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

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

This email sent to [EMAIL PROTECTED]