Re: Swift and Threads

2016-09-13 Thread Stephen J. Butler
This site suggests a version using withUnsafeMutableBufferPointer: http://blog.human-friendly.com/swift-arrays-are-not-threadsafe let nbrOfThreads = 8 let step = 2 let itemsPerThread = number * step let bitLimit = nbrOfThreads * itemsPerThread var bitfield = [Bool](count: bitLimit, repeatedValue:

Re: Where are my bytes hiding?

2016-05-04 Thread Stephen J. Butler
Those files are compressed by the filesystem. In HFS+/MacOS Extended that means that the data fork is empty and the file contents are stored in the resource fork or extended attributes structure. http://wiki.sleuthkit.org/index.php?title=HFS#HFS.2B_File_Compression If it's in the extended attribu

Re: Diff view framework?

2016-01-25 Thread Stephen J. Butler
How about using a webkit view and one of these diff2html scripts: http://stackoverflow.com/questions/641055/diff-to-html-diff2html-program On Mon, Jan 25, 2016 at 3:08 AM, Jonathan Guy wrote: > Hi all > Does anyone know of a cocoa framework which provides a view for showing > file differences?

Re: Handling http:// URLs

2015-10-13 Thread Stephen J. Butler
I think you're talking about Seamless Linking/Universal Links. Introduced in iOS 9 https://developer.apple.com/videos/play/wwdc2015-509/ https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html On Tue, Oct 13, 2015 at 7:20 PM, Rick Mann w

Re: Question about enums

