Re: OS constant cause 32-bit RIP relative reference out of range linker error on x64

2012-06-13 Thread Dave Zarzycki
Please reduce this down to a simple test case. Thanks! On Jun 13, 2012, at 4:16 AM, Vojtěch Meluzín meldaproduct...@gmail.com wrote: Hi, I'm trying to make x64 work on XCode 4 Mac OS 10.7, but whenever I use a system constant, such as kCFAllocatorDefault, I get this linker error (on x86

Re: Question about dispatch_timer function

2012-04-26 Thread Dave Zarzycki
On Apr 25, 2012, at 6:07 PM, Kévin Vavelin vavelinke...@gmail.com wrote: Hi there, I've a question about the dispatch_timer function. I try to make a strobe flash on my iPhone app and for that i used an NSTimer but a friend of mine say that it's better to use dispatch function. So i was

Re: Fast Enumeration and temporary objects/autoreleasing

2012-04-17 Thread Dave Zarzycki
On Apr 17, 2012, at 1:28 AM, Graham Cox graham@bigpond.com wrote: …having been using Objective C productively for over 10 years now, that I still find ARC something I have not needed. So far. I'm kinda hoping that remains true, because it actually seems pretty complicated in order to

Re: Fast Enumeration and temporary objects/autoreleasing

2012-04-16 Thread Dave Zarzycki
On Apr 16, 2012, at 8:10 PM, Graham Cox graham@bigpond.com wrote: Memory management is really quite straightforward, and consists of a few rules that everything follows (the framework invariably does; your code should do). If that were true, then ARC would not have been necessary. On

Re: Dictionary not returning objects

2012-04-15 Thread Dave Zarzycki
On Apr 15, 2012, at 3:46 PM, Markus Spoettl ms_li...@shiftoption.com wrote: On 4/15/12 8:06 PM, Scott Ribe wrote: On Apr 15, 2012, at 12:01 PM, Markus Spoettl wrote: I have an NSDictionary that contains, well, objects. When I call -objectForKey: I get nil for keys that are definitely in

Re: Convert to Objective-C ARC Syntax Error

2012-04-01 Thread Dave Zarzycki
Brad, This looks similar to Radar 10434539. Let me know if this works: simplify the header includes in your code to just #import Quartz/Quartz.h and just link against Quartz. If your code is already doing this, then let us know. Thanks! davez On Mar 31, 2012, at 3:39 PM, Brad Stone

Re: ARC not ready for primetime?

2012-03-24 Thread Dave Zarzycki
Scott, Please reduce this down to a test case so that we might try and reproduce what you are observing. Thanks! davez On Mar 24, 2012, at 1:17 AM, Scott Andrew scottand...@roadrunner.com wrote: I seem to have hit a few limitations with ARC. 1.) Subclasses of CALayer are not being fully

Re: Accessing array in thread safe way

2012-03-06 Thread Dave Zarzycki
On Mar 6, 2012, at 11:51 AM, Jan E. Schotsman jesc...@xs4all.nl wrote: Hello, I have an array of progress values (number objects) for subprojects, from which I calculate the overall progress . The array is an atomic property of the project class. Is it safe to access this array from

Re: Block Behavior

2012-02-15 Thread Dave Zarzycki
Koko, Are you using C++? (Probably.) If you are, then do you have a const version of Set? (Probably not.) If the above is not true, then what is the exact compiler error, and can you reduce this down to a test case? Thanks! davez On Feb 15, 2012, at 3:14 PM, koko k...@highrolls.net wrote:

Re: ARC in Snow Leopard?

2012-02-12 Thread Dave Zarzycki
On Feb 11, 2012, at 9:49 PM, Kyle Sluder kyle.slu...@gmail.com wrote: On Feb 11, 2012, at 3:56 PM, Charles Srstka cocoa...@charlessoft.com wrote: On Feb 11, 2012, at 5:25 PM, William Squires wrote: is ARC a Lion-only feature or will an ARC-compiled app work on 10.6.8 assuming no other

Re: ARC in Snow Leopard?

2012-02-12 Thread Dave Zarzycki
On Feb 12, 2012, at 12:06 PM, Mike Abdullah cocoa...@mikeabdullah.net wrote: On 12 Feb 2012, at 02:49, Kyle Sluder wrote: On Feb 11, 2012, at 3:56 PM, Charles Srstka cocoa...@charlessoft.com wrote: On Feb 11, 2012, at 5:25 PM, William Squires wrote: is ARC a Lion-only feature or will

Re: Calling an Objective-C function from C++?

2012-01-31 Thread Dave Zarzycki
Howard, If you don't want to rename your .cpp file to .mm, then you can just tell Xcode to ignore the file extension and always compile as Objective-C++. Then your C++ code can call Objective-C code natively when compiling for Mac OS X / iOS. davez On Jan 31, 2012, at 11:31 AM, Howard Moon

