Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread Andy Lee
I'm not really following this thread, so I might be missing important context, but I think it's possible the base class could be an abstract class, perhaps providing nothing except the ability for concrete subclasses to make singleton instances of themselves. You might reuse this class in differ

Re: Global Shortcuts

2011-04-17 Thread Florian Pilz
@Eric: Thanks. In the meantime I saw that some methods have a "deprecated" tag on their side, but not the method in question. :) @Bavarious, Dave: I am a beginner, thus I want to try to achieve my goals without wrappers and external libraries. But thanks. Already have a working implementation, th

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread Kyle Sluder
On Apr 16, 2011, at 10:20 PM, WT wrote: > > On Apr 17, 2011, at 12:31 AM, Kyle Sluder wrote: > >> Do you really need a singleton, or just a default instance? > > A singleton. Okay, next question: why? Is there a reason that you can't replace all your calls to +alloc/-init with +sharedInstanc

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread Scott Ribe
On Apr 16, 2011, at 9:04 PM, WT wrote: > Among other things, I wanted to replace my usage of @synchronized > singletons... Why? As a learning experience, experimenting with GCD, what you're doing is somewhat instructive. But your stated goal seems pointless to me. Whether you use @synchronized

AVFoundation -- Authorization for Playback of Protected Content?

2011-04-17 Thread Brad Gibbs
There's a note in AV Foundation Release Notes for iOS 4.3 that reads: Note that the value of each of these properties is YES even if the associated operation is only conditionally supported. Examples: playable is YES even if the asset has protected content and requires authorization of both the

Re: AVFoundation -- Authorization for Playback of Protected Content?

2011-04-17 Thread Eli Bach
On Apr 17, 2011, at 10:10 AM, Brad Gibbs wrote: > Is this saying that an authorized app, such as iTunes or QuickTime is > required to play protected content? Yes. > Or, is there some way for me to authorize my own AV Foundation-based app and > protected content and then play it back in an AVP

Re: AVFoundation -- Authorization for Playback of Protected Content?

2011-04-17 Thread Brad Gibbs
Thanks for the response. On the desktop, I'd be limited to AppleScript control over iTunes or Quicktime Player X? QTKit can't play protected content, can it? On Apr 17, 2011, at 9:17 AM, Eli Bach wrote: > > On Apr 17, 2011, at 10:10 AM, Brad Gibbs wrote: > >> Is this saying that an authori

Background Applications vs Threading

2011-04-17 Thread Bing Li
Dear all, I am programming on iPad. I notice that background applications are not allowed for power issues on iPad. I am not sure how to define the concept of background applications? In my system, I need to have multiple threads run when users interact with my system. The work done by the threads

Re: Background Applications vs Threading

2011-04-17 Thread Fritz Anderson
On 17 Apr 2011, at 12:04 PM, Bing Li wrote: > I am programming on iPad. I notice that background applications are not > allowed for power issues on iPad. I am not sure how to define the concept of > background applications? In my system, I need to have multiple threads run > when users interact wi

iOS 4: more AVAsset questions

2011-04-17 Thread John Michael Zorko
Hello, all ... I've more questions regarding AVAsset: 1. I see AVAsset and AVURLAsset. Is there a subclass that allows me to create an asset from a bytestream? I'm finding that AVURLAsset is a bit too high level for what I need to do (that being, create an asset for a stream of bytes coming f

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread WT
Hi Ken, On Apr 17, 2011, at 3:00 AM, Ken Thomases wrote: > On Apr 17, 2011, at 12:20 AM, WT wrote: > >> On Apr 17, 2011, at 12:31 AM, Kyle Sluder wrote: >> self class] alloc] init] autorelease]; >>> >>> You are in a class method. self == [self class], so no need to call +class >

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread WT
On Apr 17, 2011, at 3:11 AM, Dave DeLong wrote: > This is a truly strange question. If you interpret a singleton to be "one and > only one", then it doesnt make much sense to ask about subclassing it, > because that would imply that you could instantiate one of the base type and > one of the su

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread WT
> it's possible the base class could be an abstract class, perhaps providing > nothing except the ability for concrete subclasses to make singleton > instances of themselves Yes, that's precisely the use I have in mind, because it's the most common in my projects. WT On Apr 17, 2011, at 4:02

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread WT
On Apr 17, 2011, at 12:03 PM, Kyle Sluder wrote: > On Apr 16, 2011, at 10:20 PM, WT wrote: > >> >> On Apr 17, 2011, at 12:31 AM, Kyle Sluder wrote: >> >>> Do you really need a singleton, or just a default instance? >> >> A singleton. > > Okay, next question: why? Is there a reason that you c

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread WT
On Apr 17, 2011, at 12:57 PM, Scott Ribe wrote: > On Apr 16, 2011, at 9:04 PM, WT wrote: > >> Among other things, I wanted to replace my usage of @synchronized >> singletons... > > Why? As a learning experience, experimenting with GCD, what you're doing is > somewhat instructive. That's one o

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread Joanna Carter
Hi guys > That's only because, unlike java, obj-c doesn't have a way built into the > language to enforce a class to be abstract. I can see valid reasons to > subclass a singleton if that singleton is to be used as an abstract class and > never be instantiated by itself. Tell me; maybe it's my

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread WT
On Apr 17, 2011, at 3:52 PM, Joanna Carter wrote: > Hi guys > >> That's only because, unlike java, obj-c doesn't have a way built into the >> language to enforce a class to be abstract. I can see valid reasons to >> subclass a singleton if that singleton is to be used as an abstract class >> a