2015-07-17 Thread Stephen J. Butler
class. On Fri, Jul 17, 2015 at 3:39 PM, Quincey Morris < quinceymor...@rivergatesoftware.com> wrote: > On Jul 17, 2015, at 13:33 , Stephen J. Butler > wrote: > > > How about using a Custom option with an associated String value? > > enum Foo:String { > >ca

Re: Question about enums

2015-07-17 Thread Stephen J. Butler
Oops, yes, obviously I haven't played much with raw representable enums yet :) Thanks for the correction. On Fri, Jul 17, 2015 at 3:39 PM, Quincey Morris < quinceymor...@rivergatesoftware.com> wrote: > On Jul 17, 2015, at 13:33 , Stephen J. Butler > wrote: > > > How a

Re: Question about enums

2015-07-17 Thread Stephen J. Butler
How about using a Custom option with an associated String value? enum Foo:String { case Bar = “Bar" case Etc = “Etc" case Etc_Etc = “Etc Etc" case Custom(String) } On Fri, Jul 17, 2015 at 2:53 PM, Michael de Haan  wrote: > I wonder if I can get some input as I seemed to have

Re: cannot invoke 'substringToIndex' with an argument list of type '(Int)'

2015-07-07 Thread Stephen J. Butler
You should file a documentation bug. The signature is actually: func substringFromIndex(index: String.Index) -> String So what you really want I believe is: s = s.substringToIndex(advance(s.endIndex, -1)) On Tue, Jul 7, 2015 at 2:02 AM, Rick Mann wrote: > What? The docs say that substringToI

Re: Swift 2 init() with CF types and throws

2015-07-01 Thread Stephen J. Butler
You're focusing on the wrong part :) Which element of your code has a type of "NSGraphicsContext"? It's cocoaCTX! The compiler error is suggesting you do one of these: cocoaCTX?.graphicsPort cocoaCTX!.graphicsPort On Wed, Jul 1, 2015 at 6:28 PM, Rick Mann wrote: > I'm trying to do this: > > cl

Re: Swift program termination...

2015-05-24 Thread Stephen J. Butler
I think you should use GCD by creating a dispatch source of type DISPATCH_SOURCE_TYPE_SIGNAL (the handle is the signal enum, eg SIGTERM), add an event handler, and then resume it. On Sun, May 24, 2015 at 10:40 AM, Randy Widell wrote: > I’m messing around with Swift to create a network server daem

Re: Best way to move a file out of the way?

2015-03-24 Thread Stephen J. Butler
I would say rename the new destination file if you think you should keep the old one around. However, if it's always the case that the new file should replace the old one when it finishes downloading, then you should save the new file under a temporary name and use -[NSFileManager replaceItemAtURL

Re: Crash in libsystem_kernel.dylib`__workq_kernreturn:

2015-01-25 Thread Stephen J. Butler
I agree that it sounds like a memory management bug. Especially since you aren't using ARC. Try turning on NSZombies and see if it crashes at a more helpful point. http://michalstawarz.pl/2014/02/22/debug-exc_bad_access-nszombie-xcode-5/ On Sun, Jan 25, 2015 at 4:57 PM, Trygve Inda wrote: >> On

Re: URLByResolvingBookmarkData not case sensitive

2015-01-06 Thread Stephen J. Butler
What about this (caveat: only works if the file exists): @interface NSArray (FileNSURL) - (NSUInteger) indexOfFileNSURL:(NSURL*)aFileURL error:(NSError**)error; @end @implementation NSArray (FileNSURL) - (NSUInteger) indexOfFileNSURL:(NSURL *)aFileURL error:(NSError**)error { id srcResourceI

Re: NSRegularExpression segfault

2014-12-15 Thread Stephen J. Butler
> On Mon, Dec 15, 2014 at 6:09 PM, Stephen J. Butler < > stephen.but...@gmail.com> wrote: >> >> If you read the ICU docs on regular expressions you'll see that it sets >> an 8MB limit on head size when evaluating. My guess is that you've run into >> this

Re: NSRegularExpression segfault

2014-12-15 Thread Stephen J. Butler
If you read the ICU docs on regular expressions you'll see that it sets an 8MB limit on head size when evaluating. My guess is that you've run into this and NSRegularExpression misses a return code somewhere. But your pattern is really suboptimal for what you're trying to accomplish. For example,

Re: hueComponent not valid for the NSColor

2014-11-01 Thread Stephen J. Butler
It's a color space that only contains a white and alpha component. Hue doesn't make sense in an all white space. It's like if we were talking about a train that only goes between NYC and DC, and you asked "How long does it take for that train to reach London?" You can't ask that question because th

Re: Class in Swift

2014-08-16 Thread Stephen J. Butler
I'm still learning Swift, but extrapolating from what I might do in Python or Ruby... protocol MyProtocol { ... } func myFunction(generator: (MyParameterType) -> MyProtocol) { for ... { let p : MyParameterType = ... if not p special { continue } let obj = generator(p) ... } }

Re: How to convert String.Index to UInt?

2014-08-16 Thread Stephen J. Butler
Try: import Cocoa let s = "hallo\there" let aas = NSMutableAttributedString(string: s, attributes: nil) if let rangeOfTab = s.rangeOfString( "\t" ) { let colour = NSColor.grayColor() let length = distance(s.startIndex, rangeOfTab.startIndex) let aRange = NSRange(location: 0, length:

Re: How do I temporary retain self, under ARC?

2014-07-17 Thread Stephen J. Butler
Do you know this code will always run on the main thread? Because you could fix this from the other side, in the delegate. Use dispatch_async(dispatch_get_main_queue(), ...) to un-assign the property. But this won't work if you're on a non-main thread when you call back into the delegate. On Thu,

Re: NSStrings to CStrings and hex encoding...

2014-06-24 Thread Stephen J. Butler
Those are the UTF-8 sequences for smart quotes. It's not coming from cStringUsingEncoding, but directly from NSTextView: http://stackoverflow.com/questions/19801601/nstextview-with-smart-quotes-disabled-still-replaces-quotes Rant: This has been a super annoying Mavericks feature IMHO. Even when y

Re: string literals and performance

2014-05-24 Thread Stephen J. Butler
You misunderstand the point of the Stackoverflow answer. In the first example you've given it looks like "s" is just a stack local variable. In that case there is no difference between the two examples. Actually, in the face of optimization I bet the assembly turns out exactly the same. Use the lat

Re: NSSharingService with Animated GIFs?

2014-05-16 Thread Stephen J. Butler
On Sat, May 17, 2014 at 12:41 AM, Charles Carver wrote: > NSURL *saveUrl = [NSURL URLWithString:[NSString stringWithFormat:@"file://%@", > NSTemporaryDirectory()]]; > saveUrl = [saveUrl URLByAppendingPathComponent:fileName]; > You shouldn't construct file URLs like this. There has been an approve

Re: How to convert a UTF-8 byte offset into an NSString character offset?

2014-05-05 Thread Stephen J. Butler
What's your next step after doing the UTF8 to UTF16 range conversion? If it's just going to be -[NSString substringWithRange:] then I'd strongly suggest just doing -[NSString initWithBytes:length:encoding:] on the UTF8 string. At least profile it and see what the penalty is. You've already paid the

Re: NSURLSession + Bonjour to do peer-to-peer file transfers?

2013-12-25 Thread Stephen J. Butler
NSURLSession is a fancy HTTP client. It needs to talk to an HTTP server. None of the included iOS and OS X frameworks (that I'm aware of) include an HTTP server. You can either run an HTTP server on the device in your app ( https://www.google.com/search?q=ios+http+server) or you can write your own

Re: _NSWarnForDrawingImageWithNoCurrentContext

2013-12-16 Thread Stephen J. Butler
Did you try the suggestion the warning listed? Breaking on "void _NSWarnForDrawingImageWithNoCurrentContext()"? Because a stack trace for when the error occurs would be helpful. On Sat, Dec 14, 2013 at 6:32 AM, Leonardo wrote: > Hi, when I rotate my NSView, my image disappears for a second from

Re: rangeOfString behaves wierd

2013-12-09 Thread Stephen J. Butler
Would converting each string to NFD (decomposedStringWithCanonicalMapping) be an acceptable work around in this case? On Mon, Dec 9, 2013 at 3:43 AM, Stephen J. Butler wrote: > OK, you are right. Copy+paste didn't preserve the compatibility character. > Does look like a bug of s

Re: rangeOfString behaves wierd

2013-12-09 Thread Stephen J. Butler
OK, you are right. Copy+paste didn't preserve the compatibility character. Does look like a bug of sorts, or at least something a unicode expert should explain. On Mon, Dec 9, 2013 at 3:20 AM, Gerriet M. Denkmann wrote: > > On 9 Dec 2013, at 16:00, Stephen J. Butler > wrote: >

Re: rangeOfString behaves wierd

2013-12-09 Thread Stephen J. Butler
I don't get the same result. 10.9.0, Xcode 5.0.2. I created an empty command line utility, copied the code, and I get NSNotFound. 2013-12-09 02:50:19.822 Test[73850:303] main "见≠見" (3 shorts) occurs in "见=見見" (4 shorts) at {9223372036854775807, 0} On Mon, Dec 9, 2013 at 2:43 AM, Gerriet M. Denk

Re: Download fileSystem data

2013-11-30 Thread Stephen J. Butler
Have you profiled your code to see what calls exactly are taking the most time? I have a feeling it's these: isFilePackageAtPath kLSItemInfoIsInvisible kFSNodeLockedMask kFSCatInfoCreateDate kFSCatInfoContentMod kFSCatInfoBackupDate kFSCatInfoAccessDate And parsing "ls

Re: Sending a message to a Toll free bridge

2013-11-25 Thread Stephen J. Butler
I don't believe that the array that CTFontCopyAvailableTables() returns contains CFTypes. So yes, CFArray is bridgeable. But in this case that isn't so useful since the values aren't. On Mon, Nov 25, 2013 at 3:23 AM, Gerriet M. Denkmann wrote: > The documentation states: "CFArray is “toll-free b

Re: How to fix warning?

2013-08-28 Thread Stephen J. Butler
Are those really always constant? Why not: NSCharacterSet *stopCharacters = [NSCharacterSet characterSetWithCharactersInString:@"< \t\n\r\x85\x0C\u2028\u2029"]; On Wed, Aug 28, 2013 at 3:26 PM, Dave wrote: > Hi, > > I am getting the following warning > > warning: format specifies type 'unsigne

Re: NSValue valueWithBytes:objCType:

2013-08-25 Thread Stephen J. Butler
My guess, and this is only a guess, is that NSValue only uses the type property to make sure two NSValues have the same layout before calling memcmp (or such) on them. We have a lot of evidence that it doesn't do a deep inspection of the type in order to give a more accurate comparison. Can you no

Re: "Ownership follows the 'Create' Rule'" - not literally

2013-08-25 Thread Stephen J. Butler
What they're saying here is that that parameter is following the "Create Rule" even though the function doesn't have a normal name for following the rule. They are documenting an exception to the ownership rule. If the function name did follow the rule it would be redundant to document it as such.

Re: Variable Number of Parameters in Method

2013-08-21 Thread Stephen J. Butler
On Wed, Aug 21, 2013 at 4:22 AM, Dave wrote: > if ([myType isEqualToString:@"NSInteger"] ) > { > myNSInteger = va_arg(myArgumentList,NSInteger*); > // do something with myNSInteger > [myFormattedString appendFormat:@"myNSInteger = %d ", > m

Re: Variable Number of Parameters in Method

2013-08-21 Thread Stephen J. Butler
On Wed, Aug 21, 2013 at 2:35 AM, Dave wrote: > -(void) methodX:(NSString*) theName,… > { > va_list > myArgumentList; > NSInteger > myArgumentCount; > > myArgumentCount = 0; > va_start(myArgumentList,theMethodName); > > while(va_arg(myArgumentList,NSString*) != nil) > // >

Re: -[NSBundle URLForResource:withExtension:subdirectory] is case-sensitive

2013-08-17 Thread Stephen J. Butler
On Sat, Aug 17, 2013 at 6:03 PM, Rick Aurbach wrote: > I expect indexURL to be non-null (and to contain the appropriate URL). > However, in actual devices, this function returns nil; on the IOS Simulator > it returns a valid URL. If I change the resource name to exactly match the > actual file na

Re: pathForResource:ofType: iOS bug?

2013-07-07 Thread Stephen J. Butler
How are you examining the return value? Show us that code too, please. On Sun, Jul 7, 2013 at 7:34 PM, Jeff Smith wrote: > > > Hi, > > > > pathForResource:ofType: is returning a path string with 4 garbage > characters added to the end of the string. > > To make sure it wasn't my program causing

Re: how to run NSApplicationMain() in child process?

2013-05-10 Thread Stephen J. Butler
On Fri, May 10, 2013 at 2:03 PM, Jens Alfke wrote: > #!/bin/sh > open -b com.example.XQIVApp $@ > You probably want this instead to prevent word splitting for elements that have spaces: open -b com.example.XQIVApp "$@" Nothing is ever trivial in sh/bash ;) _

Re: how to run NSApplicationMain() in child process?

2013-05-10 Thread Stephen J. Butler
On Fri, May 10, 2013 at 1:56 AM, Ondrej Holecek wrote: > thanks for the hint, I have to check this first. However at first > glance it seems I have to create 2 applications. Daemon and cmd-line > app. My idea is to have just one app which behaves as a "daemon" in > case the deamon doesn't run yet

Re: how to run NSApplicationMain() in child process?

2013-05-09 Thread Stephen J. Butler
I didn't look at your code, but... one thing to note is that it is absolutely not secure to run your daemon as root and display a GUI. I hope that isn't part of your plan. The OS X way to do this sort of thing is to write your daemon as a Launch Agent (since it needs to interact with a logged in u

Re: Too many threads?

2013-05-08 Thread Stephen J. Butler
If that's a POSIX error code it's reporting, then 35 maps to either EAGAIN or EWOULDBLOCK. I thought it might be you're hitting the max file limit (256 by default) but that would cause open() to return EMFILE. However, pthread_create() can return EAGAIN, and with 2000+ threads you might be hitting

Re: Dynamic library linking

2013-02-24 Thread Stephen J. Butler
This is an advanced topic which touches on a lot of OS X details. The short of it is, even if you solve your linking problems your Python 3.3 library won't work. What you need to is include the entire Python 3.3 framework in your Application bundle. Once you've figured out how to do that, linking

Re: Cocoa | Reading Plist/file version of Native binary

2012-11-26 Thread Stephen J. Butler
Do you mean the app/bundle version? CFBundleGetValueForInfoDictionaryKey() with kCFBundleVersionKey. On Tue, Nov 27, 2012 at 12:41 AM, Sachin Porwal wrote: > Hi, > > I am looking for a way to read file version information of a native > Binary(32/64 bit) in Cocoa. This is required to upgrade a ex

Re: App rejection due to app-sandboxing invalid entitlement

2012-10-29 Thread Stephen J. Butler
On Mon, Oct 29, 2012 at 12:49 PM, Martin Hewitson wrote: > But com.apple.security.scripting-targets is not a temporary entitlement, is > it? I thought this was the recommended way of communicating between apps in > the new era. But this part clearly is: com.apple.security.temporary-exception

Re: Hints for supporting dragging a file onto the dock icon, then onto a row in menu presented at that point?

2012-09-13 Thread Stephen J. Butler
On Thu, Sep 13, 2012 at 2:40 PM, Chris Markle wrote: > I'm pretty new to OS X development and just looking for hints about > how to do something like this... I saw an app called Dragster that > allows you to drag a file over the dock icon for the app, at which > point a menu of rows opens up form

Re: How to Identify a "Phantom" Write Operation

2012-09-05 Thread Stephen J. Butler
On Wed, Sep 5, 2012 at 1:51 PM, douglas welton wrote: > I reconfigured my code to load the cached copy of the user-selected movie > with the QTMovieResolveDataRefsAttribute set to "NO. > > I don't get any new/additional messages sent to the console. In your > experience, is this an indication t

Re: App memory

2012-08-16 Thread Stephen J. Butler
getrusage? On Thu, Aug 16, 2012 at 9:39 AM, Charlie Dickman <3tothe...@comcast.net> wrote: > Is there a system command or any other way to get application memory stats > like vm_stat does for the whole system? > > Charlie Dickman > 3tothe...@comcast.net > > > > > _

Re: Where do these come from...

2012-08-15 Thread Stephen J. Butler
On Wed, Aug 15, 2012 at 10:39 PM, Charlie Dickman <3tothe...@comcast.net> wrote: > I DO NOT call drawRect directly. I DO call [self setNeedsDisplay: YES] to > keep things going. All drawing is done from inside drawRect which has been > invoked through the use of [self setNeedsDisplay: YES], May

Re: Where do these come from...

2012-08-15 Thread Stephen J. Butler
On Wed, Aug 15, 2012 at 10:02 PM, Charlie Dickman <3tothe...@comcast.net> wrote: > Here's the whole method... it is being called from within a view's drawRect > method... Are you calling drawRect directly from your code? If so, don't do that. You should be sending one of the setNeedsDisplay messa

Re: Where do these come from...

2012-08-15 Thread Stephen J. Butler
On Wed, Aug 15, 2012 at 10:20 AM, Charlie Dickman <3tothe...@comcast.net> wrote: > [[NSColor whiteColor] set]; > [die1 drawInRect: iDieDrawRect > fromRect: imageRect1 > operation: NSCompositeSourceOver > fr

Re: Adding login items - who's right? The headers or the guide?

2012-07-29 Thread Stephen J. Butler
On Sun, Jul 29, 2012 at 6:09 PM, João Varela wrote: > I would like to support the new way of adding login items by adopting the > Services Management framework. As I I would like to support Snow Leopard I > was quite pleased when I read that SMLoginItemSetEnabled function was > available on OS X 1

Re: Getting NSApplicationDelegate protocol

2012-07-06 Thread Stephen J. Butler
nd that would explain your problem perfectly. > On Fri, Jul 6, 2012 at 11:14 AM, Stephen J. Butler > wrote: > >> On Fri, Jul 6, 2012 at 3:30 AM, ecir hana wrote: >> > I'm trying to get the methods a protocol specifies and just stumbled upon >> > one pr

Re: Getting NSApplicationDelegate protocol

2012-07-06 Thread Stephen J. Butler
On Fri, Jul 6, 2012 at 3:30 AM, ecir hana wrote: > I'm trying to get the methods a protocol specifies and just stumbled upon > one problem: the following code returns NULL: > > Protocol *protocol = objc_getProtocol("NSApplicationDelegate"); Are you trying this on 10.5? Or are you building thi

Re: How to know if a file has been opened before?

2012-06-05 Thread Stephen J. Butler
On Tue, Jun 5, 2012 at 3:14 AM, Antonio Nunes wrote: > On 5 Jun 2012, at 00:09, Stephen J. Butler wrote: > >> You can use extended attributes to attach information to a file. Maybe >> serialize your session state as a plist and use setxattr/getxattr to >> manipulate it.

Re: How to know if a file has been opened before?

2012-06-04 Thread Stephen J. Butler
You can use extended attributes to attach information to a file. Maybe serialize your session state as a plist and use setxattr/getxattr to manipulate it. Follows the file as it's moved around. PS: it's recommended that names for your attribute following the java style reverse DNS. For example, Ap

Re: Sending a list of path strings to the Finder via Scripting Bridge

2012-05-26 Thread Stephen J. Butler
On Fri, May 25, 2012 at 1:56 AM, Peter wrote: > I'd like to reveal/select multiple items in the Finder. > NSWorkspace only handles single files as in > >            [[NSWorkspace sharedWorkspace] selectFile:currentFilePath >                             inFileViewerRootedAtPath:currentFilePath]; >

Re: In a modal pickle

2012-05-19 Thread Stephen J. Butler
On Sat, May 19, 2012 at 12:04 PM, NUExchange wrote: > I have a core data app that opens two windows when it starts up. One of the > two has a NSSearchField. The cursor is in search field and I can enter and > delete text, but any other operation on either of the windows causes the > screen to f

Re: Dissappearing string

2012-05-16 Thread Stephen J. Butler
On Wed, May 16, 2012 at 12:39 PM, Charlie Dickman <3tothe...@comcast.net> wrote: >        NSString *possibleString = [NSString stringWithFormat: @"%s", > possible]; ... and this line is something you shouldn't do. There are a ton of correct methods to create an NSString from a C string: +stringW

Re: Dissappearing string

2012-05-16 Thread Stephen J. Butler
On Wed, May 16, 2012 at 12:39 PM, Charlie Dickman <3tothe...@comcast.net> wrote: >        possible[strlen(possible)] = '\0'; This can't possibly work. strlen() depends on the string already being \0 terminated. You can't use strlen() to find the position to add a \0. _

Re: First Responder

2012-05-10 Thread Stephen J. Butler
On Thu, May 10, 2012 at 6:24 PM, koko wrote: > I have a menu item connected to an action in First Responder; > > The action exists in an NSView subclass. > > The subclass implements acceptsFirstResonder and return YES. > > The subclass implements validateMenuItem and return YES; > > When the menu

Re: Problem parsing file in 64 bit build.

2012-05-07 Thread Stephen J. Butler
On Mon, May 7, 2012 at 8:06 AM, Charles Srstka wrote: > Myself, I like to just spin off a method or function that takes a chunk of > data and populates the fields of the struct one by one, instead of writing > the data straight onto the struct. A little more code, but you know it’s > going to w

Re: inconsistent behavior of NSString's localizedCaseInsensitiveCompare

2012-05-05 Thread Stephen J. Butler
On Sat, May 5, 2012 at 6:53 PM, Jens Alfke wrote: > > On May 5, 2012, at 3:18 PM, Quincey Morris wrote: > >> "ß" within a string probably compares equal to "ss" at the corresponding >> position, independently of the language. (This makes sense, I think.) >> Therefore "laßt" > "lasso" always. > >

Re: inconsistent behavior of NSString's localizedCaseInsensitiveCompare

2012-05-05 Thread Stephen J. Butler
On Sat, May 5, 2012 at 4:46 PM, Markus Spoettl wrote: > On 05.05.12 23:07, Martin Wierschin wrote: >> >> So, when using a binary search, I get different answers depending on the >> other strings in the list! > > > Seems to work for me: I was using F-Script to investigate this, but I'm seeing the

Re: How do I get the hot spot from a .cur file in objective c on MAC Cocoa?

2012-03-31 Thread Stephen J. Butler
Wikipedia says that cur/ico files have a very simple format: http://en.wikipedia.org/wiki/ICO_(file_format) Part of the ICONDIRENTRY structure is the hotspot information. Should be pretty easy to write a basic parser. On Sun, Mar 25, 2012 at 4:25 AM, Oshrat Fahima wrote: > Hi > In our plug-ins

Re: drawRect using a Category

2012-03-30 Thread Stephen J. Butler
On Fri, Mar 30, 2012 at 10:31 PM, Peter Teeson wrote: > Rather than using a sub-class, which seems overkill to me, > I decided to try a Category instead. So here's what I did (and it seems to > work.) The problem with this approach is that you've replaced the drawRect: for every NSMatrix instanc

Re: [Q] Why is the threading and UI updating designed to be done only on a main thread?

2012-03-13 Thread Stephen J. Butler
On Tue, Mar 13, 2012 at 4:09 PM, JongAm Park wrote: > In other words, the thread function may want to update UI like inserting a > log message to a text field on a window and thus asking main thread to do > so, and main thread is waiting to acquire a lock or waiting using "Join", > then either the

Re: Finding object array index when iterating through array

2012-03-08 Thread Stephen J. Butler
On Tue, Mar 6, 2012 at 8:19 PM, Marco Tabini wrote: >> I have an array and I am iterating through it using this technique: >> >>> for (id object in array) { >>>    // do something with object >>> } >> >> Is there  way to obtain the object's current array index position or do I >> have to add a co

Re: Accessing array in thread safe way

2012-03-06 Thread Stephen J. Butler
On Tue, Mar 6, 2012 at 1:51 PM, Jan E. Schotsman wrote: > 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 multiple threads, using me

Re: initFileURLWithPath run on emulator, not run on device

2012-01-30 Thread Stephen J. Butler
On Mon, Jan 30, 2012 at 9:57 AM, Riccardo Barbetti wrote: > I have a problem, after that I had write and test code on simulator, today I > have work on device. I'm skeptical because... > In my program I save my NSArray: > > >    NSArray *paths = > NSSearchPathForDirectoriesInDomains(NSSharedPu

Re: KVO willChange and didChange

2012-01-15 Thread Stephen J. Butler
On Mon, Jan 16, 2012 at 12:30 AM, Gideon King wrote: > Are there any recommendations on the best approach for being able to have the > setter able to do what it needs with the KVO and then calling other methods, > without breaking bindings? > > I can't believe I have misunderstood this for so lo

Re: Carousel - like control for Mac OS

2011-12-21 Thread Stephen J. Butler
On Tue, Dec 20, 2011 at 3:00 PM, Nick wrote: > Hello > I am wondering, if a component exists similar to this > http://www.ajaxdaddy.com/demo-jquery-carousel.html > for Mac OS. > > Basically, what I need is just "next" and "previous" buttons (and > these images smoothly scrolled one image per "next

Re: Locks

2011-12-06 Thread Stephen J. Butler
On Tue, Dec 6, 2011 at 9:07 PM, koko wrote: > I did come across OSAtomicIncrementXX … thanks. > > I cannot use NSLock as this is in a BSD Static lib and I am required to > implement as close to windows as possible. > > So my code looks like below and is isomorphic to the Windows implementation.

Re: Validating dictionary strings file

2011-11-20 Thread Stephen J. Butler
On Sun, Nov 20, 2011 at 11:33 PM, Gideon King wrote: > Clearly there is some formatting error in the file but it is a rather large > file and would take a very long time to manually go through and find the > issue - is there some tool available that will tell me where to look in the > file for

Re: -dateWithTimeIntervalSinceNow: 64-bits may overflow

2011-10-09 Thread Stephen J. Butler
On Sun, Oct 9, 2011 at 1:51 PM, Jerry Krinock wrote: > > On 2011 Oct 08, at 21:12, Stephen J. Butler wrote: > >> What's wrong with +[NSDate distantFuture]? > > Nothing.  It's only [NSDate -dateWithTimeIntervalSinceNow:FLT_MAX] which > sometimes gives unexpecte

Re: -dateWithTimeIntervalSinceNow: 64-bits may overflow

2011-10-08 Thread Stephen J. Butler
On Sat, Oct 8, 2011 at 11:09 PM, Jerry Krinock wrote: > Don't do this: > >    -[NSDate dateWithTimeIntervalSinceNow:FLT_MAX] ; > > Expected result: A date far off into the future which will always behave as > though it is later than or equal to any other date. What's wrong with +[NSDate distant

Re: Mystery of the missing symbol

2011-10-02 Thread Stephen J. Butler
On Sun, Oct 2, 2011 at 7:50 PM, Graham Cox wrote: > A user is reporting this error logged to the console when trying to load a > plug-in bundle (an iTunes visualizer): > > dlopen(): Symbol not found: __NSConcreteStackBlock >  Referenced from: >  Expected in: /usr/lib/libSystem.B.dylib > > > The p

Re: Task dispatching

2011-09-13 Thread Stephen J. Butler
On Tue, Sep 13, 2011 at 1:36 PM, Scott Ribe wrote: > On Sep 13, 2011, at 12:23 PM, Jens Alfke wrote: >>  The forked process is an exact clone of the original, with its address >> space copy-on-write, so it’s already up and running without any startup time. > > Yeah, but about the only thing you c

Re: Custom universal types, but outside an application

2011-09-08 Thread Stephen J. Butler
On Thu, Sep 8, 2011 at 3:21 PM, wrote: > My problem: this type is not actually defined and used by an > application, but by a preference pane. It seems that putting the proper > entries in the preference pane's Info.plist doesn't work (or am I > missing something ?). What you're missing, I think

Re: Symbol not found when compiling MM (ObjC++) file

2011-08-05 Thread Stephen J. Butler
On Fri, Aug 5, 2011 at 9:57 AM, Alexander Hartner wrote: > Now when I import Logger.h and use it from a Objective C (.m) file everything > seems to work great. However as soon I as import it and use it from a > Objective C++ (.mm) file I get the following link error: > > Ld [REMOVED] normal i386

Re: NSTask vmrun

2011-08-05 Thread Stephen J. Butler
On Fri, Aug 5, 2011 at 10:15 PM, Rainer Standke wrote: > args: ( >    "-T fusion", >    "-gu Administrator", >    "-gp Admin", >    runScriptInGuest, >    "\"/Users/rainer/Documents/Virtual Machines.localized/Windows XP > Professional v1.vmwarevm/Windows XP Professional v1.vmx\"", >    "", >    "

Re: Running Cocoa from a dynamic library

2011-07-28 Thread Stephen J. Butler
On Thu, Jul 28, 2011 at 1:14 PM, Jens Alfke wrote: > On Jul 27, 2011, at 8:02 AM, Guido Sales Calvano wrote: > >> Ogre3D however, uses a cocoa window to render on, and obviously I want user >> input. But if I start ogre in a dynamic library ui events register >> incorrectly. > > It’s not the fact

Re: NSTask oddity with getting stdout

2011-07-24 Thread Stephen J. Butler
On Sun, Jul 24, 2011 at 10:17 PM, Scott Ribe wrote: > I'm using NSTask to run a background process, monitor its output, and > ultimately present a message to the user. All has been fine with this 10.2 > through 10.6, as far as I know. Now under 10.7 I saw a case where my code did > not receive

Re: drawRect not getting called when needed under OS X

2011-07-23 Thread Stephen J. Butler
On Sat, Jul 23, 2011 at 11:33 PM, Tom Jeffries wrote: > When I run the code that displays the graphics in question on initialization > it works fine, but when I call it later in the program it the new graphics > are not displayed.  The code in the graphics module that displays the window > is work

Re: Writing global preferences file into /Library/Preferences (OS X Lion)

2011-07-20 Thread Stephen J. Butler
On Wed, Jul 20, 2011 at 8:31 PM, Peter C wrote: > Some of the programs I wrote save a preference file into /Library/Preferences > via NSDictionary. This serves as a general settings for all users. Many other > 3rd party software (Skype, Microsoft and etc) saves preferences file into > this dire

Re: getting last accessed date

2011-07-08 Thread Stephen J. Butler
t iconForFile: to modify the atime. > On Jul 8, 2011, at 1:52 PM, "Stephen J. Butler" > wrote: > >> On Fri, Jul 8, 2011 at 12:31 AM, Scott Ribe >> wrote: >>> On Jul 7, 2011, at 11:19 PM, Rick C. wrote: >>> >>>> One more note, seems in

Re: getting last accessed date

2011-07-07 Thread Stephen J. Butler
On Fri, Jul 8, 2011 at 12:31 AM, Scott Ribe wrote: > On Jul 7, 2011, at 11:19 PM, Rick C. wrote: > >> One more note, seems in terminal "stat aFile" works so I suppose I could use >> nstask to do this as well? > > It does seem odd that the two would produce different results... They don't, at lea

Re: Why Wasn't Memory Collected?

2011-06-11 Thread Stephen J. Butler
On Sat, Jun 11, 2011 at 1:03 PM, Bing Li wrote: >        NSData *data = [xmlDoc XMLData]; >        NSString *xmlStr = [[[NSString alloc] initWithData:data > encoding:NSUTF8StringEncoding] autorelease]; >        xmlStr = [xmlStr stringByAppendingString:@"\n"]; >        const char *xmlChar = [xmlStr

Re: How can logging a pointer value cause EXC_BAD_ACCESS?

2011-05-29 Thread Stephen J. Butler
On Sun, May 29, 2011 at 1:30 PM, Jerry Krinock wrote: > I'm really losing it; or maybe I never understood to begin with.  How can > this code crash? > >      - (void)dealloc >      { >          NSLog(@"0988 %p %s", self, __PRETTY_FUNCTION__) ; >          NSLog(@"1250 ") ; > CRASH->   int myPointe

Re: What's wrong with this?

2011-05-28 Thread Stephen J. Butler
On Sat, May 28, 2011 at 11:29 PM, Graham Cox wrote: > #import > > @class SGBoard;         //<-- error: Expected '{' before 'class' > > @interface GameViewController : UIViewController > { >        IBOutlet UIView*                mGameView; >        IBOutlet SGBoard*       mBoard; > } > > > -

Re: A Simple NSXML XPath Problem

2011-05-28 Thread Stephen J. Butler
On Sat, May 28, 2011 at 9:40 PM, Bing Li wrote: > The XML is pretty simple. > >     >     >        Orange ST >        RM235 >     > > The following code is use to extract the value of the road, "Orange ST". In > Java, the XPath is the same, i.e., /addresses/road. You're selecting the node which

Re: How to implement "while there are objects in the array - run runloop" idea?

2011-05-26 Thread Stephen J. Butler
On Thu, May 26, 2011 at 1:35 PM, Stephen J. Butler wrote: > You might want to abandon that approach and not add objects from the > background thread directly to the shared array. Instead, you could > "signal" the main thread that a new object is ready to be processed. &g

Re: How to implement "while there are objects in the array - run runloop" idea?

2011-05-26 Thread Stephen J. Butler
On Thu, May 26, 2011 at 1:39 PM, Ken Thomases wrote: > On May 26, 2011, at 1:35 PM, Stephen J. Butler wrote: >> - Use NSNotifications to notify that a new object is waiting to be >> processed. If you go this route, you could actually have multiple >> processing threads

Re: How to implement "while there are objects in the array - run runloop" idea?

2011-05-26 Thread Stephen J. Butler
On Thu, May 26, 2011 at 12:56 PM, Nick wrote: > I have a custom (not main) thread, that adds objects to an NSArray at random > times. > I have an another thread (main thread) that has to retrieve these objects > and do something with them (extract some properties from the retrieved > object and ma

Re: "Use them from only one thread at a time"

2011-05-19 Thread Stephen J. Butler
On Thu, May 19, 2011 at 3:56 PM, Sean McBride wrote: > On Thu, 19 May 2011 13:22:32 -0700, Jerry Krinock said: > >>"Thread-Unsafe Classes.  The following classes and functions are >>generally not thread-safe. In most cases, you can use these classes from >>any thread as long as you use them from o

Re: Read-Write Lock is Available?

2011-05-12 Thread Stephen J. Butler
On Thu, May 12, 2011 at 12:44 PM, Bing Li wrote: > I am writing concurrent code. I get used to the read-write lock on other > development environment. However, according to the Threading Programming > Guide from apple.com, Cocoa does not support the read-write lock? We can use > it with POSIX thre

Re: @selector signature with two colons instead of actual message name

2011-05-03 Thread Stephen J. Butler
On Tue, May 3, 2011 at 8:49 PM, wrote: > - (void)noEmailAlertDidEnd:(NSAlert*) returnCode:(NSInteger)retCode > contextInfo:(void*)ctxInfo { See it now? - (void)noEmailAlertDidEnd:(NSAlert*) returnCode :(NSInteger)retCode contextInfo:(void*)ctxInfo It's using 'returnCode' as the first vari

Re: Xcode 4 auto-importing Objective C categories from static library

2011-04-23 Thread Stephen J. Butler
On Sat, Apr 23, 2011 at 3:36 PM, Bradley S. O'Hearne wrote: > Since transitioning to Xcode 4, I have discovered a very curious shift in the > way Objective C categories are handled in static libraries. In general, if > you create an Objective C category, you have to import that category into an

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: Strange property/synthesized accessor behaviour

2011-04-10 Thread Stephen J. Butler
On Sat, Apr 9, 2011 at 9:52 AM, Philipp Leusmann wrote: > Who can explain this behavior to me? Why is oWidth != object.mWidth ? How can > that happen? It's an artifact of how Objective-C searches for selector implementations. You're calling @selector(width) on an "id", and of course "id" doesn't

Re: Programming Context Menu

2011-04-04 Thread Stephen J. Butler
On Tue, Apr 5, 2011 at 12:10 AM, Chris Hanson wrote: > On Apr 4, 2011, at 12:38 PM, Bing Li wrote: > >>        if (nil == defaultMenu) >>        { >>                @synchronized(self) >>                { >>                        if (nil == defaultMenu) > > Don't do this. I don't mean just in Co

  1   2   3   4   >