Re: Crash and dispatch queue

2011-11-17 Thread Dave Zarzycki
James, We need a lot more information before we can give any help. Please strongly consider reducing your experience down to a compilable test case. Good luck, davez On Nov 17, 2011, at 1:49 PM, James Maxwell wrote: I have a method that's crashing with EXC_BAD_ACCESS. I'm running a fairly

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

2011-11-04 Thread Dave Zarzycki
You're tripping across a fundamental aspect of how virtual memory works. For example: what do you expect will happen if you do this on an iOS device (none of which have more than 512*1024*1024 bytes of memory)? void *x = malloc(1024*1024*1024); assert(x); The answer depends on

Re: Blocks vs. life, the universe and everything

2011-10-15 Thread Dave Zarzycki
On Oct 14, 2011, at 11:44 PM, Jean-Daniel Dupas wrote: Le 15 oct. 2011 à 01:45, Quincey Morris a écrit : On Oct 14, 2011, at 14:27 , Greg Parker wrote: Do you actually use exceptions in your code, or do you follow the Cocoa convention that exceptions are for programmer error only? If

Re: Blocks vs. life, the universe and everything

2011-10-15 Thread Dave Zarzycki
On Oct 15, 2011, at 12:10 PM, Seth Willits wrote: Unrelated, when did @autoreleasepool pop in? I don't remember if I knew about that or not. It's _used_ once in the Obj-C Programming Language guide, but never documented anywhere I can find. @autoreleasepool {} is new with Xcode 4.2 and

Re: Implementing a Synchronous Channel with dispatch

2011-09-14 Thread Dave Zarzycki
Andreas, This is probably not the answer you're looking for, but when we find coding patterns like this in the OS, we advice developers to replace this pattern with a GCD queue and use either dispatch_sync() or dispatch_async(). The reason for this advice is because parking threads to wait for

Re: Implementing a Synchronous Channel with dispatch

2011-09-14 Thread Dave Zarzycki
On Sep 14, 2011, at 9:38 AM, Andreas Grosam wrote: On Sep 14, 2011, at 4:20 PM, Dave Zarzycki wrote: Andreas, This is probably not the answer you're looking for, but when we find coding patterns like this in the OS, we advice developers to replace this pattern with a GCD queue

Re: Implementing a Synchronous Channel with dispatch

2011-09-14 Thread Dave Zarzycki
On Sep 14, 2011, at 12:08 PM, Andreas Grosam wrote: On Sep 14, 2011, at 8:00 PM, Dave Zarzycki wrote: Dispatch queues exist to solve both the synchronous and asynchronous producer/consumer pattern. If you want the producer to wait until the consumer is done, then use dispatch_sync

Re: ARC + CF types

2011-08-29 Thread Dave Zarzycki
Thomas, Why not use a NSMutableSet and avoid the bridging casts entirely? davez On Aug 29, 2011, at 7:20 AM, Thomas Davie wrote: I'm not really very clear on how ARC and CF types are meant to interact yet, because of that I've managed to create some buggy code, could someone have a

Re: ARC + CF types

2011-08-29 Thread Dave Zarzycki
Or, your code could subclass NSMutableSet and interpose the methods that add to the set. In other words, mentally separate objects that are equal from objects that should be in the set. The former is an equality check, the latter is a policy decision. davez On Aug 29, 2011, at 7:37 AM,

Re: ARC and Singletons

2011-08-02 Thread Dave Zarzycki
Karl, This is not on our todo list or any list that I know of. Please file a bug report if this enhancement request is interesting to you. Thanks! :-) davez On Aug 2, 2011, at 4:59 PM, Karl Goiser wrote: Hi Greg, Is that wishful thinking or a hint about the future? :-) All I have

Re: ARC and Singletons

2011-08-01 Thread Dave Zarzycki
The simplest and most ARC friendly way to implement the singleton pattern is to switch from instance methods to class methods – because the class itself is by definition a singleton. In other words: + (MyClass *)sharedInstance; // and maybe override alloc/retain/release to

Re: ARC and Singletons

2011-08-01 Thread Dave Zarzycki
that ARC does not magically fix concurrency issues (globals or otherwise). davez Jeff Kelley On Mon, Aug 1, 2011 at 12:05 PM, Dave Zarzycki zarzy...@apple.com wrote: The simplest and most ARC friendly way to implement the singleton pattern is to switch from instance methods to class methods

Re: Why does NSArray count return NSUInteger?

2011-05-30 Thread Dave Zarzycki
On May 30, 2011, at 1:45 PM, julius wrote: On 30 May 2011, at 20:03,Quincey Morris wrote On May 30, 2011, at 08:27, julius wrote: All I had hoped was that someone on this list might illuminate the issue more than has happened so far. The problem isn't really lack of illumination,