Re: iOS 4: more AVAsset questions

2011-04-17 Thread Mike Abdullah
I'm no expert on AVFoundation, but there's a fair chance it's using the Cocoa URL loading system under the hood. If so, you could always resort to implementing your own custom URL scheme and passing that in. On 17 Apr 2011, at 19:35, John Michael Zorko wrote: > > Hello, all ... > > I've more

How do I disable Xcode 4's SVN support?

2011-04-17 Thread John Michael Zorko
Hello, all ... I run my own SVN server, and I do my own SVN management. I would greatly prefer that Xcode 4 not even try to talk to my SVN server, as it keeps asking me to allow access to that key in my keychain, over and over and over and over again. How can I disable Xcode 4's SVN support pe

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread Scott Ribe
On Apr 17, 2011, at 12:43 PM, WT wrote: > That's not what I keep reading/hearing. Apple's made a big push for GCD in > WWDC 2010, even on iOS devices. Yeah, for actually performing tasks on background threads, which is not what you're doing here. > I think that's an oversimplification of how t

Re: How do I disable Xcode 4's SVN support?

2011-04-17 Thread WT
On Apr 17, 2011, at 4:23 PM, John Michael Zorko wrote: > > Hello, all ... > > I run my own SVN server, and I do my own SVN management. I would greatly > prefer that Xcode 4 not even try to talk to my SVN server, as it keeps asking > me to allow access to that key in my keychain, over and over

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread WT
On Apr 17, 2011, at 4:28 PM, Scott Ribe wrote: > On Apr 17, 2011, at 12:43 PM, WT wrote: > >> That's not what I keep reading/hearing. Apple's made a big push for GCD in >> WWDC 2010, even on iOS devices. > > Yeah, for actually performing tasks on background threads, which is not what > you're

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread Joanna Carter
Hi WT > what happens if you need/want to subclass that class? Then you have to search > for and change all the places in your code base that refer to it. Hmmm, I have a problem with the idea of subclassing singletons. Does the derived instance contain the same data as the base class; so that an

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread Quincey Morris
On Apr 17, 2011, at 12:04, WT wrote: > On Apr 17, 2011, at 3:52 PM, Joanna Carter wrote: > >> >> Tell me; maybe it's my background in other languages, but I would tend to >> use a "static class" as a singleton; or, at least, design a class with only >> class methods/properties, with static "f

NSString "midstring()"

2011-04-17 Thread JAMES ROGERS
I know there must be a better way but this was all I could come up with as a rookie cocoa programmer to get a substring out of a very long NSString from a textView growing as the operator types in the message content. The receive buffer in the chip I am talking to will only take 80 characters b

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread Eeyore
On Apr 17, 2011, at 12:58 PM, Quincey Morris wrote: > On Apr 17, 2011, at 12:04, WT wrote: > >> On Apr 17, 2011, at 3:52 PM, Joanna Carter wrote: >> >>> > >>> Tell me; maybe it's my background in other languages, but I would tend to >>> use a "static class" as a singleton; or, at least, desi

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread WT
On Apr 17, 2011, at 4:55 PM, Joanna Carter wrote: > Hi WT > >> what happens if you need/want to subclass that class? Then you have to >> search for and change all the places in your code base that refer to it. > > Hmmm, I have a problem with the idea of subclassing singletons. Does the > deriv

Re: NSString "midstring()"

2011-04-17 Thread Mike Abdullah
Why not use -substringWithRange: ? On 17 Apr 2011, at 21:09, JAMES ROGERS wrote: > I know there must be a better way but this was all I could come up with as a > rookie cocoa programmer to get a substring out of a very long NSString from > a textView growing as the operator types in the messag

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread WT
Hi Quincey, thanks for pitching in. On Apr 17, 2011, at 4:58 PM, Quincey Morris wrote: > 1. Conceptually, I think Joanna is right. In practice, I've found that using > the class as a singleton doesn't always serve the purpose -- though I can > never remember the usage case that's a problem. I t

Re: NSString "midstring()"

2011-04-17 Thread Quincey Morris
On Apr 17, 2011, at 13:09, JAMES ROGERS wrote: > char sndBuffer[65]; > int j; > > characterIndex++; // is always sitting at the last character sent so advance > to the next character in string. > for (j = 0; j < 65; j++) { >sndBuffer[j] = [string characterAtIndex:characterIndex]; >chara

