Re: Determining available or installed RAM on iOS device?

2014-02-11 Thread James Montgomerie
On 11 Feb 2014, at 15:46, Jens Alfke j...@mooseyard.com wrote: I'm well aware that on most modern operating systems available RAM is not a very informative number because virtual memory makes RAM and address space very different things. But on iOS, as I understand it, there is no swap file

Re: CVPixelBufferCreateWithPlanarBytes does not execute callback when released

2014-01-06 Thread James Montgomerie
I'm not an expert on planar video formats, but I tried out your code anyway and noticed that if I pass a non-NULL value as the dataPtr parameter then the callback gets called. Jamie. On 5 Jan 2014, at 11:04, Matthieu Bouron matthieu.bou...@gmail.com wrote: On Mon, Nov 25, 2013 at 12:45 PM,

Re: ARC vs Manual Reference Counting

2013-09-09 Thread James Montgomerie
When performance testing ARC code, remember to test in a release configuration, with compiler optimisations on. In my experience, it can really make a big difference; a lot of 'spurious' retain/release pairs are optimised away, and many objects are released earlier. Jamie. On 9 Sep 2013, at

Re: iCloud Key-Value Store not Syncing ?

2013-06-01 Thread James Montgomerie
On 1 Jun 2013, at 06:16, Peng Gu pan...@gmail.com wrote: * Questions: * 0. Any thoughts on the problems? 1. Is there any way to check if the data is uploaded to the iCloud storage. 2. I'm not a iOS developer membership yet, so the app isn't code-signed. Can I test the iCloud functionality

Re: Simple Vector Based Line Charts

