Re: [iPhone] Data protection clarification needed.
On 2 Aug 2010, at 18:37, Sandro Noël wrote: I suppose it might depend on what data you're talking about. If it's application configuration data, then it definitely should be backed up via the usual methods. If it's some kind of cache of data from an external source, then perhaps it doesn't need to be backed up. The data is definitely cached and it is not part of the settings I'm aiming at the data store. the application sync's the data from a in-house web service provider, and then stores it into a Core Data SQLite store. There is no need for that data to be backed up anywhere, as it is retrievable from the web service. the cached data is used for offline operations and later synced back to the web service. There are some locations you can write files that won't get backed up by iTunes (and when the content is recoverable as you say, it's fine to put the files in those areas). If you write to Library/Caches or tmp, you don't get backed up. Here's a link: http://developer.apple.com/iphone/library/documentation/iphone/conceptual/iphoneosprogrammingguide/RuntimeEnvironment/RuntimeEnvironment.html#//apple_ref/doc/uid/TP40007072-CH2-SW1 Cheers, Graham. -- Graham Lee http://blog.securemacprogramming.com/ Author - Professional Cocoa Application Security http://www.amazon.co.uk/gp/product/0470525959?ie=UTF8tag=thaeofer-21linkCode=as2camp=1634creative=6738creativeASIN=0470525959 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: CCCrypt()
On 24 Jun 2010, at 07:43, Richard Hood wrote: does anyone know in which library the CCCrypt() routine is defined? I've linked against libcrypto.dylib where it's defined in the header and libSystem.dylib where the man page says it is but I'm still getting undefined symbol errors on link. Hi Richard, what errors do you get? You certainly should be able to link just against libSystem without problems: jormungand:common_crypto_example leeg$ nm /usr/lib/libSystem.dylib | grep CCC 001065df T _CCCrypt 0006ee17 T _CCCryptorCreate 001064b3 T _CCCryptorCreateFromData 00106446 T _CCCryptorFinal 00106466 T _CCCryptorGetOutputLength 0006fb93 T _CCCryptorRelease 00106486 T _CCCryptorReset 0006f06d T _CCCryptorUpdate Which SDK are you linking against? Graham. -- Graham Lee http://blog.securemacprogramming.com/ Author of Professional Cocoa Application Security http://www.amazon.co.uk/gp/product/0470525959?ie=UTF8tag=thaeofer-21linkCode=as2camp=1634creative=6738creativeASIN=0470525959 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Looking for info on anti-piracy and trial-mode techniques for my app . . .
On 24 Feb 2010, at 22:57, Michael A. Crawford wrote: Part of your response suggests that if there was an existing framework that was openly available, it wouldn't do me any good because the bad guys would have the source code. I disagree. If it's based on a tried and tested (and occasionally formally verified) crypto system, knowing the algorithm doesn't lead to a crack. Weaknesses would come through bugs in the framework (or incorrect application of it), and the more people who can see the source the greater chance there is that good people as well as bad can find the issues. Good people fix 'em. Cheers, Graham. -- Graham Lee http://blog.securemacprogramming.com/ Coming soon - Professional Cocoa Application Security http://eu.wiley.com/WileyCDA/WileyTitle/productCd-0470525959.html ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Looking for info on anti-piracy and trial-mode techniques for my app . . .
On 25 Feb 2010, at 01:41, Greg Parker wrote: On Feb 24, 2010, at 5:27 PM, Graham Lee wrote: On 24 Feb 2010, at 22:57, Michael A. Crawford wrote: Part of your response suggests that if there was an existing framework that was openly available, it wouldn't do me any good because the bad guys would have the source code. I disagree. If it's based on a tried and tested (and occasionally formally verified) crypto system, knowing the algorithm doesn't lead to a crack. Weaknesses would come through bugs in the framework (or incorrect application of it), and the more people who can see the source the greater chance there is that good people as well as bad can find the issues. Good people fix 'em. Except in the standalone piracy-prevention case, the algorithm is already known to be broken. Formally, the attacker already has in hand all of the information they need: they have the executable and all of the data accessed by the executable. The only information the attacker lacks is the algorithm. Once they know the algorithm, they know how to rewrite your executable to bypass the protection system. They don't even need to know the algorithm, if they have access to kernel memory - at some point the code has to end up in a state the OS can execute. Believing that DRM provides confidentiality is the most common incorrect application I come across :-) Graham. -- Graham Lee http://blog.securemacprogramming.com/ http://www.mac-developer-network.com/category/columns/security/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Looking for info on anti-piracy and trial-mode techniques for my app . . .
On 25 Feb 2010, at 01:45, Chris Williams wrote: Having code execute dependent on some switch, regardless of the number or sophistication of the switches, can be hacked. But then once you sell the licensed version you've given it to someone who might distribute it on, so that's not foolproof either :-( Graham. -- Graham Lee http://blog.securemacprogramming.com/ Pre-order now! - Professional Cocoa Application Security http://www.amazon.co.uk/gp/product/0470525959?ie=UTF8tag=thaeofer-21linkCode=as2camp=1634creative=6738creativeASIN=0470525959 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Re : Proper way to initialize application support file
On 18 Feb 2010, at 09:36, Peter Hudson wrote: Files that are necessary should be inside your app bundle, usually. I put some files into the app bundle which were essential for the app to run - but also needed to be modified at run time. Those definitely shouldn't be changed inside the app bundle, as you'll break your code's identity. The first time our app was installed on a server ( for a number of users to have access to ) we got into trouble as the sysadmin would not give write permission on the application folder to anybody. Is there another way to do this ? You could _distribute_ them in the app bundle, then copy the files to ~/Library/Application Support/com.yourcompany.yourapp/ when it is first launched. Use and change the deployed copies from then on. Cheers, Graham. -- Graham Lee http://blog.securemacprogramming.com/ Coming soon - Professional Cocoa Application Security http://eu.wiley.com/WileyCDA/WileyTitle/productCd-0470525959.html ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: KVO on Distributed Objects with exception handling.
On Sep 7, 2009, at 21:45 , Edward Chan wrote: Great... How long ago did you ask the Apple engineers? I haven't tried this piece of code with Snow Leopard actually... This was back in February, I was probably testing on Leopard. The difference between what you and I tried was that I used - bind:toObject:withKeyPath:options: instead of - addObserver:forKeyPath:options:. Did they explain why they didn't want to support it? No, but then the discussion was over Twitter DMs, with all the terseness that entails :-). I do remember eventually sending some sample code to someone in Apple who I seem to recall is on this list, hopefully he is and will be able to explain engineering's reservations more completely. Cheers, Graham. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: KVO on Distributed Objects with exception handling.
On Sep 7, 2009, at 20:02 , Edward Chan wrote: Hello, I'm using KVO on a Distributed Object, and I am binding my UI controls based on the observer. Hi, not much of constructive help from me I'm afraid, just a warning. I also did the same thing once, and the reaction from Apple engineers went through denial, shock and fear, but never got as far as acceptance. In fact I was told that combining KVO with DO is not supported and if it does work now, don't expect it to work in the future. Cheers, Graham. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: what is this currency symbol?
On 21 Jul 2009, at 16:53, Andy Lee wrote: I've recently started using the currency option for NSDateFormatter in IB. I could have sworn it was using $ as the currency symbol, but lately it's started using ¤, which is a symbol I don't recognize. Anybody know what the ¤ is, and how I can get $ back as the default? That's the generic currency symbol. Cheers, Graham. -- Graham Lee Senior Mac Software Engineer tel: +44 1235 540266 SOPHOS - simply secure Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Clarification on accessors? (was: Yet another memory management question)
On 08/07/2009 17:51, Caleb Strockbine ca...@mac.com wrote: On Jul 4, 2009, at 9:37 PM, mmalc wrote: In an initaliser method and in dealloc, you should typically set or release the variable directly, so in dealloc it would be [myArray release]; Really? Are -init and -dealloc special in some way that makes it a bad idea to use accessors? If you've got an accessor for myArray, why wouldn't you just say: self.myArray = nil? -init and -dealloc are special in that the object is not in a consistent state during those methods (it either hasn't yet entered it's initial state or is transitioning out of its final state). If your accessors rely on the internal state of the object being normal, they could blow up when called in these methods. Cheers, Graham. -- Graham Lee Senior Mac Software Engineer tel: +44 1235 540266 SOPHOS - simply secure Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
[meet] cocoaheads Swindon tonight!
Hi all, For those of you who've never explored the delights that the fine city of the Hill of Pigs has to offer, tonight offers an unparalleled opportunity. Come and sit in (or outside, weather permitting) a pub only a short distance from the railway station, and listen to Mike Abdullah speaking about WebKit. As always there'll also be general NSDiscussion, and the occasional pint of beer. http://cocoaheads.org/uk/Swindon/index.html Hope to see you there, Graham. -- Graham Lee Senior Mac Software Engineer tel: +44 1235 540266 SOPHOS - simply secure Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: C string constant-NSString constant without defining twice?
On 28/04/2009 16:51, Stephen J. Butler stephen.but...@gmail.com wrote: On Tue, Apr 28, 2009 at 10:18 AM, Erik Buck erik.b...@sbcglobal.net wrote: Don't hard code paths! Use NSHomeDirectory() or NSTemporaryDirectory() or NSSearchPathForDirectoriesInDomains(). Not only that, but hardcoding filenames in tmp directories is generally considered a security bug. You should be using mktemp or one of its ilk. Not sure if there's a Cocoa API for that. It's not only a security bug but a buggy bug. If you see what I mean :-). What happens if two users are fast-user-switching on the same box? Both apps are using the same temporary data... Cheers, Graham. -- Graham Lee Senior Mac Software Engineer tel: +44 1235 540266 SOPHOS - simply secure Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: One IBAction, multiple results from multiple methods
On 26/02/2009 16:24, Paul Sanders p.sand...@dsl.pipex.com wrote: No, it's an object (or, if you like, an action) represented by a symbol: // Generated by IB #define IDC_CUT 1 #define IDC_COPY 2 #define IDC_PASTE3 // Coded by Joe Soap switch (tag) { case IDC_CUT: ... case IDC_COPY: ... case IDC_PASTE: ... } You could call it a SELector. Cheers, Graham. -- Graham Lee Senior Macintosh Software Engineer, Sophos Plc. +44 1235 540266 http://www.sophos.com/ Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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 about the Foundation Framework
On 19/02/2009 15:36, Michael Ash michael@gmail.com wrote: If you're looking for more information, note that NSTemporaryDirectory is essentially equivalent to /tmp on a normal UNIX system, although it's actually in a different location. Hi Mike, that's not quite true, NSTemporaryDirectory() should be somewhere like: /var/folders/6G/6GtcG4aOHt0FanslHMn1Hk+++TI/-Tmp-/ which includes the security session ID in the path. That means that even if the same user is running your Foundation code multiple times in different login sessions, they won't be able to clobber each other. Cheers, Graham. -- Graham Lee Senior Macintosh Software Engineer, Sophos Plc. +44 1235 540266 http://www.sophos.com/ Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Security With Show Package Contents?
On 12/01/2009 15:18, Chunk 1978 chunk1...@gmail.com wrote: anyway, i started thinking about security of applications based on showing package contents. as far as i know the only way for someone to crack an application is to have access to the package contents which lists the Unix Executable File in the Mac OS folder. No, it's not. since apps are really just folders with a .app extension, wouldn't it be possible to disable Show Package Contents, as with the new .pages files, so that it would make the app more secure (if not impossible to crack)? I don't see how that would make anything more secure, just as marking files as 'hidden' doesn't. With some appropriate changes to the code signing mechanism, interface and requirements they could make it hard - though not impossible - for cracked apps to act as drop-in replacements for their legitimate antecedents. But I'm pretty sure that while it's possible people will do it, even if the pay-off were to disappear :-( Graham. -- Graham Lee Senior Macintosh Software Engineer, Sophos Plc. +44 1235 540266 http://www.sophos.com/ Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Security With Show Package Contents?
On 12/01/2009 17:25, Michael Ash michael@gmail.com wrote: On the Mac code signing is just a way for users to be able to trust that an app is from who it says it's from. I agree that it the underlying technology has the capability to provide that, I'm not sure that code signing on the Mac currently does provide that trust. AFAICT it currently only lets users trust that app v1.0.1 came from the same people as app v1.0, and only then thanks to the _lack_ of any UI which would appear in the failure case - and only _THEN_ if the app tries to perform one of a small number of privileged operations. Cheers, Graham. -- Graham Lee Senior Macintosh Software Engineer, Sophos Plc. +44 1235 540266 http://www.sophos.com/ Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Using the security framework
On 07/01/2009 05:36, Peter N Lewis pe...@stairways.com.au wrote: At 18:50 -0600 3/1/09, Joe Turner wrote: I am making a hard drive cloner/backuper, and to do some deleting and copying, I need to use the security framework. What I need to be able to do is have the user type in their password one time, and then it would give me system.privilege.admin rights until a time that they want to unauthorized it (could be days, weeks, months, years). I have looked through the security framework, but have not really found how to have one system.privilege.admin authorization, and have it last a long time. So, if anyone could point me in the right direction with this, like what methods to use, and what parameters to use. One way to do this is to have a second tool that runs as root. You need to ask for admin permissions the first time to enable suid mode on the tool, but after that the tool will run as root with full privileges. Naturally, this has all the inherent security implications of that of any suid root tool, and the tool must now defend against possible misuse. Some security suggestions include: To avoid some of the problems with using a setuid tool, you can use launchd to run the privileged process as root. See the B.A.S. readme: http://developer.apple.com/samplecode/BetterAuthorizationSample/listing4.htm l * Code sign both your application and your tool and verify both signatures before applying the suid bit. * Strictly limit the actions of the tool. * Ensure requests to the tool are processed only if they come from your properly signed application. * Strictly minimize the tools code to minimize the chance of security related bugs. * Limit the use of external frameworks in the tool to minimize the chance of security issues. These are still all good ideas. Another thing to do is to convert the Auth Services rights structure into an external form, and pass it to the helper - the helper then only performs privileged operations if it agrees that it has received the authorisation. Cheers, Graham. -- Graham Lee Senior Macintosh Software Engineer, Sophos Plc. +44 1235 540266 http://www.sophos.com/ Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: More - Safari Download Security Alerts
Hi Dave, On 17/12/2008 15:19, Dave d...@looktowindward.com wrote: 2. When I run the Install Package after the Initial Screen and clicking Continue, I get to the Screen where is says - Standard Install on VolumeName, there is a button that says Change Install Location, if I press it brings up a list of all mounted volumes (including iPod's!). I can't seem to find a way to get rid of this, I just want it be be installed in /Applications on the System Volume and nowhere else. This is much more of a problem. You can use a VolumeCheck script as described in the Apple developer documentation for installer packages to restrict which volumes the package can be installed to. In general, you'll have more luck with installer questions in installer-...@lists.apple.com. Cheers, Graham. -- Graham Lee Senior Macintosh Software Engineer, Sophos Plc. +44 1235 540266 http://www.sophos.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: More - Safari Download Security Alerts
On 15/12/2008 17:41, Dave d...@looktowindward.com wrote: Hi, I looked at the Man page below, I can't see anything that says udifrez. Is this meant for me? I'm not sure what I am supposed to do with it. Hi Dave, on my system (10.5.6): udifrez [options] image Attaches resources (software license agreements, for example) to a disk image. Hope that helps, Graham. -- Graham Lee Senior Macintosh Software Engineer, Sophos Plc. +44 1235 540266 http://www.sophos.com/ Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: More - Safari Download Security Alerts
On 15/12/2008 17:06, Devon Ferns dfe...@devonferns.com wrote: This is OT for the Cocoa list now, but you can set an EULA to be displayed when mounting a dmg. I don't know how since I've never cared to check but many apps do it so it's possible. x-man-page://1/hdiutil Particularly the 'udifrez' command. Cheers, Graham. -- Graham Lee Senior Macintosh Software Engineer, Sophos Plc. +44 1235 540266 http://www.sophos.com/ Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Number of Files on Volume
On 26/11/2008 08:28, Andrew Farmer [EMAIL PROTECTED] wrote: On 25 Nov 08, at 16:44, Joe Turner wrote: I have ben trying to find a good way to get an accurate count of files on a Volume. Using a NSDirectoryEnumerator takes way too long (a couples minutes), so, I figured out how to do it on the old Carbon FileManager using [FSGetVolumeInfo...] Is there a better way of doing it? Maybe with Cocoa tools? If you want a non-Carbon way of doing this, take a look at statfs64(). It's not technically Cocoa, but it's not Carbon and it works just fine. An equivalent to your code would simply be: self.count = [NSNumber numberWithUnsignedLongLong:fsbuf.f_files]; In fact, f_files (when it works) reports the total number of nodes on the filesystem, so you need to subtract f_ffree to find the number of nodes which are occupied. Also, you need to test that neither of these numbers is -1, as some filesystems don't support telling you that stuff. Cheers, Graham. -- Graham Lee Senior Macintosh Software Engineer, Sophos Plc. +44 1235 540266 http://www.sophos.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 [EMAIL PROTECTED]
Re: Lack of Initializers or Factory Methods
Gordon Apple wrote on 03/11/2008 16:30:57: Is self even defined for a class object? Yes; in any method, self is (or at least starts life as) the object which received the message. If so, should case 1 (or similar) be the assumed implementation for all of Cocoa? I don't think that would work for class clusters. Consider +[NSArray array]: #import Foundation/Foundation.h int main (int argc, char ** argv) { id arp = [[NSAutoreleasePool alloc] init]; id array = [NSArray array]; NSLog(@%@, NSStringFromClass([array class])); [arp release]; return 0; } intel:trunk leeg$ ~/foo 2008-11-03 16:36:29.274 foo[14229:10b] NSCFArray so it doesn't return the class in your case 1, which would be NSArray. It doesn't return the class in your case 2 which would also be NSArray ;-). If not, then, IMHO, the docs in general should specify which is is for each factory method. File bugs :-) Cheers, Graham. -- Graham Lee Senior Macintosh Software Engineer, Sophos Tel: 01235 540266 (Direct) Web: http://www.sophos.com Sophos - Security and Control Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Mutable arrays
Michael Ash wrote on 20/10/2008 15:31:01: On Mon, Oct 20, 2008 at 1:35 AM, j o a r [EMAIL PROTECTED] wrote: Some general suggestions for best practices wrt. optimizations: 1) Measure first 2) Implement supposed optimization 3) Measure to see the impact of the code change 4) Based on the result of #3, either scrap your changes, or document the optimized code And don't forget step 0: 0) Don't even bother A lot of people optimize code that's already plenty fast. A lot of people optimize code that *hasn't even been written yet*. This is foolish. Write your code to be easy to understand and as bug-free as you can get it. And then, only if it's not running as fast as you need it to, should you even start to consider the possibility of thinking about beginning to investigate optimizing the code. I think that's only frequently, not usually or always, the approach to take. For instance if you have a specific performance requirement, and when you prototype the proposed solution you find the performance to be way off the requirement, it's best to go back to the boxes on the paper. Even Instruments is unlikely to help you get your slow design orders of magnitude faster, nor your bloated design orders of magnitude more svelt. I've been involved on a project like that in a previous job, where we had a requirement to process thousands of things/sec and our existing solution was capable of tens/sec. Rather than see what we could eke out of our solution, we went back to the whiteboard and optimised the design. In that case, this was not a foolish thing to do. Cheers, Graham. -- Graham Lee Senior Macintosh Software Engineer, Sophos Tel: 01235 540266 (Direct) Web: http://www.sophos.com Sophos - Security and Control Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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]
[meeting] Swindon, UK: upcoming cocoaheads
Hi all, September's CocoaHeads Swindon will be at the Glue Pot pub, at 20:00 BST on Monday 1st September. As ever, the website for more information is: http://cocoaheads.org/uk/Swindon/index.html See (some of) you there! Graham. -- Graham Lee Senior Macintosh Software Engineer, Sophos Tel: 01235 540266 (Direct) Web: http://www.sophos.com Sophos - Security and Control Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Design Question: Bindings Custom Views
Grahaam Cox wrote on 2008-08-28 13:11:47: Regarding the above though, if this is similar to your situation - what's really wrong with model objects caching a thumbnail? Being a slave to MVC is going to lead to suboptimal solutions just as ignoring MVC altogether is going to be. The cached thumbnail has to be stored somewhere, right? Where, doesn't really matter. So if a model object has a -thumbnail method that returns the thumbnail when you need it, what's wrong with that? The thumbnail doesn't need to end up permanently stored by the model when archived, just created lazily when required. If the model object is the best object to make and cache that thumbnail (i.e. it has all the state information to hand to do so) why not let it? A view that displays the thumbnail can then just request it directly from the object in question instead of going round the houses to generate a thumbnail simply to avoid the model object getting its hands dirty. Some may feel differently but I don't see that this violates MVC in any significant way and it's much simpler. Your model objects could be re-used somewhere that AppKit isn't available or where it's unnecessary and perhaps even inappropriate to keep NSImages around; your command-line interface to the model probably won't need them, for instance. As such, following the Decorator pattern by having an object which does appkit-can-draw-this and has-a model object promotes re-use of the model. It also keeps all of your AppKit code in the view, so when you need an other-ui-framework-which-I-will-not-specify-can-draw-this object, you don't have to go hunting around for all that drawing code. As others have pointed out if you don't need extra ivars, or don't mind jumping through a hoop to get them, you can add a category to the model class which is decorating via ObjC magic. It still lets you separate the UI code into the view package, but also means you directly use the model class. An example of that approach is NSAttributedString(AppKitAdditions). Cheers, Graham. -- Graham Lee Senior Macintosh Software Engineer, Sophos Tel: 01235 540266 (Direct) Web: http://www.sophos.com Sophos - Security and Control Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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]
[meeting] CocoaHeads Swindon, Monday August 4th
Hi all, the next meeting of CocoaHeads Swindon will take place on Monday, 4th August. In a grotesque example of self-promotion, I will be leading a discussion on Designing a secure Cocoa application. Details regarding the time and location can be found on the CH website: http://cocoaheads.org/uk/Swindon/index.html See you* there! * [cocoaDevSubscribers intersectSet: peopleLivingNearSwindon]; Cheers, Graham. -- Graham Lee Senior Macintosh Software Engineer, Sophos Tel: 01235 540266 (Direct) Web: http://www.sophos.com Sophos - Security and Control Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Running a daemon
Ivan C Myrvold wrote on 2008-06-18 13:07:50: I have developed a daemon that have an Objective-C class ApplicationWatcher which checks the foreground applications with NSWorkspace. In my main I create the ApplicationWatcher, and the class starts an NSTimer. This is probably a stupid question, but I want the daemon to continue running, but at the end of main the daemon quit, even if I have an NSTimer running. So what should I do in main to have the daemon running? In an ordinary Cocoa application the main contains return NSApplicationMain(argc, (const char **) argv);, but as this is a daemon I can't call this. The bit of NSApplicationMain() which you need to replicate is the run loop. Timers get scheduled in run loops. Have a look at the NSRunLoop documentation (you probably want [[NSRunLoop currentRunLoop] run]). Cheers, Graham. -- Graham Lee Senior Macintosh Software Engineer, Sophos Tel: 01235 540266 (Direct) Web: http://www.sophos.com Sophos - Security and Control Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Best Practice for Returning Immutable Objects?
Karl Moskowski wrote on 2008-06-03 17:16:48: On 3-Jun-08, at 12:13 PM, Mike Abdullah wrote: Well this cast is fairly pointless as it makes no change to the data at all. Returning an NSMutableData object from an NSData method is perfectly legitimate as it is a subclass. So you might as well just do: return myData; Really, it's up to you. You can just use the simple option of returning a mutable object, or you can do either of these: return [NSData dataWithData:myData]; return [[myData copy] autorelease]; My concern is that the returned object be truly immutable. For now, I'm the only one using the class, but that may change in the future. If it has to be 'truly' immutable, then use one of Mike's suggestions, which will return an immutable NSData object containing the same bytes as the bytes in the mutable object you constructed. The code you originally posted still returns the mutable object; casting doesn't change the 'isa' which is what tells the ObjC runtime what class the instance is. I.e. given an NSMutableData *foo: (NSData *)foo is a NSMutableData (NSObject *)foo is a NSMutableData (id) foo is a NSMutableData Cheers, Graham. -- Graham Lee Senior Macintosh Software Engineer, Sophos Tel: 01235 540266 (Direct) Web: http://www.sophos.com Sophos - Security and Control Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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 is Apple + Ctrl + D implemented?
Graham Cox wrote on 2008-04-28 11:36:32: Bear in mind that the question what is a word? is far from trivial to universally answer. So in fact determining the boundaries of a word can be complex. As far as I can glean from the docs, this job falls to NSTypesetter, though there isn't an obvious method that simply returns a word. CFStringTokenizer allows you to tokenize strings into words, sentences or paragraphs in a language-neutral way. http://developer.apple.com/documentation/CoreFoundation/Reference/CFStringTokenizerRef/Reference/reference.html Should fit the bill ;-) Graham. -- Graham Lee Senior Macintosh Software Engineer, Sophos Tel: 01235 540266 (Direct) 01235 559933 (Reception) Web: http://www.sophos.com Sophos - security and control Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon, OX14 3YP, United Kingdom. Company Reg No 2096520. VAT Reg No GB 348 3873 20. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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]