Re: NSString "midstring()"

2011-04-17 Thread JAMES ROGERS
Quincy, I have stepped this through with the debugger and no flags were raised. The code compiles without an error or a warning of any kind. I am afraid your response has overwhelmed me. One thing I will mention, I am not changing string. So that point is a moot one. I am just copying data o

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread Quincey Morris
On Apr 17, 2011, at 13:46, WT wrote: > At the end of the day, the most honest answer I can give is that I wanted to > explore dispatch_once() and thought that doing so in the context of > implementing singletons would be a good learning experience. > > This thread and links to some blogs on the

Re: NSString "midstring()"

2011-04-17 Thread JAMES ROGERS
Mike, thanks for your response. I looked at -substringWithRange but could not discern how exactly I would apply it. I will take another look. Thanks, Jim On Apr 17, 2011, at 3:22 PM, Mike Abdullah wrote: > Why not use -substringWithRange: ? > > On 17 Apr 2011, at 21:09, JAMES ROGERS wrote: > >

Re: NSString "midstring()"

2011-04-17 Thread Stephen J. Butler
On Sun, Apr 17, 2011 at 4:08 PM, JAMES ROGERS wrote: > I have stepped this through with the debugger and no flags were raised. The > code compiles without an error or a warning of any kind. I am afraid your > response has overwhelmed me. You didn't see it in the debugger because you aren't usin

Re: NSString "midstring()"

2011-04-17 Thread Quincey Morris
On Apr 17, 2011, at 14:08, JAMES ROGERS wrote: > I have stepped this through with the debugger and no flags were raised. The > code compiles without an error or a warning of any kind. I am afraid your > response has overwhelmed me. > > One thing I will mention, I am not changing string. So tha

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread Scott Ribe
On Apr 17, 2011, at 2:46 PM, WT wrote: > I've worked on projects where other people have made the app delegate > responsible for everything and the kitchen sink. It's one thing to have a few > core data stack methods in the app delegate; it's another to do a lot of > one's core data tasks in th

Re: renaming directories and moving files into them (NSFileManager)

2011-04-17 Thread Scott Anguish
not sure what to say, my code wasn’t doing that. I ended up churning through all the files once, finding the .mp4s, getting the whereas information and then making the directory I needed first. I just didn’t have more time to spend trying to figure it out. Now I feel like I need to though... :-

Re: NSString "midstring()"

2011-04-17 Thread Gerriet M. Denkmann
On 18 Apr 2011, at 03:54, Quincey Morris wrote: > > On Apr 17, 2011, at 13:09, JAMES ROGERS wrote: > >> char sndBuffer[65]; >> int j; >> >> characterIndex++; // is always sitting at the last character sent so >> advance to the next character in string. >> for (j = 0; j < 65; j++) { >> snd

Re: Access main window of other Applications

2011-04-17 Thread Florian Pilz
Thanks again Peter! I have a working solution now (see below). It doesn't rely on the Accessibility API, whereby AppleScript functions like `set size` or `ser position` does. However, I am still not sure if I should in fact rely on the Accessibility API as Apple explains that this API is enabled in

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread Greg Parker
On Apr 17, 2011, at 11:42 AM, WT wrote: > Hi Ken, > > On Apr 17, 2011, at 3:00 AM, Ken Thomases wrote: > >> On Apr 17, 2011, at 12:20 AM, WT wrote: >> >>> On Apr 17, 2011, at 12:31 AM, Kyle Sluder wrote: >>> > self class] alloc] init] autorelease]; You are in a class me

Re: renaming directories and moving files into them (NSFileManager)

2011-04-17 Thread Andy Lee
But seriously... there's more going on in your code than in mine, so the problem must lie in whatever is different (or be somehow caused by the data rather than the code). Like you say, what you're doing *seems* pretty straightforward and what you're seeing *seems* impossible (my favorite kind o

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread Greg Parker
On Apr 16, 2011, at 8:34 PM, Kyle Sluder wrote: > On Sat, Apr 16, 2011 at 8:31 PM, Kyle Sluder wrote: >> + (id)sharedInstance { >> static id sharedInstance; >> static dispatch_once_t once; >> dispatch_once(&once, ^{ sharedInstance = [[self alloc] init]; }); >> return sharedInstance; >> } > >

Re: Proper way to create a singleton without @synchronized ?

2011-04-17 Thread Greg Parker
On Apr 17, 2011, at 11:52 AM, Joanna Carter wrote: > Tell me; maybe it's my background in other languages, but I would tend to use > a "static class" as a singleton; or, at least, design a class with only class > methods/properties, with static "fields" declared in the @implementation > section

Re: renaming directories and moving files into them (NSFileManager)

2011-04-17 Thread Andy Lee
On Apr 18, 2011, at 1:56 AM, Andy Lee wrote: > But seriously... Oops. I had inserted a lame joke, but deleted it. Unfortunately I forgot to delete the "But seriously...". --Andy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not p