2013-04-25 Thread James Montgomerie
If you have quite simple requirements, a CAShapeLayer might work. You'll need to create a CGPath to give it to render. On iOS, UIBezierPath can help with creating the CGPath if you don't want to drop to the CGPath API (no such luck on Mac - NSBezierPath can't be trivially converted to a

Re: Understanding user defaults

2013-03-19 Thread James Montgomerie
On 19 Mar 2013, at 10:02, Marcel Weiher marcel.wei...@gmail.com wrote: On Mar 19, 2013, at 1:19 , Jens Alfke j...@mooseyard.com wrote: On Mar 18, 2013, at 5:14 PM, Rick Mann rm...@latencyzero.com wrote: NSArchiver calls look like -setValue:forKey:, so it seems reasonable that the

Re: Uploading photos to iCloud programatically

2013-02-13 Thread James Montgomerie
If you save images to the camera roll the system will automatically upload them to the photo stream, just as if they'd been taken with the camera. Jamie. On 7 Feb 2013, at 05:42, Balaji M balaji06n...@gmail.com wrote: Hi, I am writing a Mac application which is expected to support

Re: Coordinate conversions in CALayer

2013-01-24 Thread James Montgomerie
On 24 Jan 2013, at 08:19, Graham Cox graham@bigpond.com wrote: I've made some progress, in that I managed to make the two code snippets work the same, by changing this line: tfm = CGAffineTransformConcat( tfm, layer.transform ); to this: tfm = CGAffineTransformConcat(

Re: Operations Beachball

2012-12-05 Thread James Montgomerie
On 4 Dec 2012, at 18:29, Jens Alfke j...@mooseyard.com wrote: On Dec 4, 2012, at 3:48 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: My app creates lots of MyOperations (subclass of NSOperation) and puts them into an NSOperationQueue. I would expect that the app thus remains

Re: How To Safely Invoke a Block

2012-11-26 Thread James Montgomerie
On 21 Nov 2012, at 10:56, Andreas Grosam agro...@onlinehome.de wrote: I've defined a class Foo that defines a block via a property: @property (copy) void (^progressHandler)(RXProgressState progressState, NSInteger totalBytesWritten, NSInteger totalBytesExpectedToWrite); The property is

Re: NSMapTable thread safety (with with ARC and weak objects)

2012-11-19 Thread James Montgomerie
On 16 Nov 2012, at 22:36, Quincey Morris quinceymor...@rivergatesoftware.com wrote: On Nov 16, 2012, at 09:53 , James Montgomerie ja...@montgomerie.net wrote: Let's assume I'm using ARC. If I create an NSMapTable with [NSMapTable strongToWeakObjectsMapTable], is it safe to put objects

NSMapTable thread safety (with with ARC and weak objects)

2012-11-16 Thread James Montgomerie
How thread safe is NSMapTable? I know that's a pretty nebulous question, so more concretely: Let's assume I'm using ARC. If I create an NSMapTable with [NSMapTable strongToWeakObjectsMapTable], is it safe to put objects into it that might be referenced from, and perhaps deallocated on, a

Re: Code Comments

2012-09-10 Thread James Montgomerie
On 9 Sep 2012, at 17:57, koko k...@highrolls.net wrote: On Sep 9, 2012, at 7:35 AM, Mike Abdullah wrote: NSXMLParser supports NSInputStream directly these days; consider moving to that That is excellent but for now I must run on 10.5.8 … Aside from the memory management issues already

Re: KVO Question: How to programmatically determine if one object is observing another on a keyPath and context?

2012-09-10 Thread James Montgomerie
On 10 Sep 2012, at 11:40, Motti Shneor su...@bezeqint.net wrote: My question is general. Supposedly I could NOT start observing once, and stop it once. Reasons: 1. There are many instances of that NSViewController 2. This observation is quite frequent in time (could reach 100 times a second)

Re: ARC Extending Lifetime of Objects

2012-07-23 Thread James Montgomerie
I think this does what you want. It works by [arguably ab-] using the CF bridging casts: NSUInteger count = [dictionary count]; // Are you sure you don't want to malloc and free these? Might blow the // stack if they're large. id __unsafe_unretained values[count]; id

Re: @synchronized crashing with ARC

2012-05-31 Thread James Montgomerie
It looks a bit suspicious to me that you're instantiating the dictionary in your hidden … work ... code, then using it in the visible code, but not releasing it. Is it possible that the dictionary started out as an ObjC object that you don't own, and you used a (__bridge CFDictionaryRef) cast

Re: Losing memory

2012-05-28 Thread James Montgomerie
On Monday, 28 May 2012 at 03:20, Charlie Dickman wrote: My application is using (leaking) too much memory and eventually dies because no more can be allocated. I have used Instruments to measure the usage and leaks and have addressed those it told me about. Now, however, Instruments

Re: stringWithFormat / Rendering Text (iOS)

2012-05-24 Thread James Montgomerie
On 24 May 2012, at 15:36, Manfred Schwind wrote: CGContextShowTextAtPoint(contextRef, 0, 40, [textToDraw UTF8String], [textToDraw length]); One bug I see here: you're passing a wrong length parameter. CGContextShowTextAtPoint expects the length of the char array (number of bytes of

Re: NSDocument disc undo stack

2012-04-01 Thread James Montgomerie
I don't think it's likely to be true in practice on 64-bit systems either. In theory, yes, the old data could get paged out, and will not be paged back in until the user uses it. In practice though, unless these pieces of old data are big, contiguous buffers taking up pages by themselves, the

Re: [Obj-C] if (self) vs. if (self != nil)

2012-02-25 Thread James Montgomerie
On 24 Feb 2012, at 20:36, Sean McBride s...@rogue-research.com wrote: On Fri, 24 Feb 2012 10:36:51 -0700, Keary Suska said: I don't believe this is the case. There can be funny issues with BOOL types, such that BOOL == YES is an inadvisable construct, since your BOOL could be an integer of

Re: copy isEqual nightmares

2012-02-14 Thread James Montgomerie
On 13 Feb 2012, at 17:29, Quincey Morris wrote: It's a mistake to calculate the hash from *mutable* object state, including ivars that can be changed after creation. The NSObject protocol documentation on 'hash' is worth recalling: hash Returns an integer that can be used as a table

Re: Allocating too much memory kills my App rather than returning NULL

2011-11-10 Thread James Montgomerie
On 9 Nov 2011, at 17:33, Dave Camp wrote: This was discussed at a WWDC session a couple of years ago. If your app attempts to allocate a large block of memory, and the OS cannot get other processes to give up memory in a timely fashion, your app will be killed. It's the reverse of you

Re: Allocating too much memory kills my App rather than returning NULL

2011-11-10 Thread James Montgomerie
On 10 Nov 2011, at 17:52, Kyle Sluder wrote: On Nov 10, 2011, at 9:33 AM, James Montgomerie ja...@montgomerie.net wrote: On 9 Nov 2011, at 17:33, Dave Camp wrote: This was discussed at a WWDC session a couple of years ago. If your app attempts to allocate a large block of memory

Re: Allocating too much memory kills my App rather than returning NULL

2011-11-09 Thread James Montgomerie
On 9 Nov 2011, at 08:08, Don Quixote de la Mancha wrote: That would be great if I actually received any memory warnings. I don't. ... However, I did set a breakpoint at both methods. That breakpoint was never hit. I dont want to wade in to the religious war here (although I'm on the side

Re: Accessing information from applications

2011-06-02 Thread James Montgomerie
Note that, depending on what you're wanting to do, this might not actually give you what you want (and getting what you want may be impossible). Lots of apps (word processors etc.) that have document files 'open' as far as the user is concerned actually open the file, read/unarchive it into

Re: Accessing information from applications

2011-06-02 Thread James Montgomerie
This is indeed impossible to do generally. If you have /specific/ apps in mind (rather than 'any application'), it might be possible to tell this on an app-by-app basis at a higher level. For example, for Safari, you could use Applescript to get the URLs of the open windows: tell application

Re: Using asynchronous APIs with NSOperation

2011-02-24 Thread James Montgomerie
Dave Dribin has written excellent blog posts about this - start here: http://www.dribin.org/dave/blog/archives/2009/05/05/concurrent_operations/ Jamie On 24 Feb 2011, at 15:08, Matt DeFoor wrote: I have been doing research in preparing to switch from manual threading to the usage of

Re: Canceling NSInvocationOperation

2011-02-14 Thread James Montgomerie
I think you are exposing yourself to a race condition here, even if you did get this to work - imagine: --- // Some Code: - (void)myOperationInController; { // Do stuff if (![self isCancelled]) -- main thread sets isCancelled to YES -- [self

Re: Fixed pattern with colorWithPatternImage

2010-09-05 Thread James Montgomerie
On 04/09/2010, at 14:52, Quincey Morris quinceymor...@earthlink.net wrote: The pattern is tiled relative to the window, not to the view. So, the 'colorWithPatternImage:' isn't a viable approach in this case. Quincey may be right that drawing the image directly is the easier approach, but it

Re: Math.h functions with CGFloat

2010-08-10 Thread James Montgomerie
You should, I believe, be able to include tgmath.h ('type generic math' - a C99 addition) instead, and then just 'use' the non-suffixed versions of the functions. Hidden macro magic is supposed to then make the compiler call the double or float versions as appropriate for the type used.

Re: Simple question

2010-04-22 Thread James Montgomerie
You should really use 'integerValue' rather than 'intValue' if you're otherwise using NSIntegers. 'integerValue' will return an NSInteger (which may be 32 or 64 bits wide depending on your platform), but 'intValue' will return a C 'int' (which is always 32 bit on the Mac and iPhone, regardless

Re: Weird exception

2010-01-25 Thread James Montgomerie
On 25 Jan 2010, at 10:21, Alexander Bokovikov wrote: On 24.01.2010, at 14:08, vincent habchi wrote: Under XCode, you select 'run with performance tool' - 'zombies'. This will launch your app with the 'zombie instrument' attached, that will signal you if you app tries to message a released

Re: How to animate the drawing of UIImages inside a drawRect: method of a UIView?

2009-04-03 Thread James Montgomerie
On 2 Apr 2009, at 22:33, WT wrote: 25 was just a test. The actual app has 2 interlocking 7x7 grids, so the number of image views is actually 98. I should explain that this animated laying out of image views happens only once and, from that point on, the image views all remain in the same

Re: How to animate the drawing of UIImages inside a drawRect: method of a UIView?

2009-04-01 Thread James Montgomerie
This is not doing exactly what you think it is. You are certainly right that UIKit calls should /always/ be made from the main thread, but the performSelector:withObject:AfterDelay method actually performs the selector on the same thread that you call it from, not a separate thread. This

Re: Memory Leak, part I

2009-02-19 Thread James Montgomerie
Presuming th rest of your code is following the rules, I can't see anything obviously wrong with this code leak-wise. Do these leaks build up every time you run the code you pasted, or is there just one in the app's lifetime? Can you post a full backtrace for the leak? (It may be easier

Re: Memory Leak, part I

2009-02-19 Thread James Montgomerie
On 19 Feb 2009, at 09:41, James Montgomerie wrote: If you don't, objects created within it and autoreleased will not get the change to be fully released until the loop finishes, Not quite sure how I came up with sentence construction like that. What I meant was, If you don't, objects

Re: Responding to view controller memory warnings (was Re: Outlets / IBOutlet declarations)

2009-02-19 Thread James Montgomerie
Returning to this months-old thread... Apologies for the length of the mail, I thought it best to summarise what went before. I suggested that an appropriate implementation for didReceiveMemoryWarning in a UIViewController subclass would be On 22 Nov 2008, at 15:58, James Montgomerie

Re: Responding to view controller memory warnings (was Re: Outlets / IBOutlet declarations)

2009-02-19 Thread James Montgomerie
On 19 Feb 2009, at 21:41, Ricky Sharp wrote: On Feb 19, 2009, at 2:18 PM, James Montgomerie wrote: Returning to this months-old thread... Apologies for the length of the mail, I thought it best to summarise what went before. I now have shipping iPhone OS apps and during all my tests

Re: NSXML Auto Release Pools

2009-02-04 Thread James Montgomerie
On 4 Feb 2009, at 18:06, Alan Shouls wrote: I am using NSXML in a C++ and am working through some test cases and have come across something I can't quite figure out. Here is what I do: 1. Create an Auto Release Pool 2. Create an NSXML object using [NSXMLDocument alloc] initWithData: (NSData

Re: App Listener?

2009-01-08 Thread James Montgomerie
On 8 Jan 2009, at 14:14, Rainer Brockerhoff wrote: Today, the only solution seems to be to install a Carbon Event handler for the {kEventClassApplication, kEventAppFrontSwitched} event. Even if such a NSWorkspace notification were to appear in a future version of Mac OS X, I'd be

Re: Printing PDF Documentation

2009-01-06 Thread James Montgomerie
On 6 Jan 2009, at 13:20, Development wrote: No, I do not need to write code to work with PDF; the example program to do this is pretty good. However, lots of documentation from Apple and other companies are not available exclusively as PDF file. Does anyone know of a good reliable source

Re: how to pass arguments by reference

2008-12-10 Thread James Montgomerie
What you're looking to do is a C++ism, it's not available in Objective- C; there's no explicit support for pass by reference. It's certainly possible to achieve the same ends though. For primitive types, you'll have to pass a pointer. Declare the method as taking, for example 'int *' if

Re: to get handle to File/1.jpg

2008-11-26 Thread James Montgomerie
On 26 Nov 2008, at 14:56, Nick Rogers wrote: Hi, How do I obtain a NSFileHandle to this file which has a forward slash in the name to be able to write to this file. Supplying the path to NSFileHandle with filename in quotes also fails. If not possible is there any other way to write to such a

Re: to get handle to File/1.jpg

2008-11-26 Thread James Montgomerie
On 26 Nov 2008, at 15:28, Jean-Daniel Dupas wrote: Le 26 nov. 08 à 16:19, James Montgomerie a écrit : On 26 Nov 2008, at 14:56, Nick Rogers wrote: Hi, How do I obtain a NSFileHandle to this file which has a forward slash in the name to be able to write to this file. Supplying the path

Re: Responding to view controller memory warnings (was Re: Outlets / IBOutlet declarations)

2008-11-22 Thread James Montgomerie
On 22 Nov 2008, at 00:53, mmalcolm crawford wrote: Context: UIViewController provides a method, didReceiveMemoryWarning, which is invoked on view controllers when the amount of memory available to the application is severely constrained. The goal of the method is to allow view

Re: Responding to view controller memory warnings (was Re: Outlets / IBOutlet declarations)

2008-11-22 Thread James Montgomerie
Nov 2008, at 16:16, mmalcolm crawford wrote: On Nov 22, 2008, at 7:58 AM, James Montgomerie wrote: if(self.anOutlet !self.view.superview) { On Nov 19, 2008, at 12:59 AM, mmalcolm crawford wrote: You could invoke 'view': - (void)didReceiveMemoryWarning { if ([self.view superview

Re: Responding to view controller memory warnings (was Re: Outlets / IBOutlet declarations)

2008-11-22 Thread James Montgomerie
On 22 Nov 2008, at 16:29, mmalcolm crawford wrote: On Nov 22, 2008, at 8:16 AM, mmalcolm crawford wrote: [...] Sorry, pressed Deliver on the wrong message by mistake. Let me check on this one. Oops, sorry, looks like we're mailing around each other now... Jamie.

Re: !foo vs foo == nil

2008-08-21 Thread James Montgomerie
On 21 Aug 2008, at 09:06, Clark Cox wrote: This is not a hack or a coincidence, this is by design. A non-NULL pointer *is* a boolean expression that evaluates to true, just as a non-zero integer is. Again, it doesn't work by coincidence, it is a guarantee of the language standard. To go off on

Re: Receive notifications about frontmost application change

2008-07-09 Thread James Montgomerie
On 9 Jul 2008, at 18:46, Bill Cheeseman wrote: on 2008-07-09 11:44 AM, Jens Alfke at [EMAIL PROTECTED] wrote: On 9 Jul '08, at 3:22 AM, Александр Даровских wrote: Hi, Is there any way to subscribe to frontmost application change notification? For example, via NSDistributedNotificationCenter

A question of style: Returning 'pairs'

2008-07-02 Thread James Montgomerie
Say I have a method that needs to return two equally important values (in my case, a string and an offset into it). I am overthinking how to do it, and I though it would be interesting to see what others have done. I see these opportunities (my use of 'object' and 'value' is blurred

Re: Regular Expressions?

2008-06-06 Thread James Montgomerie
On 6 Jun 2008, at 08:03, Jens Alfke wrote: On 6 Jun '08, at 3:23 AM, Jason Stephenson wrote: As a long time UNIX programmer, I'll suggest looking into the regexp library that already comes with OS X. man regcomp on the command line to find out how to use. It doesn't look as though this

Re: iChat theater

2008-05-11 Thread James Montgomerie
As you say, there is no way for an app to cause a transition to IMAVRequested, the user has to initiate the session from iChat. If your app is not document based, the user can request a session by selecting your app in the Share a file via iChat Theater file requester (or by dragging your