Re: Fire-and-forget controllers with blocks

2011-05-20 Thread Dave Zarzycki
On May 20, 2011, at 5:48 AM, Ben wrote: MyImportController *controller = nil; CleanupBlock cleanup = ^{ [controller release]; // Other stuff }; controller = [[MyImportController alloc] initWithCleanupBlock:[[cleanup copy] autorelease]]; [controller start]; // The controller

Re: create an autorelease pool in the init-method and release it in the dealloc-method ..?

2011-05-14 Thread Dave Zarzycki
Here is a trick to help you better understand how to use autorelease pools correctly. Put this in a header somewhere: static inline void subpool(void (^block)(void)) { NSAutoreleasePool *_pool = [[NSAutoreleasePool alloc] init]; block(); [pool drain]; } … and use it like

Re: Lockless thread-safe accessor using blocks: how to?

2011-04-14 Thread Dave Zarzycki
On Apr 14, 2011, at 6:20 AM, WT wrote: Hi all, I've started to use GCD in my projects and I found myself using a certain pattern that I now realize isn't actually thread safe. The goal is to write a thread-safe lazy accessor without using locks, @synchronized, or an atomic property. At

Re: Lockless thread-safe accessor using blocks: how to?

2011-04-14 Thread Dave Zarzycki
On Apr 14, 2011, at 10:11 AM, WT wrote: Hi Dave, thanks for replying. I must say some of what you said went above my head. :) On Apr 14, 2011, at 2:02 PM, Dave Zarzycki wrote: The first is that if the method gets invoked already in the queue's automatic thread

Re: dynamic binding in initializers

2011-02-24 Thread Dave Zarzycki
Roland, Check this out: http://cocoawithlove.com/2008/03/cocoa-application-startup.html The code should arguably live in a +initialize method. davez On Feb 24, 2011, at 6:41 AM, Roland King wrote: I burned myself today with a pattern I've been using for ages. I have lots of

Re: Reliable way to determine bitness of the kernel

2011-02-22 Thread Dave Zarzycki
We support fat binaries. Please use them to avoid this problem entirely. You just need to reconfigure your kext project to build both architectures at the same. A simple example from the command line: /tmp $ cat test.c #include stdio.h int main(void) { printf(sizeof(void *) ==

Re: GCD cancel handler invocation

2011-01-10 Thread Dave Zarzycki
On Jan 10, 2011, at 2:06 PM, Jonathon Kuo wrote: I set up a source handler on a TCP socket like this: dispatch_source_t newsrc = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ,sockfd,0,globalQueue); It works well, and when a client process closes his socket my cancel_handler gets

Re: GCD cancel handler invocation

2011-01-10 Thread Dave Zarzycki
On Jan 10, 2011, at 3:04 PM, Jonathon Kuo wrote: On Jan 10, 2011, at 2:58 PM, Ken Thomases wrote: On Jan 10, 2011, at 4:20 PM, Dave Zarzycki wrote: On Jan 10, 2011, at 2:06 PM, Jonathon Kuo wrote: I set up a source handler on a TCP socket like this: dispatch_source_t newsrc

Re: Context in GCD source cancel handler?

2011-01-06 Thread Dave Zarzycki
On Jan 6, 2011, at 12:17 PM, Jonathon Kuo wrote: On Jan 5, 2011, at 12:41 PM, Dave Keck wrote: Q: When a context object is set with dispatch_set_context(), is it retained? Or do I need to retain it first, set it, and then in the cancel handler release it? The 'context' argument is

Re: Context in GCD source cancel handler?

2011-01-06 Thread Dave Zarzycki
will be equal to EPIPE. davez On Jan 6, 2011, at 1:22 PM, Jonathon Kuo wrote: On Jan 6, 2011, at 1:15 PM, Fritz Anderson wrote: Taking by value to mean as many uninterpreted bits as will fit into a variable of type void*, yes. On Jan 6, 2011, at 1:14 PM, Dave Zarzycki wrote: Yes

Re: Context in GCD source cancel handler?

2011-01-05 Thread Dave Zarzycki
Jonathon, GCD is an object oriented API done in C. If you look at the man page entitled dispatch_object, you'll see that one can call dispatch_set_context() and dispatch_get_context() against any GCD object (sources and queues are where they make the most sense). In fact, if you're simply

Re: cannot access __block variable of array type inside block

2010-12-14 Thread Dave Zarzycki
Jonathon, This is being tracked by our internal bug number 8590846. I'm told that the workaround is to place the array within a structure: __block struct { double result[COUNT]; } results; davez On Dec 14, 2010, at 7:30 PM, Jonathon Kuo wrote: I'm trying to learn GCD and reading