Re: Managing navigation in an iOS app
Hi James, I'd suggest that you're probably pushing the idea of decoupling things a bit too far here. View Controllers are inherantly tied to the behaviour of your application, and your user's experience of the flow through it. In 95% of cases, it's absolutely correct for the view controller to know the user pushed this button, therefore I should show them this other view controller. For the 5% of remaining cases where (for example) you have a highly reusable view controller that gets used in many different places in the app, and may push a different child VC depending on its usage location, I'd suggest simply using a delegate to that particular VC to allow you to separate out what gets pushed. Thanks Tom Davie On 21 May 2013, at 20:56, j...@clvr.im wrote: I'd like to get some opinions on handling navigation without having your view controllers modify the navigation stack directly. I'm currently working on an app where I've subclassed UINavigationController, which in turn has custom methods for showing the various views of the app. Each of my app's view controllers has no sense of the other pieces of the app, and do not push directly on the navigation controller. I'm thinking this a much better method since it decouples view controllers from each other and allows the flow of the app to be updated more easily. I'm using a lot of NSNotifications to signal commands to the navigation controller, and it's getting a bit messy. I love the idea of a centralized, decoupled navigation controller, but I haven't seen any good examples of this yet. I would love to get some feedback as to if this is a good idea in the first place, or techniques you've implemented to handle this sort of thing. Cheers, James ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Creating More Than 1 Of The Same Element/control
On 18 May 2013, at 03:21, Harmony Neil harmony.n...@gmail.com wrote: Hellow, I've been working through a couple of tutorials and managed to make a text field and things just fine. The thing I'm wondering is how do I go about naming the textField what I want to call it, like textField1 or for example rather than just textField? Also, how do I make more than 1 textField? I would just use the same code as for the first one and change the y co-ordinate, but then I would still want to call them all something other than textField. I'm using the objective c language and hate using the storyboard and interface builder. If I'm going to code something, I'll write the code by hand. I tried posting on the objc language list, but the only person who replied seemed to think it was too beginner level and that I was posting on the wrong list. If no one on here can help me rather than insist on suggesting stupid books, I don't really know where else to ask, since I'm not getting a lot of luck on google's search results. Thanks, Harmony. Hi Harmony, I'd really very strongly suggest that you just use Interface Builder. Your user interface is essentially data, not code. I doubt (and hope) very much that you don't write code to fill up a buffer with image data at runtime, rather than storing images in data files. The same logic applies to your UI – store your archived objects in a nib file, and use IB to edit them. Thanks Tom Davie ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSMutableDictionary or Custom Object when adding properties?
Alternatively, a dictionary mapping keys onto blocks of type (void(^)(void)), which each compute their result. That, combined with typedef void(^voidBlock)(void); voidBlock constant(id r) { return [^{return r;} copy]; } would give you a dictionary that can store both constants and computed values. Bob On 17 May 2013, at 12:07, Sandor Szatmari admin.szatmari@gmail.com wrote: If you go the dictionary route a simple category on NSDictionary would allow you to compute dynamic properties such as area = length * width. Sandor Szatmari On May 17, 2013, at 1:43, Trygve Inda cocoa...@xericdesign.com wrote: I need to keep a small (few thousand) record database of sorts. Each record has some pre-detertermined fields, but the user can add there own fields to to a limited extent. It is a pretty light use so CoreData isn't what I really want, plus migrating to future structures is an issue with CoreData. This will be simple objects in an NSMutableArray. I can use an array of NSMutableDictionaries or perhaps an array of class-based custom cocoa objects. One nice thing about the object route is that I can have some fields (properties) be based on a calculation rather than real storage like they'd be in an NSMutableDictionary. E.g. NSNumber length NSNumber width NSNumber area In an object area could be a method returning length*width instead of an instance var for area. The trouble comes in the fact that I need to be able to add properties at runtime. For the dictionary option, it is easy - just make sure the key names don't collide and I can add more keys to each dictionary. But for the objects I don't see a nice way to do this There is setValue:forUndefinedKey: and then each object could keep a local dictionary of these defined at runtime keys. Thoughts on this? ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com This email sent to admin.szatmari@gmail.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: https://lists.apple.com/mailman/options/cocoa-dev/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Core Graphics optimisation
On 10 Aug 2012, at 09:09, Fulbert Boussaton 4...@flubb.net wrote: Hi everyone, on iOS, I was using the following immediate CG code to display hundreds procedural sprites : I'd suggest simply dropping CG, and drawing them using OpenGL ES instead. Thanks Tom Davie ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: When does NSInputStream's -getBuffer:length: actually work?
On 25 Jul 2012, at 18:08, Jens Alfke wrote: NSInputStream has a -getBuffer:length: method that lets you get the available data from the stream without copying. This is great for performance, and I've written my client code to take advantage of it if it's supported, but every time I've tested, it isn't supported (i.e. just returns NO) so my code just falls back to calling -read:maxLength: instead. Does anyone know in what circumstances, or in what types of streams, this method actually works? I don't know for sure, but I would bet it's streams reading from files, which have become memory mapped. Bob ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Parser Support
On 18 Jun 2012, at 08:22, Appa Rao Mulpuri wrote: Hi List, Do we have any parser to parse a file with the following entries? ID String ID Actual String 1=STRINGLITERAL_ID_1=String 1 some Blah 2=STRINGLITERAL_ID_2=String 2 3=STRINGLITERAL_ID_3=String 3 .. .. Basically I need to construct two dictionaries from that file. One with 'ID' vs 'Actual String' as Key-Value pairs and second one with 'String ID' Vs 'Actual String' as Key-Value pairs. Core parse will trivially create one for you: https://github.com/beelsebob/CoreParse Bob ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Demo Version
On 15 Jun 2012, at 01:06, Preston Sumner wrote: On Jun 14, 2012, at 11:41 AM, Richard Somers wrote: The Mac App Store guidelines indicates that Apps that are beta, demo, trial, or test versions will be rejected. So if potential customers need to go to my website to download a demo version then I might as well offer the retail version for sale on my website also. Why use the Mac App Store? Of note, while all these are banned, apple seem entirely okay with lite versions. The key is basically that the lite version must still function as an app on its own... just not quite as complete a one as the full version. This as opposed to a demo app which is likely to stop working as an app on its own. Thanks Tom Davie ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Dumb Q about console I/O under ObjC
On 27 May 2012, at 18:26, William Squires wrote: I'm trying to develop my retro CRPG game engine as a console app, but how do I test the input part? I can output to stdio with either printf() or NSLog, but the debug console only supports output, not input. What's the normal way to redirect this to terminal.app so that scanf() will work? Since when does the debugger console only support output? Bob ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSMutableData capacity
On 24 May 2012, at 06:02, Jason Teagle wrote: +dataWithCapacity:some_capacity The docs note that this doesn't necessarily pre-allocate the given capacity. Which is exactly why I said, in the very same sentence, to guarantee it has the capacity (but not necessarily allocated yet). I'm not sure what you're hoping to achieve from this. NSMutableData's capacity is not a hard and fast upper limit to how much data can be put in there; it's just a hint to the API for roughly how much space should be found for the data. Bob ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Multiple Inheritance
Implement abstract classes that implement the methods, then use the runtime to copy the methods into the classes that should have them in +initialize. Bob On 24 May 2012, at 10:14, Gerriet M. Denkmann wrote: I have an abstract class M with subclasses MAB, MAX, MXB. There are several lengthy methods A which are used in MAB and MAX, and others methods B which are used in MAB and MXB. Methods A use a property NSUInteger index. Class MXB has no such property, is has NSIndexSet *indices instead. Similar for methods B. Currently these common methods are present in both classes. But: this is less than perfect - meaning that each change has to be done twice. What to do? Have a file methodsA.m which is included in both MAB and MAX (and same for methodsB.m) ? Other, better solutions? Kind regards, Gerriet. ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Drawing unicode glpyhs
Hi all, I'm having an issue with drawing text via CGContextShowGlyphs, whereby it doesn't draw cyrilic (and presumably a variety of other exciting) characters. The code at https://github.com/beelsebob/OpenStreetPad/blob/master/OpenStreetPad/OSPMetaTileView.m#L710 (which goes via CTLineDraw) successfully renders all characters, correctly. Meanwhile, the code at https://github.com/beelsebob/OpenStreetPad/blob/master/OpenStreetPad/OSPMetaTileView.m#L797 (which use CGContextShowGlyphs to draw the glyphs on a path) does not draw them correctly (instead outputting Helvetica-Light: FT_Load_Glyph failed: error 6). It appears that this text path doesn't deal with font fallbacks correctly; the docs for CTLineDraw though say that it's just an alias for repeatedly calling CGContextShowGlyphs. Anyone got any ideas what I could have ballsed up? Thanks Tom Davie if (*ra4 != 0xffc78948) { return false; } ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: WWDC
Do you have a bug number that I could reference? I'd probably like to file one asking them to do *several* WWDCs around the world – the cost to people in the bay area is already pretty high ($1.6k ish per attendee), but to someone in the UK, the cost is more like $4k per attendee. Plus of course doing several would kill the second stone of having more spaces available! Bob if (*ra4 != 0xffc78948) { return false; } On 25 Apr 2012, at 18:45, Rob Ross wrote: I filed a bug report under other asking them to increase the numbers of attendees at future WWDC. They should be able to do it, if they want to. Java One regularly had 15,000 in its heyday, at the exact same Moscone Center venue. On Wednesday, April 25, 2012, Nathan Sims newsli...@autonomy.caltech.edu wrote: The WWDC 2012 announcement email was dated April 25, 2012 7:04:42 AM PDT. *No one* I know of was able to obtain a ticket. Maybe they need a raffle or some such? On Apr 25, 2012, at 10:19 AM, Rick Mann wrote: Is WWDC really sold out already? I just got the notification email... -- Rick ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/rob.ross%40gmail.com This email sent to rob.r...@gmail.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: https://lists.apple.com/mailman/options/cocoa-dev/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: @-directives
Not that I know of off the top of my head, but here's my attempt at such a list: @class @interface @implementation @end @private @public @protected @protocol @required @optional @property @synthesize @try @catch @finally @autoreleasepool @synchronized Have I missed your favourite out? Bob if (*ra4 != 0xffc78948) { return false; } On 8 Mar 2012, at 21:12, H. Miersch wrote: hi. is there a list of @-directives (like @class, @property and @synthesize) somewhere out there? ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
[ANN] CoreParse (Version n+1)
Hi All, A while ago I showed you all my parsing library 'CoreParse', and got some really useful feedback. Today, I'd like to show you what's changed since then! • Easier processing of syntax trees into your data structures. In earlier versions of CoreParse you had to use a parser delegate to construct your data structures from the result of parsing expressions. Not so in the new version! Instead, Simply implement the CPParseResult protocol, and CoreParse will call -initWithSyntaxTree: when it finds something of that class. • Archiving and Unarchiving of parsers and tokenisers. Construction of large parsers can be quite slow and memory consuming, because of that you don't always want to do it at run time. The new version of CoreParse implements NSCoding for both parsers and tokenisers, allowing you to quickly load them without creating them on the fly. • Error handling and recovery. Previous versions of CoreParse simply bailed out when they found something that couldn't be tokenised or parsed. The new version adds support for several delegate callbacks allowing you to specify how the parser should deal with the situation: -tokeniser:didNotFindTokenOnInput:position:error: Allows you to advance the token position to skip unrecognised input, and to insert error tokens into the token stream. -parser:didEncounterErrorOnInput:expecting: Allows you to specify a recovery action for the parser to take (choose from deleting the token, inserting a dummy token, falling back to the previous item in the parse stack, or fail immediately), and do your own error reporting/handling. CoreParse has now been used in a couple of significant projects and proven to be stable and reliable: • I have used it to parse MapCSS in OpenStreetPad (https://github.com/beelsebob/OpenStreetPad). • Matt Mower has used it in his StateC state machine library (https://github.com/mmower/statec). He has contributed significant feedback to make sure that the error handling is as robust as possible and provides as much information as it can for you to accurately report errors. Thanks Tom Davie if (*ra4 != 0xffc78948) { return false; } ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [ANN] CoreParse (Version n+1)
I'm pretty sure I did this the first time I announced CoreParse too . Thanks for the suggestion Uli: https://github.com/beelsebob/CoreParse Tom Davie if (*ra4 != 0xffc78948) { return false; } On 5 Mar 2012, at 13:45, Uli Kusterer wrote: On 05.03.2012, at 12:09, Thomas Davie wrote: A while ago I showed you all my parsing library 'CoreParse', and got some really useful feedback. Today, I'd like to show you what's changed since then! You have a link to CoreParse? :-) Cheers, -- Uli Kusterer The Witnesses of TeachText are everywhere... ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [Obj-C] if (self) vs. if (self != nil)
To me, it breaks one of my golden rules, and exposes one of the things I dislike about C. Expressions, at least in my mind, should not involve state change – that's what statements are for. My rationale behind this is that it makes it easier to read expressions – you get one more guarantee about what they're doing – they're computing a value, not changing some state behind your back. This has a few implications for how I write code: • I don't use the increment/decrement operators in expressions. • I don't use the result value of assignments within expressions. • Functions I try to keep as much as possible mathematical functions – they don't change state, they just return the result of a computation. • If I need to return something from a subroutine that does change state, I tend to use a pointer argument rather than the result. More specifically • I don't use assignments in an if's condition, as below. Bob if (*ra4 != 0xffc78948) { return false; } On 25 Feb 2012, at 01:12, Wade Tregaskis wrote: if(nil != (self = [super init])) Myself I find it elegantly brief and imminently readable. I don't mind it, but to me it begs the question of what it offers over: self = [super init]; if (self) { My rationale is, generally you avoid assignments within conditionals because it's just plain awkward. The if (self = [super init]) pattern is a rare exception, that is justified purely by convention at this point. If you're going to break that convention, and increase the verbosity to boot, you should probably just revert to fundamentals - i.e. treat it like any other assignment and test. ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [Obj-C] if (self) vs. if (self != nil)
Neither is more correct. The main distinction is whether you are happy with C's (very weak) type system or not. If you are satisfied that if simply checks if some integer typed value is equal to 0 or not, and uses the first branch if it isn't, then the former is more concise and better for you. If you on the other hand like to hold a stronger type system than C's in your head, and like to think of if statements as things that accept boolean arguments, and execute the first branch if the boolean is true, then clearly if (self) is an in head type error - you need to compare against nil to get a boolean out. Hope that clarifies things. Bob if (*ra4 != 0xffc78948) { return false; } On 24 Feb 2012, at 14:50, Oleg Krupnov wrote: An interesting question. The following samples are equivalent in terms of compiled code, but which one is more correct from the language's point of view? self = [super init]; if (self) { } return self; self = [super init]; if (self != nil) { } return self; The Xcode samples promote the first variant, but I'm wondering if the second one is more correct? The nil is defined as follows (jumped to definition) #define nil NULL #define NULL ((void*)0) So basically, nil is of type void*, so the expression self != nil compares two pointers and the result is boolean, which is perfect for testing in the if statement. But the self alone is of type pointer and so when it is tested by the if statement, it's implicitly cast to the type boolean. I also heard that generally speaking NULL is not necessarily always equal to 0 on all architectures. Thoughts? ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to parse multipart/form-data?
CoreParse! https://github.com/beelsebob/CoreParse I hope that helps :) Thanks Tom Davie if (*ra4 != 0xffc78948) { return false; } On 28 Jan 2012, at 06:29, Kai Cao wrote: Hi, I'm using CocoaHTTPServer to upload files from computer to iOS devices. But the result NSData received from the browser is multipart form data, which is really hard to parse manually. I know I can write a parser from scratch, however, it's time consuming and bug prone. I'm wondering wether there's a sophisticated library/framework for this. Any help would be appreciated. Thanks in advance. Best regards, Kai nonamel...@me.com sent from Mobile Me ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSXMLParser, streams, multiple threads, and crashing
Hi all, I'm having a bit of a bizarre issue with a pair of NSXMLParsers reading out of streams, where my main thread crashes while signalling a stream. Every crash occurs in the main thread, with this back trace: #00x0175d0b0 in objc_msgSend () #10x0133fb4d in _outputStreamCallbackFunc () #20x0130f06d in _signalEventSync () #30x0130efe6 in _cfstream_shared_signalEventSync () #40x0134297f in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ () #50x012a5c39 in __CFRunLoopDoSources0 () #60x012a5454 in __CFRunLoopRun () #70x012a4db4 in CFRunLoopRunSpecific () #80x012a4ccb in CFRunLoopRunInMode () #90x01832879 in GSEventRunModal () #10 0x0183293e in GSEventRun () #11 0x003b4a9b in UIApplicationMain () #12 0x2cd8 in main at /Users/tatd2/Documents/Personal/OpenStreetPad/OpenStreetPad/main.m:17 As you can see, none of that is in my code (beyond main), so I have a real problem debugging what's going on here. What I have noticed is that every time this crash occurs, another thread is currently reading from a stream with this back trace: #00x92a08c22 in mach_msg_trap () #10x92a081f6 in mach_msg () #20x0134213a in __CFRunLoopServiceMachPort () #30x012a5605 in __CFRunLoopRun () #40x012a4db4 in CFRunLoopRunSpecific () #50x012a4ccb in CFRunLoopRunInMode () #60x01349609 in boundPairRead () #70x012ab744 in CFReadStreamRead () #80x0133f69f in -[__NSCFInputStream read:maxLength:] () #90x00d82da6 in -[NSXMLParser parseFromStream] () #10 0x00d82e2a in -[NSXMLParser parse] () #11 0xea99 in __34-[OSPMapServer popConnectionQueue]_block_invoke_0 () #12 0x01e43445 in _dispatch_call_block_and_release () #13 0x01e44c7b in _dispatch_async_f_redirect_invoke () #14 0x01e444e6 in _dispatch_worker_thread2 () #15 0x98a83b24 in _pthread_wqthread () #16 0x98a856fe in start_wqthread () As you can see, up to OSPMapServerMaxSimultaneousConnections operations are dispatched at once to parse the output of an NSURLConnection, notably, if that constant is set to 1, the crash no longer occurs. - (void)popConnectionQueue { @synchronized(self) { while ([[self currentConnections] count] OSPMapServerMaxSimultaneousConnections [[self connectionQueue] count] 0) { OSPConnection *rec = [[self connectionQueue] objectAtIndex:0]; [[self connectionQueue] removeObjectAtIndex:0]; [[self currentConnections] addObject:rec]; [rec setConnection:[NSURLConnection connectionWithRequest:[rec request] delegate:rec]]; [[rec connection] start]; CFReadStreamRef readStream; CFWriteStreamRef writeStream; CFStreamCreateBoundPair(NULL, readStream, writeStream, 4096); NSInputStream *iStream = CFBridgingRelease(readStream); NSOutputStream *oStream = CFBridgingRelease(writeStream); [oStream setDelegate:rec]; NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; [iStream scheduleInRunLoop:runLoop forMode:NSDefaultRunLoopMode]; [oStream scheduleInRunLoop:runLoop forMode:NSDefaultRunLoopMode]; [iStream open]; [oStream open]; [rec setParserStream:oStream]; NSXMLParser *parser = [[NSXMLParser alloc] initWithStream:iStream]; [parser setDelegate:rec]; [rec setParser:parser]; dispatch_async(parserQueue, ^() { [parser parse]; }); } } } I'm currently stuck even for ways to approach debugging this problem, if anyone has any ideas how I could tackle this, I'd really apreciate it. If you'd like to take a look at the full source and/or experience the crash for yourself, the full source is at github.com/beelsebob/OpenStreetPad Thanks all Tom Davie if (*ra4 != 0xffc78948) { return false; } ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSXMLParser, streams, multiple threads, and crashing
Thanks Andreas, I am indeed using ARC, so the code should be safe enough, as ARC will retain rec for me. Cheers for taking a look though Tom Davie if (*ra4 != 0xffc78948) { return false; } On 22 Jan 2012, at 13:35, Andreas Grosam wrote: On Jan 22, 2012, at 2:15 PM, Thomas Davie wrote: OSPConnection *rec = [[self connectionQueue] objectAtIndex:0]; [[self connectionQueue] removeObjectAtIndex:0]; [[self currentConnections] addObject:rec]; Not sure if this is related to your issue, but basically, the lines above are potentially dangerous. You should mention which memory management model you are using: GC, ARC or manual. Writing it the way below should be safe in all cases and doesn't hurt at all otherwise: OSPConnection *rec = [[self connectionQueue] objectAtIndex:0]; [[self currentConnections] addObject:rec]; [[self connectionQueue] removeObjectAtIndex:0]; Andreas ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSXMLParser, streams, multiple threads, and crashing
On 22 Jan 2012, at 18:45, Jens Alfke wrote: On Jan 22, 2012, at 5:15 AM, Thomas Davie wrote: As you can see, none of that is in my code (beyond main), so I have a real problem debugging what's going on here. Cocoa debugging tip: A crash in objc_msgsend almost always implies a dangling reference to a deallocated object. Usually the dead object is being messaged directly, or sometimes a still-active instance method has accessed one of its instance variables that got overwritten with garbage. The best response is to go into the scheme editor and turn on zombies and scribbling. Zombies will give you much more detailed information if a dead object is messaged, and scribbling will immediately overwrite freed memory with a 0x55 pattern that’s easily detectable in crashes (if the crash is trying to read memory from address 0x, you can be pretty sure why.) Thanks Jens, I received the same advice from #iphonedev on freenode earlier today, and eventually tracked it down to an object being deallocated that was still pointed at as a delegate. Cheers for your help :) if (*ra4 != 0xffc78948) { return false; } ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Calling a Cocoa library from C
On 12 Nov 2011, at 18:45, Nathan Sims wrote: On Nov 11, 2011, at 6:22 PM, Wim Lewis wrote: int get_float_data(float *result1, float *result2) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; @try { [objcCode call]; *result1 = [more stuff]; etc.; } @catch { fprintf(stderr, omg doomed!\n); etc.; } @finally { [pool drain]; } return blahblah; } Wow, I didn't realize how integrated C and Objc are, that you could employ Objc code from a C function. Kewl. Strictly speaking, this is an objective-c function. But, Objective-C is a superset of C – this means that all valid C programs are valid objective-c programs with the same meaning. In this case, the C function definition syntax has the same meaning when you're writing objective-c, only now we can make objective-c calls, and use objective-c exception catching because we're writing objective-c. As someone else mentioned, this should now be written with the @autoreleasepool directive. Okay, does this mean that an object instantiated by a C function has persistence across C function calls? In the example above you have: [objcCode call]; I'm guessing I would have to have: ObjcCode *objcCode; declared globally in the library, and that would suffice? Declared somewhere certainly – I would highly recommend against it being a global though for all the usual reasons to avoid globals. Tom Davie___ 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: Calling a Cocoa library from C
Note that of course you can take this one step further and use a typedef to mask that you're passing back an untyped pointer: typedef OCObjcCodeRef void * OCObjcCodeRef OCCreateObjcCode(void) { return (ObjcCodeRef)[[ObjcCode alloc] init] } int OCGetFloatData(OCObjcCodeRef objcCodeRef, float *result1, float *result2) { ObjcCode *obj = (ObjcCode *)objcCodeRef; @autoreleasepool { *result1 = [obj doSomeStuff]; *result2 = [obj doSomethingElse]; return [obj doMagic]; } } void OCReleaseObjcCode(OCObjcCodeRef o) { [(ObjcCode *)o release]; } Which gets you roughly to the toll free bridging abstraction. Tom Davie if (*ra4 != 0xffc78948) { return false; } On 12 Nov 2011, at 22:48, Greg Guerin wrote: Nathan Sims wrote: Hmm, if not a global, where would the declaration go? The C function certainly shouldn't return it, so if it is to remain persistent across calls, wouldn't the logical (the only?) place for it be as a global in the library's .m file? Why shouldn't the C function return it? As far as C is concerned, an object pointer is just an opaque pointer. Handle it like any other opaque pointer. Example: void * setup_data() { return (void *) [[ObjcCode alloc]init]; } int get_float_data( void * ptrFrom_setup_data, float *result1, float *result2) { ObjcCode *obj = (ObjcCode *) ptrFrom_setup_data; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [obj call]; *result1 = [more stuff]; etc.; [pool drain]; return 0; } void quit_data( void * ptrFrom_setup_data ) { [(ObjcCode *)ptrFrom_setup_data release]; } -- GG ___ 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/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: C struct and __unsafe_unretained
Yes and no – it means you have an NSString there that can disappear at any moment without warning, and when it does, you'll still have a pointer into garbage memory. Also, if the original code has been copying/retaining it into the struct and releasing it out, then it's entirely possible that by doing this you very much *are* changing something. Personally I would take this as a prompt to move to using a class and a (copy) property. Bob if (*ra4 != 0xffc78948) { return false; } On 30 Oct 2011, at 18:40, James Merkel wrote: Ok thanks. Not changing anything is the easiest and safest approach. Jim Merkel On Oct 30, 2011, at 10:52 AM, Dave Zarzycki wrote: ___ 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
Animating a UITableViewCell changing size
Dear list, I'm trying to construct a UITableViewCell with what is essentially a disclosure triangle on it. When that's tapped, the cell expands to show additional information. I currently hack this with code along these lines: NSArray *cellPaths = [tableView indexPathsForVisibleRows]; [UIView animateWithDuration:0.3 animations:^ () { MyCustomCell *cell = [tableView cellForRowAtIndexPath:indexPath]; NSUInteger minRow = [indexPath row]; BOOL d = ![cell disclosed]; [cell setDisclosed:d]; [disclosures setObject:[NSNumber numberWithBool:d] forKey:[cell statName]]; for (NSIndexPath *p in cellPaths) { if ([p row] minRow) { MyCustomCell *c = [tableView cellForRowAtIndexPath:p] [c setFrame:CGRectMake([c frame].origin.x, d ? [c frame].origin.y + kDisclosureOffset : [c frame].origin.y - kDisclosureOffset, [c frame].size.width, [c frame].size.height)]; } } } completion:^ (BOOL finished) { [tableView reloadRowsAtIndexPaths:cellPaths withRowAnimation:UITableViewRowAnimationNone]; }]; This for the most part works well except for one case – collapsing the cells. When this happens, the table view does not have cells for the rows that are not yet visible, but become visible as the cell collapses. Because of this, a blank area comes into view at the bottom of the table view, and then flashes as it gets replaced by the newly generated rows. I've tried using cellForRowAtIndexPath: to grab the cells off the bottom, but these come back as nil, as the table view doesn't think it needs to show them. The only other thing I can conjor in my mind is to call something similar to the data source method directly to construct cells myself, add them to the TV, animate them in, remove them and reload the table view. However, this does not solve one final issue – what happens when the table view is scrolled near to the bottom and there are no cells to add. If anyone could recommend a good way forward here, I'd be appreciative. Thanks Tom Davie ___ 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: adding something to a setter
I don't know of any better way than simply writing the setters yourself. One thing I'd love to see apple add to the language is allowing us to specify a code block to be included in setter and getting in the synthesize: @property (readwrite, retain, nonatomic) NSString *theValue; @synthesize (setCode={ [self setNeedsDisplay:YES]; }, getCode={ NSLog(@It's being set); }); would be lovely if it desugared to this in the implementation: { NSString *theValue; } - (NSString *)theValue { { NSLog(@It's being set); } return [[theValue retain] autorelease]; } - (void)setTheValue:(NSString *)newTheValue { if (theValue != newTheValue) { [theValue release]; theValue = [newTheValue retain]; { [self setNeedsDisplay:YES]; } } } Does anyone have any comments on why that might not work, before I file a bug report to request it? Bob if (*ra4 != 0xffc78948) { return false; } On 6 Oct 2011, at 12:28, Torsten Curdt wrote: The property syntax is great until you need one more thing. Think of a NSView and that view displays a value. @synthesize value; Now you also want to setNeedsDisplay: when a new value is set. So one can override the setter. - (void)setValue:(NSString*)theValue { ... [self setNeedsDisplay:YES]; } but - you would have to implement the setter yourself. No big deal - but... it sucks. Is there a way to forward the setting to the originally synthesized setter? Super cannot be it. Of course one could add another selector that to the interface - (void) setValueAndUpdateDisplay:(NSString*)theValue { self.value = theValue; [self setNeedsDisplay:YES]; } ...but that sucks, too. There gotta be a better way! How do you deal with this? cheers, Torsten ___ 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/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: adding something to a setter
On 6 Oct 2011, at 13:36, Mike Abdullah wrote: On 6 Oct 2011, at 13:09, Thomas Davie wrote: Does anyone have any comments on why that might not work, before I file a bug report to request it? Well it would become rather unreadable for anything more than a single line of code. I'm not sure it would be any less readable than code involving blocks tbh. What's wrong with: @synthesize ( setCode = { [a b]; [c d:e f:g]; [h i]; }, getCode = { ... }) Bob if (*ra4 != 0xffc78948) { return false; }___ 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: adding something to a setter
On 6 Oct 2011, at 14:16, Torsten Curdt wrote: Hm... using KVO for an object to observe it's own properties? That's feels wrong to me. Is that just me? No, definitely not just you... But then, I find KVO pretty wrong in the first place. if (*ra4 != 0xffc78948) { return false; } ___ 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: How to blink with a focus ring of the text box?
The correct way to notify a user that he can't enter text in a text box is to disabled it. Bob if (*ra4 != 0xffc78948) { return false; } On 6 Oct 2011, at 16:33, Nick wrote: Hello I am wondering if there's a way to do this, notifying the user that he can't enter any more text into NSTextField edit box? Is there a way to change the color of the NSTextField's focus ring to red (to highlight that this is an error)? How difficult would that be to implement? Thank you! ___ 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/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: creating multiple NSTimers
On 30 Sep 2011, at 08:19, Conrad Shultz wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 9/29/11 10:50 PM, Greg Guerin wrote: Gordon Apple wrote: There must already be an array for the table, so just iterate the array every minute or whatever (single repeating timer), compare the times to [NSDate date} and start or shut down whatever has not been started or shut down. Much easier than trying to manage timers. You don't have to iterate the whole array, either. Sort it by ascending order of turn-off time. Keep a current position (index). If the time of day is less than the turn-off time of the device at the current position, do nothing. If time of day = turn-off time of current position, then turn it off and advance position until time of day is again less than the turn-off time of device at the current position. Only needs one timer, and scales to as large an array as you want to keep. I don't really see how this is superior to keeping the one timer per remote box. When the user updates a timer, one is forced to re-sort the array and reposition the index (under the above implementation). Why would you need to resort? Just remove, and reinsert. One would also have to implement the scheme carefully, particularly if the shut-off code is offloaded onto separate threads, to avoid potential race conditions arising from a user changing a fire date in the middle of a shut-off sequence. Careful locking required in multithreaded environment – unsurprising. And as Graham mentioned, polling is probably less CPU and power efficient than using timers anyway. Who's suggesting polling - you simply have one timer set for the time at which the first of your actual timers goes off. When it goes off, you fire the first of your actual timers, and reschedule your when do other timers go off timer. Am I missing something conceptually here? Why are people pushing for the single timer model? Is there some hidden complexity in a multi-timer approach that I'm not seeing? I implemented the single timer model yesterday, but I have to admit, the reason was because I'm targeting GNUstep, and when I stared at their source I discovered that they simply itterate through *all* timers every run loop iteration checking if they've gone off, their code also starts NSLogging warnings if you have more than 1000 timers. I have no idea if apple's solution is better than GNUstep's, but if it isn't, the single timer approach would be vastly beneficial. Tom Davie___ 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: Cleaning up a window with blocks
A quick scan over the code says that your issue is that you're referring to theObserver inside theObserver, which, when the block is constructed, as not yet been assigned the result of addObserverForName:... Bob if (*ra4 != 0xffc78948) { return false; } On 29 Sep 2011, at 17:37, Eric Gorr wrote: The intent of the following code is to implement a quick and easy way to bring up a window and provide a way to clean up after it closes. The problem is that it is crashing. I believe I am missing something obvious here and was hoping that someone could remove the blinders... - (void) displayWindow { NSURL* documentURL; NSWindowController* controller; id theObserver; documentURL = [[NSBundle mainBundle] URLForResource:@document withExtension:@rtf]; controller = [[NSWindowController alloc] initWithWindowNibName:@DocDisplay]; theObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSWindowWillCloseNotification object:[controller window] queue:nil usingBlock:^(NSNotification *note) { [[NSNotificationCenter defaultCenter] removeObserver:theObserver]; [[controller window] orderOut:self]; [controller autorelease]; }]; NSArray*subviews= [[[controller window] contentView] subviews]; NSScrollView* scrollView = [subviews objectAtIndex:0]; NSTextView* rtfView = [scrollView documentView]; [rtfView readRTFDFromFile:[documentURL path]]; [[controller window] setTitle:@TheTitle]; [[controller window] makeKeyAndOrderFront:self]; } Here's the relevant part of the crash log: 0 libobjc.A.dylib objc_msgSend_vtable13 + 13 1 libobjc.A.dylib objc_retain + 19 2 libsystem_blocks.dylib_Block_object_assign + 336 3 com.company.app __copy_helper_block_ + 67 4 libsystem_blocks.dylib_Block_copy_internal + 203 5 com.apple.CoreFoundation -[NSBlock copy] + 39 6 com.apple.Foundation +[__NSObserver observerWithCenter:queue:name:object:block:] + 211 7 com.apple.Foundation -[NSNotificationCenter addObserverForName:object:queue:usingBlock:] + 134 8 com.company.app -[TMBrowserAppDelegate displayWindow:] + 494 ___ 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/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: nonatomic vs atomic assign/retain
There are two schools of thought on atomic/nonatomic, and both apply equally to Mac/iOS: 1) Atomicity provides a little bit of safety, and shouldn't be shrugged off for no reason. Because of that, only optimise the atomic set/get when you've actually profiled and determined it's a problem. 2) When multithreading you rarely if ever actually want atomicity at the property level, instead you want somewhat larger critical sections in general. Because of that, atomic setters/getters are pointless cruft and everything should be made monatomic. Chose which camp you live in. Tom Davie if (*ra4 != 0xffc78948) { return false; } On 6 Sep 2011, at 16:30, Torsten Curdt wrote: On iOS properties are usually (unless required otherwise) defined as nonatomic @property (nonatomic, assign) On the Mac I have seen quite often just an assign or retain which AFAIK defaults to atomic @property (assign) So what should one use e.g. for normal IBOutlets with AppKit? I would think nonatomic should be good enough on Mac, too. No? cheers, Torsten ___ 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/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: Overwhelming Options
Can I ask what your app is? I find it hard to believe that your user really needs to set 42 boolean flags. There must surely a better way to think about the configuration. Tom Davie if (*ra4 != 0xffc78948) { return false; } On 1 Sep 2011, at 17:36, Jeremy Matthews wrote: I have an app with some groups of checkboxes...and it really takes up too much space in the UI. It is a utility app, but it has about 7 different matricies of about 6 checkboxes eachso lots of options...and it can be overwhelming at times. I'd like to design a better UI so as to not take up so much space in the UI, and at the same time, make it appear a bit simpler, and hide categories (of checkboxes) unless you need to see them. I'm considering migrating to an OutlineView, or perhaps the new View-based TableView...but I was wondering what other folks have done out there to make sure their users are not overwhelmed by having too many choices at their disposal. ___ 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: ARC + CF types
On 31 Aug 2011, at 21:55, Clark Cox wrote: On Mon, Aug 29, 2011 at 7:20 AM, Thomas Davie tom.da...@gmail.com 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 quick stare at this and tell me what I've misunderstood that's causing a segfault when adding to the mutable set: https://gist.github.com/1178475 Does the implementation of those objects' -hash method agree with your definition of equality? (i.e. it is almost always wrong to change the concept of equality without also changing the hash implementation). The only change in the equality concept is that isEqualToAPIObject: assumes that it's been given an APIObject and doesn't check that the other object is the right class. Otherwise the equality semantics are identical. if (*ra4 != 0xffc78948) { return false; } ___ 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
ARC + CF types
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 quick stare at this and tell me what I've misunderstood that's causing a segfault when adding to the mutable set: https://gist.github.com/1178475 Thanks Tom Davie if (*ra4 != 0xffc78948) { return false; } ___ 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: ARC + CF types
Because NSMutableSet does not have the ability to specify a different version of equality – though as Mike Ash pointed out in #macdev, NSHashTable may well be appropriate. Thanks Thomas if (*ra4 != 0xffc78948) { return false; } ___ 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: ARC + CF types
Doing that wouldn't magically use the more efficient equality check though without recoding NSMutableSet almost entirely, or… you know, using CFMutableSetRef and providing your own equality function. Thanks Tom Davie if (*ra4 != 0xffc78948) { return false; } On 29 Aug 2011, at 17:43, Dave Zarzycki wrote: 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, Thomas Davie wrote: Because NSMutableSet does not have the ability to specify a different version of equality – though as Mike Ash pointed out in #macdev, NSHashTable may well be appropriate. Thanks Thomas if (*ra4 != 0xffc78948) { return false; } ___ 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: Large over 100K pixel high ruler scroll view
if (*ra4 != 0xffc78948) { return false; } On 23 Aug 2011, at 22:18, Julie Porter wrote: I work with scans of 10 tune Nickelodeon player piano rolls. These can be over 100 yards long when unrolled. My roll images when uncompressed can be 100,000 plus pixels by 2800 pixels. In actual practice the images are made of lines, not pixels. To read these I have programs written in postscript or carbon. My carbon application is getting long in the tooth. I have been reading over this list and the Cocoa program examples and documentation over the last 3 months. I found the NSRulerView sample application. At issue is that interface builder will only let me make a view that is 1 pixels. Searching the web I see suggestions to do this programmatically. I am not sure where the code to create the window would go. I am finding that Cocoa, especially V2.0 obfuscates things, especially where to put things. What examples I have are base on images, but I am drawing lines, based on the scroller positions. I already have postscript and carbon code that tiles the images, So if I have the first set of lines to draw and the last set of lines to draw, I can find these in the file and draw them. How do I do setup the ruler and scrollviews programetically without interface builder? Your best bet is to not completely dump IB, but to simply set the contentSize programatically as soon as you load your document. I don't really see what you're saying about cocoa obfuscating things, it's one of the most clear APIs out there, and I'm not sure what you mean by v2.0 either. Re your specific example though – you should not be drawing anything based on a scroller position. Instead, the NSScrollView will ask for a specific rectangle of your contentView to be drawn using - (void)drawRect:(NSRect)r. Simply draw the area you've been asked to draw and all will go well. This all said, I'd recommend against using a scroll view here. Extremely long scroll views can get very difficult for the user to navigate. Instead, it might be worth considering some kind of scrubbing interface. Maybe something like a movie editor that shows a miniature visualisation of each section of roll, and allows the user to easily scrub through. Bob ___ 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: Coordinate system in CAOpenGLLayer
You're right – the vertices are here specified in OpenGL clip space – a coordinate system stretching from -1 to 1 on all 3 axes. If you want to specify points in a different coordinate space, it's your responsibility to make sure that they end up in clip space, by transforming them appropriately. In old world GL (as you have there) this is done through the fixed function transform: vertex in model space -- * modelview matrix - vertex in world space -- * projection matrix - vertex in clip space -- divide x,y,z by w - vertex in normalised device space -- viewport transform - vertex in pixel space I would however *highly* recommend not using old world GL. It will make your later transition to OpenGL 3.2 core much much harder, as most of the functions here (glMatrixMode, glPushMatrix, glRotate, glBegin, glColor, glVertex, glEnd, glPopMatrix, and many others) are no longer present. To get an idea of how to get started with modern OpenGL, take a look at https://github.com/beelsebob/Cocoa-GL-Tutorial and https://github.com/beelsebob/Cocoa-GL-Tutorial-2. These are still written in OpenGL 2.1, but in a way that the port to 3.2 when you come to it is trivially easy. Thanks Tom Davie if (*ra4 != 0xffc78948) { return false; } On 8 Aug 2011, at 08:35, Graham Cox wrote: I'm looking at using CAOpenGLLayer to boost drawing performance. I'm a total novice at OpenGL. Looking at the 'CALayerEssentials' sample code as a starting point, it has the following code: -(void)drawInCGLContext:(CGLContextObj)glContext pixelFormat:(CGLPixelFormatObj)pixelFormat forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp { // Set the current context to the one given to us. CGLSetCurrentContext(glContext); // We're just going to draw a single red quad spinning around based on the current time. Nothing particularly fancy. GLfloat rotate = timeInterval * 60.0; // 60 degrees per second! glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glRotatef(rotate, 0.0, 0.0, 1.0); glBegin(GL_QUADS); glColor3f(1.0, 0.0, 0.0); glVertex2f(-0.5, -0.5); glVertex2f(-0.5, 0.5); glVertex2f( 0.5, 0.5); glVertex2f( 0.5, -0.5); glEnd(); glPopMatrix(); // Call super to finalize the drawing. By default all it does is call glFlush(). [super drawInCGLContext:glContext pixelFormat:pixelFormat forLayerTime:timeInterval displayTime:timeStamp]; } What I find a bit odd here is that the coordinate values for the glVertex calls are not related to the layer's actual bounds, but to some notional coordinate system stretching from -1 to +1 in each dimension. If the layer is resized, the 'square' resulting stretches in proportion. I didn't expect this, though perhaps it's normal for OpenGL, or at least CAOpenGLLayer. There's virtually nothing in the documentation about this layer or how it's set up, so I'm having a hard time understanding how I'm supposed to go about calculating the coordinates I need. Can someone point me in the direction of any documentation that could help here, or at least confirm my observations about coordinates being relative to a +/- 1 virtual space? --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/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: Asynchronous downloading and parsing of XML
The hint is that the NSXMLParser docs say: Parameters stream The input stream. The content is incrementally loaded from the specified stream and parsed. if (*ra4 != 0xffc78948) { return false; } On 8 Aug 2011, at 17:59, Mikkel Islay wrote: Thanks for the explanation, Jens too. The hint that NSXMLParser has that behaviour is that it accepts an NSInputStream, or that it relies on a delegate for communicating parse-events? Mikkel On 8 Aug 2011, at 10:34, Andreas Grosam wrote: No. Asynchronous routines can be implemented above a blocking interface. Blocking and asynchronous interfaces work well together, and you may not even notice the existence of a blocking interface since it is working under the hood as an implementation detail. For instance the parser *could* (we don't know) be implemented as a recursive decent parser. This kind of parser will effectively require that the parsing routine blocks, when there is no further input available, since the state of the parser will be in its call stack. So you can't just stop and exit the parse function in the middle of a stream, and then continue with a newly invoked method when more data is available. The parser would just dispatch its events on the main thread where the delegate can handle them. So, from the view point of the delegate, it looks like an asynchronous interface. ___ 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/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: Asynchronous downloading and parsing of XML
On 8 Aug 2011, at 18:16, Mikkel Islay wrote: On 8 Aug 2011, at 19:04, Thomas Davie wrote: Parameters stream The input stream. The content is incrementally loaded from the specified stream and parsed. No, that states something about the way NSXMLParser is able to parse from a stream. It doesn't say anything about its state with respect to the main thread. I'm not sure what you're getting at… The key facts are… NSURLConnection provides data incrementally. The URLConnection delegate takes that data incrementally and provides it to the stream incrementally. The Stream takes the data incrementally and provides it to the parser as it gets it. The XML parser takes the data incrementally and calls the delegate when it parses something successfully. All of this is asynchronous, so everything works happily :) Tom Davie___ 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: Asynchronous downloading and parsing of XML
The purpose of the NSURLConnection is to deal with HTTP… How else would you propose dealing with it? I'm not sure why you think this throws away benefits of async loading, can you clarify that? Thanks Tom Davie On 7 Aug 2011, at 12:47, Mikkel Islay wrote: Thanks for sharing with the list. I wonder what the purpose of NSURLConnection is in this solution? Aren't you in effect throwing away the benefits of asynchronous loading? The NSInputstream can block, and NSXMLParser presumably will. You will also have to deal with events in several places, and make sure errors are propagated up and down the stream. Mikkel On 6 Aug 2011, at 22:08, Thomas Davie wrote: Just for reference, With the help of Mike Ash I figured out how to do this sensibly. Note, code typed straight into Mail.app, so it may not be dead perfect, but it should show the idea: //When creating the NSURLConnection and parser: - (void)doMagicParsingStuff { NSInputStream *iStream; NSOutputStream *oStream; CFStreamCreateBoundPair(NULL, iStream, oStream, 4096); [oStream setDelegate:self]; NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; [iStream scheduleInRunLoop:runLoop forMode:NSDefaultRunLoopMode]; [oStream scheduleInRunLoop:runLoop forMode:NSDefaultRunLoopMode]; finishedLoading = NO; [iStream open]; [oStream open]; [self setParserStream:oStream]; NSXMLParser *parser = [[[NSXMLParser alloc] initWithStream:iStream] autorelease]; } - (void)attemptToWriteToStream { NSUInteger written = [[self parserStream] writeBytes:[[self buffer] bytes] maxLength:[[self buffer] length]]; [[self buffer] replaceBytesInRange:NSMakeRange(0,written) withBytes: length:0]; } // In the output stream delegate: - (void)stream:(NSStream *)s handleEvent:(NSStreamEvent)event { if (NSStreamEventHasSpaceAvailable == event) { if (finishedLoading [[self buffer] length] == 0) { [[self parserStream] close]; } else { [self attepmtToWriteToStream]; } } } // In the NSURLConnection Delegate: - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)d { [[self buffer] appendData:d]; [self attemptToWriteToStream]; } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { finishedLoading = YES; } On 6 Aug 2011, at 12:14, Mikkel Islay wrote: You can't hook up NSURLConnection to NSXMLParser like that because it loads its data asynchronously. Rather, feed it (a copy of) the NSData object generated by NSURLConnection, or bypass NSURLConnection completely and load your data via NSInputStream. In either case you will have to verify that the data you feed to NSXMLParser is complete. Mikkel On 6 Aug 2011, at 12:02, Thomas Davie wrote: I'm trying to figure out how to download and parse XML at the same time. NSXMLParser seems to have support for this by providing it with an NSInputStream. However, I see no way to get an NSInputStream that contains the data that an NSURLConnection is downloading. ___ 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
Asynchronous downloading and parsing of XML
Hi everyone, I'm trying to figure out how to download and parse XML at the same time. NSXMLParser seems to have support for this by providing it with an NSInputStream. However, I see no way to get an NSInputStream that contains the data that an NSURLConnection is downloading. Is this possible in some sane way? Thanks Tom Davie___ 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: Asynchronous downloading and parsing of XML
Just for reference, With the help of Mike Ash I figured out how to do this sensibly. Note, code typed straight into Mail.app, so it may not be dead perfect, but it should show the idea: //When creating the NSURLConnection and parser: - (void)doMagicParsingStuff { NSInputStream *iStream; NSOutputStream *oStream; CFStreamCreateBoundPair(NULL, iStream, oStream, 4096); [oStream setDelegate:self]; NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; [iStream scheduleInRunLoop:runLoop forMode:NSDefaultRunLoopMode]; [oStream scheduleInRunLoop:runLoop forMode:NSDefaultRunLoopMode]; finishedLoading = NO; [iStream open]; [oStream open]; [self setParserStream:oStream]; NSXMLParser *parser = [[[NSXMLParser alloc] initWithStream:iStream] autorelease]; } - (void)attemptToWriteToStream { NSUInteger written = [[self parserStream] writeBytes:[[self buffer] bytes] maxLength:[[self buffer] length]]; [[self buffer] replaceBytesInRange:NSMakeRange(0,written) withBytes: length:0]; } // In the output stream delegate: - (void)stream:(NSStream *)s handleEvent:(NSStreamEvent)event { if (NSStreamEventHasSpaceAvailable == event) { if (finishedLoading [[self buffer] length] == 0) { [[self parserStream] close]; } else { [self attepmtToWriteToStream]; } } } // In the NSURLConnection Delegate: - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)d { [[self buffer] appendData:d]; [self attemptToWriteToStream]; } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { finishedLoading = YES; } On 6 Aug 2011, at 12:14, Mikkel Islay wrote: You can't hook up NSURLConnection to NSXMLParser like that because it loads its data asynchronously. Rather, feed it (a copy of) the NSData object generated by NSURLConnection, or bypass NSURLConnection completely and load your data via NSInputStream. In either case you will have to verify that the data you feed to NSXMLParser is complete. Mikkel On 6 Aug 2011, at 12:02, Thomas Davie wrote: I'm trying to figure out how to download and parse XML at the same time. NSXMLParser seems to have support for this by providing it with an NSInputStream. However, I see no way to get an NSInputStream that contains the data that an NSURLConnection is downloading. ___ 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: Unnecessary Boolean Warning
On 3 Aug 2011, at 14:29, Scott Ribe wrote: On Aug 3, 2011, at 1:53 AM, Dale Miller wrote: A decent language (IMHO) would not confuse things with two different and's. Well, there *are* two different and's, regardless of whether your favored languages allow you access to both or not. Not really – both C ands are the same and… they're just operating on different representations of booleans. Any *reasonably high level* language wouldn't have two representations of booleans. But that gets rather to the point of this – C isn't high level, for good reasons. Bob___ 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: Unnecessary Boolean Warning
On 3 Aug 2011, at 15:15, Scott Ribe wrote: On Aug 3, 2011, at 7:54 AM, Thomas Davie wrote: Not really – both C ands are the same and… they're just operating on different representations of booleans. No, they're not the same at all. One is a bitwise operation on binary ints. Yes – it performs the logical and operation on booleans represented by bits (lots of booleans at once in this instance). The other performs the same logical and operation on booleans represented by entire ints. Same op, different representations. Bob ___ 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: Drawing text like Lion's Mail
On 3 Aug 2011, at 22:40, Andre Masse wrote: One less pass is good. Thanks. Unfortunately, text is not as clean as Mail at this point. Small characters like e loose sharpness (white space inside the character is reduced). Still trying to find a winner by mixing different values. I'm not so sure Mail is using Helvetica now. Thanks for your help, No – it's using the system font – Lucida Grande. Bob___ 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: ARC and Singletons
On 1 Aug 2011, at 16:48, Jeff Kelley wrote: Is there a new recommended way to implement a singleton with ARC? I remember hearing something about it, but I’m not sure what it was. Was it perhaps… don't use singletons, they're just globals in disguise? Bob___ 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: Why Don't Cocoa's (Un)Archiving Methods return Errors?
On 29 Jul 2011, at 23:54, wadesli...@mac.com wrote: When invoking -archivedDataWithRootObject: on, say, dictionary, finding an un-encodeable object buried somewhere in the dictionary would seem to be quite common. Similarly, when invoking -unarchiveObjectWithFile:, no programmer can guarantee what may be found on the filesystem. And this is one of several concerns with the NSCoding system. It may be that the reason these classes haven't been updated is because there's consternation over the value of such an update. Some people consider NSCoding intractably insecure and ergo unsuitable for use in pretty much anything. Others take issue with it for varied other reasons. I personally like it, but it's not flawless. I wouldn't stress too much over it, in any case. Sooner or later a change will occur. 'til then, follow the best practices to date. I'm not sure really what the argument here is. What both of you seem to be asserting is you could construct any object from a file… that file might be maliciously structured to construct objects that behave in evil ways. This is true, but I'm not sure I see how this differs for *any* API that reads from the file system and constructs objects (as any file loading has to do). Can you give me an example of something that NSCoding (particularly when using keyed archiving) doesn't deal with cleanly, that leads to a security problem not found in other file loading schemes? Thanks Tom Davie___ 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: UI like Transmission BT
On 28 Jul 2011, at 09:16, Wilker wrote: Hi Guys, Which components of XCode 4 I should use in order to make an UI like the Transmission BT (http://www.transmissionbt.com/) I mean the part of downloads, one below the other, its like each download is a view, but I don't know how to put them one below the order, and how to make background color cycle. I was looking on Collection View, but after reading doc it don't really seems to feet for me, I just need something simpler, one below the other, scroll when its bigger than screen. You have three options: 1) Restrict yourself to 10.7 and use NSTableView with NSViews instead of NSCells. 2) Code an NSCell for that – this can be pretty damn horrible as NSCells can't keep their own state internally, because they will get reused for other rows. 3) Write your own view for putting a bunch of other views one above each other. 1 is trivially easy, 3 is pretty easy, 2 is a nightmare waiting to happen and the reason that 1 exists. Bob___ 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: Calculations in a tableview
On 28 Jul 2011, at 23:48, Andre Masse wrote: Hi, For example, lets say I have a tableview with 3 columns: quantity, unit price and total. I want to calculate total using (quantity * unit price). Pretty simple using a datasource but I've no idea how to do that with bindings (using an NSArrayController). Any pointer to an example of this would be greatly appreciated. To be honest, this, along with the many debugging issues of bindings is exactly why I still use data sources. Bob___ 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: iOS UI Design Question / Opinions wanted
On 14 Jul 2011, at 06:05, John Tsombakos wrote: Hi, Just getting more into iOS development, and am deciding on what to do for an app. One app is a competition scoring application, where the judges would use the app to calculate and score a game. The scores would are derived from a series of challenges, each worth a set number of points. Each challenge score is determined by a Yes/No completion - Did XYZ happen? Did The other thing happen? etc. I was trying to figure out how to design the UI and while for a web version that we already have that uses radio buttons for each question, I'm not sure what would be best for an iOS app. I looked at the UISwitch, but it shows On/Off and that's not quite right. A segmented control could possibly work, with one for Yes and one for No. I thought a checkbox to signify Yes - but it doesn't look like iOS has checkboxes (how did I never notice that!). I want to make it simple, so popping up a separate alert/window would incur an extra step. So I'm soliciting opinions / suggestions. Along with various other people, I have a custom UISwitch that does exactly what you require, it's available here http://whataboutapp.co.uk/ Tom Davie___ 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: Removing (foo) from a NSString
On 12 Jul 2011, at 20:23, Eric E. Dolecki wrote: What would be the easiest way to strip out parens and everything between them from an NSString? It's slightly overkill for the situation, but CoreParse (http://www.github.org/beelsebob) will deal with nested parens quite happily.___ 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: [ANN] CoreParse
On 6 Jun 2011, at 16:10, Philip Mötteli wrote: I really appreciate how BN support is implemented in ParseKit: http://parsekit.com/grammars.html. I like it very much, that there are no numbers, but call backs for every token, using method-names (c. f. above URL under Instantiating Grammar Parsers in Objective-C). Hi Philip, I thought you'd like to know I've improved the handling of BN grammars in CoreParse significantly. You can read about how it works at https://github.com/beelsebob/CoreParse. Thanks Tom Davie___ 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: [ANN] CoreParse
On 5 Jun 2011, at 15:35, Stephane Sudre wrote: Hi, your post probably misses the following stuff: - a URL - the license - whether it's written in Obj-C 2.0 (which I personally hope it's not) or 1.0. That'll teach me for posting this just as I was going out the door! - URL - http://www.github.com/beelsebob/CoreParse - The License - BSD 3 part - Obj-C 2.0 - yes, fraid so, it's all Obj-C 2.0 and requires the non-fragile ABI too. It supports both ref counting and GC modes though. Thanks Tom Davie___ 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: [ANN] CoreParse
On 6 Jun 2011, at 16:10, Philip Mötteli wrote: Hi, Am 06.06.2011 um 00:12 schrieb Thomas Davie: On 5 Jun 2011, at 18:22, Jens Alfke wrote: On Jun 5, 2011, at 6:21 AM, Thomas Davie wrote: I've just completed firming up the API and documentation for CoreParse. CoreParse provides a powerful tokenisation and parsing engine, which uses shift-reduce parsing (unlike ParseKit) to support a wide range of context free grammars. Parsers can be built quickly and easily using BNF like syntax. Cool! What advantages does this have over using a more-established tool like ANTLR? (“An Objective-C API” is an obvious answer, I suppose, but it doesn’t look that difficult to call into ANTLR-generated C++ code from Obj-C.) I've not investigated ANTLR, but you're right, my primary goal was a nice, clean, cocoa-like API in pure Obj-C only API. The only comparable API that I know of is ParseKit which uses recursive decent, and hence doesn't support a lot of grammars. By comparison there, I support SLR, LR(1) and LALR(1), so there's rather more coverage. I'd really appreciate you taking a look and reporting back if you find any interesting things that ANTLR or other tools does better. I really appreciate how BN support is implemented in ParseKit: http://parsekit.com/grammars.html. I like it very much, that there are no numbers, but call backs for every token, using method-names (c. f. above URL under Instantiating Grammar Parsers in Objective-C). Yep, I agree that my current implementation is not particularly nice in that respect. That said, I'm not entirely keen on ParseKit's design either. The alternative I'm pondering at the moment is to add a protocol defining -initWithSyntaxTree: and have CP do id x = [NSStringFromClass(nonTerminalName) alloc]; if ([x conformsToProtocol:@protocol(CPParsing)]) { return [[x initWithSyntaxTree:tree] autorelease]; } else { return tree; } It strikes me that this has disadvantages for the user too (creating a lot of boiler plate classes potentially). It seems to fit cases where you actually want to construct a data structure from your parse nicely, but not so well when you want to do a computation as a result of the parse. I will think about it some more, but I'd appreciate contributions on how to do this cleanly. Thanks Tom Davie___ 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
[ANN] CoreParse
Hi guys, I guess this will get rather overshadowed by some other guy's announcements in the near future, but I thought I'd throw this out there. I've just completed firming up the API and documentation for CoreParse. CoreParse provides a powerful tokenisation and parsing engine, which uses shift-reduce parsing (unlike ParseKit) to support a wide range of context free grammars. Parsers can be built quickly and easily using BNF like syntax. I'd really appreciate anyone's questions, comments and feature requests for future versions. Thanks Tom Davie ___ 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: [ANN] CoreParse
On 5 Jun 2011, at 18:22, Jens Alfke wrote: On Jun 5, 2011, at 6:21 AM, Thomas Davie wrote: I've just completed firming up the API and documentation for CoreParse. CoreParse provides a powerful tokenisation and parsing engine, which uses shift-reduce parsing (unlike ParseKit) to support a wide range of context free grammars. Parsers can be built quickly and easily using BNF like syntax. Cool! What advantages does this have over using a more-established tool like ANTLR? (“An Objective-C API” is an obvious answer, I suppose, but it doesn’t look that difficult to call into ANTLR-generated C++ code from Obj-C.) I've not investigated ANTLR, but you're right, my primary goal was a nice, clean, cocoa-like API in pure Obj-C only API. The only comparable API that I know of is ParseKit which uses recursive decent, and hence doesn't support a lot of grammars. By comparison there, I support SLR, LR(1) and LALR(1), so there's rather more coverage. I'd really appreciate you taking a look and reporting back if you find any interesting things that ANTLR or other tools does better. Thanks Bob ___ 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
Documentation generation
Heya, I'm working on improving my CoreParse (http://www.github.com/beelsebob/CoreParse) framework by actually documenting it properly. The problem I'm hitting though is that either the two major documentation generators suck (doubt that, probably PEBKAC), or their default configuration sucks. I've had a go with both doxygen and headerdoc. Headerdoc seems to produce some reasonably clear and well organised output, but I can't find any way to configure the output to be a bit prettier. Doxygen seems to produce a pretty cluttered mess as output, with a bunch of stuff that I really don't want, but I've not found any good documentation on how to configure it to produce nicer output. The GUI tool seems to be a perfect example of how not to design a GUI wrapper for a command line tool. Perhaps the design skills involved in it hint at why I don't like the structure of it's output either. Does anyone know a good way to get clean, reasonably configurable html output for objective-c documentation? Ideally, I'd like something that just dumps out almost exactly the style apple use for their docs, without too much need to play about. Thanks Tom Davie___ 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: Documentation generation
Excellent stuff thanks – hit a few bugs in it, but with some tweaking, its output looks absolutely brilliant. Cheers Tom Davie On 8 May 2011, at 14:11, Dave DeLong wrote: AppleDoc produces Apple-like docsets: https://github.com/tomaz/appledoc Cheers, Dave Sent from my iPhone On May 8, 2011, at 4:42 AM, Thomas Davie tom.da...@gmail.com wrote: Heya, I'm working on improving my CoreParse (http://www.github.com/beelsebob/CoreParse) framework by actually documenting it properly. The problem I'm hitting though is that either the two major documentation generators suck (doubt that, probably PEBKAC), or their default configuration sucks. I've had a go with both doxygen and headerdoc. Headerdoc seems to produce some reasonably clear and well organised output, but I can't find any way to configure the output to be a bit prettier. Doxygen seems to produce a pretty cluttered mess as output, with a bunch of stuff that I really don't want, but I've not found any good documentation on how to configure it to produce nicer output. The GUI tool seems to be a perfect example of how not to design a GUI wrapper for a command line tool. Perhaps the design skills involved in it hint at why I don't like the structure of it's output either. Does anyone know a good way to get clean, reasonably configurable html output for objective-c documentation? Ideally, I'd like something that just dumps out almost exactly the style apple use for their docs, without too much need to play about. Thanks Tom Davie___ 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/davedelong%40me.com This email sent to davedel...@me.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: Set the Display link's framerate?
On 8 May 2011, at 20:20, Nick wrote: Hi Is there any way to customize the frequency of the Core Video Display Link's callback calls? If not, what is the way to manually limit the framerate? The entire point of a CVDisplayLink is that it's tied to the refresh timing of the display. If you want to drop a frame, don't swap. Bob ___ 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
Online NSPrinters
Heya, The NSPrinter documentation says it will return nil of the specified printer passed to +printerWithName: is not available. Apparently being available does not correspond to being online as listed in System Preferences. Is there a sane way to check if a printer is connected and ready to go? Thanks Bob___ 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: NSOpenPanel
On 25 Apr 2011, at 12:55, Rick C. wrote: Hello, I'm thinking the answer is no but just to double-check is there any way to get another button into an NSOpenPanel? I only see the possibility for the default and cancel buttons unless I'm overlooking something. Thanks! See -setAccessoryView: Thanks Bob___ 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: A very customized window
On 16 Apr 2011, at 13:44, eveningnick eveningnick wrote: Basically i need this, to make my application look as similar as possible to my Windows version. A truely terrible idea! Why on earth do you think Mac users use Macs? Don't you think if they wanted everything to look and behave like windows they would just use windows? Bob ___ 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: Trying to subclass UISwitch
On 4 Apr 2011, at 17:31, Philip Ershler wrote: Outstanding, thank you very much! Phil On Apr 4, 2011, at 10:28 AM, Roger Dalal wrote: Phil: Try http://osiris.laya.com/projects/rcswitch/ by Sascha Hoehne and Robert Chin. It is well done. Roger Dalal Assembled Apps I didn't know this existed at the time I ended up writing my own, so the result is that I wrote my own a while back. If for some reason you find this version unsatisfactory, I also have a version available under the BSD 3 part license here: http://whataboutapp.co.uk/ Bob ___ 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: @property and Garbage Collection
On 25 Jan 2011, at 09:59, Kevin Bracey wrote: Hi Guys, I've been using Retain/Release up til now but I have started my first GC project. In a Garbage Collected App when using the @property is it correct that I still have to specify (copy) or (retain) or have I missed something? I thought using GC didn't require retain and that everything could just be assigned, but the complier complains. There is still a semantic difference between simply keeping hold of a reference to something, and copying that something, even if you have a neat tool keeping track of whether you still hold a reference. Bob___ 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: NSNotFound
On 15 Jan 2011, at 18:43, Richard Somers wrote: NSNotFound is formally defined as NSIntegerMax. But the framework methods returning NSNotFound are typically typed NSUInteger. Is there a technical reason why NSNotFound is not defined as NSUIntegerMax? 1) Because it's usable for NSInteger too. 2) By looking at these values you're breaking the abstraction barrier. NSNotFound could have *any* value, and in fact its value could change from cocoa version to cocoa version. Stop looking! Bob___ 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
Locating a contextual menu
Heya, I'd like in my app to be able to position an item by right clicking, and selecting something from a contextual menu. I'm struggling with this though, I don't see any way to find the position of the click that caused the contextual menu to appear. Things I've tried: 1) using standard responder like stuff to find the last click in the view, and memorise it. Unfortunately, NSView eats the right click that causes the contextual menu popup so you never get to know where it was. 2) Tracking mouseMoved events until the menu pops up – unfortunately you get no way to figure out when the menu opens, so the best you can get is the position of the mouse when your action was sent (which is possibly a long way off the original click). 3) Searching the docs for some kind of position/location/frame/etc property on NSMenu and friends – no luck. Is there a correct way to do this? Thanks Tom Davie___ 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
Responding to the keyboard in an NSCell
I'm trying to implement an NSCell which should be able to respond to the user pressing backspace to delete something, but I don't quite see how keyboard handling is meant to work. The - (BOOL)acceptsFirstResponder method seems to suggest that NSCell *should* be an NSResponder subclass. It isn't though, and it doesn't get sent things like -keyDown: if you return YES from acceptsFirstResponder. I get the feeling that I'm missing something obvious here, but I could do with a prod in the right direction. Thanks Tom Davie___ 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: Responding to the keyboard in an NSCell
On 25 Nov 2010, at 10:46, Graham Cox wrote: On 25/11/2010, at 9:37 PM, Thomas Davie wrote: I'm trying to implement an NSCell which should be able to respond to the user pressing backspace to delete something, but I don't quite see how keyboard handling is meant to work. The - (BOOL)acceptsFirstResponder method seems to suggest that NSCell *should* be an NSResponder subclass. It isn't though, and it doesn't get sent things like -keyDown: if you return YES from acceptsFirstResponder. I get the feeling that I'm missing something obvious here, but I could do with a prod in the right direction. A cell is usually a component of a view. The view is the responder, but I presume the -acceptsFirstResponder method in NSCell is really there so that the host view can defer to its cell to answer that question. Surely in order to defer control though there would have to be some protocol defined somewhere that tells us how a view can ask a cell for help in responding to the keyboard? If you want to use the cell in a standard view, such as a tableview , matrix, or other control, you'll have to figure out how those classes interact with their cells. If it's in a custom view of your own, you can probably be more loose with how you do it, if compatibility with standard controls isn't required. Though in that case, you could just make a custom view. Unfortunately, I'm embedding these in an outline view, my current thinking is to subclass NSOutlineView and hack my own responder events to talk to my cell, but it seems a bit of a hack – it embeds part of the semantics of my cell in a class elsewhere, and stops the cell being composible in other scenarios. If there really is no real way to do this though, I guess it's what I'll have to do :/ Thanks Tom Davie___ 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: Responding to the keyboard in an NSCell
On 25 Nov 2010, at 11:30, Graham Cox wrote: On 25/11/2010, at 10:12 PM, Thomas Davie wrote: Surely in order to defer control though there would have to be some protocol defined somewhere that tells us how a view can ask a cell for help in responding to the keyboard? Cells are mostly designed, as far as I can see, to relieve the view of a repetitive drawing task. Where they have an editing function, that's handled by the Field Editor, another view. Unfortunately, I'm embedding these in an outline view, my current thinking is to subclass NSOutlineView and hack my own responder events to talk to my cell, but it seems a bit of a hack – it embeds part of the semantics of my cell in a class elsewhere, and stops the cell being composible in other scenarios. If there really is no real way to do this though, I guess it's what I'll have to do :/ The view is the only part that directly responds to the keyboard. You could just pass everything to the cell, but then it wouldn't work the same in a standard control. There is no defined protocol beyond the usual control -- cell methods which allow you to, e.g. start and stop editing, but do not go further down to individual key events, which are handled by the Field Editor. There are further interactions between the Field Editor and the cell though, maybe your cell could use the FE in a standard way for editing? I've made a few NSCell subclasses in my time, and every time it was a deal of trouble. In your case if you want to use NSOutlineView as a host you'll probably have to accept the hassle, or try to make your cell fit in a more standard way. Sorry the advice is rather vague - every case seems to be different. Yep, NSCell certainly seems to introduce a whole bundle of corner cases – this is the second of any significance I've tried to implement, and each has thrown up different bizarre behaviours. Here's hoping that now that drawing efficiency is less of an issue, apple can refactor NSOutlineView and NSTableView into an NSOutlineView2 that uses something more akin to CocoaTouch's cells (that are still views) for drawing. Tom Davie___ 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
Asking an outline/table view to send it's setObjectValue:... message
Hi, I'm writing a custom cell at the moment that's used in an outline view, it's object value changes sometimes when the outline view doesn't expect it to (which seems to be only on mouse down or end editing). Is there some way I can force the outline view to send it's - (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item message? Thanks Tom Davie___ 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: On self = [super init...] ...
On 18 Nov 2010, at 21:16, Bill Bumgarner wrote: On Nov 18, 2010, at 1:10 PM, John Engelhart wrote: The basic premise behind self = [super init...] is that the lower levels of initialization are free to return a different object than the one passed in. However, there is an unstated assumption in this reasoning: whatever object is returned by [super init...] is the one that will be used. I don't understand the above claim; Why must the object returned by [super init*] be the one that is used? I'm certainly not aware of any limitation on an init method that would prevent it from… say… calling [super init], releasing whatever is returned if deemed unfit and then allocating an initializing some other instance. The documentation (http://developer.apple.com/library/mac/#documentation/cocoa/Conceptual/ObjectiveC/Articles/ocAllocInit.html) doesn't seem to make any such claim either. I haven't read beyond the above yet. Maybe the unstated assumption is explained? Indeed, the behaviour of immutable strings and containers seem to back up this assertion #import Foundation/Foundation.h int main (int argc, char ** argv) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *s1 = @; NSString *s2 = [NSString stringWithString:s1]; NSString *s3 = [NSString alloc]; NSString *s4 = [s3 initWithString:s2]; NSLog(@%p, %p, %p, %p, s1, s2, s3, s4); [pool drain]; } prints 2010-11-18 21:39:35.767 Test[18767:a0f] 0x11050, 0x11050, 0x10010d470, 0x11050 So our allocated string is certainly substituted during initialisation. Bob___ 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: How to remove 'not found in protocol' compiler warning
On 12 Nov 2010, at 14:17, Sherm Pendley wrote: On Fri, Nov 12, 2010 at 9:09 AM, Paul Johnson p...@askerko.net wrote: I'm getting a compiler warning message at the following line of code: NSArray *selectedObjects = [[secondTableView dataSource] selectedObjects]; The warning message is 'selectedObjects' not found in protocol. Note that NSTableView's -dataSource returns an object of type idNSTableViewDataSource. So, the compiler knows nothing about the object other than its protocol conformance. Since -selectedObjects isn't part of the protocol, it gives this warning. Can someone suggest what I need to do to remove the warning? Use a type cast to tell the compiler what class the data source really is: NSArray *selectedObjects = [(MyDataSourceClass*)[secondTableView dataSource] selectedObjects]; While this will work, I don't agree that it's the correct solution to the problem. The issue here is that you are making an assumption about the TV's data source that may not be true. Instead, what should be happening is that if you want to send messages to that particular object with the knowledge that it's the right type to receive those messages, you should maintain your own pointer to the object, and you should send messages there instead. This is roughly the same reason as why you shouldn't be sending messages to [NSApp delegate] – that's the app delegate, and the app is responsible for sending it messages, not you... if you want to send messages to a controller that just so happens to be the same object, maintain your own pointer to it with a more specific type. Bob___ 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: iPad 4.1 (deploy to 3.2.2) error
On 11 Nov 2010, at 14:50, Steve Bird wrote: On Nov 11, 2010, at 9:39 AM, colors wrote: Wow I am so sorry I posted to this forum. I thought this was a forum for engineers, but turns out everyone on it is a lawyer. I fat fingered a 2 instead of a 1 in the subject field and ended up with a bunch of emails about legal agreements. There were two instances of 4.2 (not 4.1) in the body of your first message, in addition to the subject. Not only that, but 4.1 was never released for iPad. Bob___ 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: [ANN] Release: NanoStore 1.0 for Mac and iOS
On 23 Sep 2010, at 07:39, Tito Ciuro wrote: Hm. That would be discussed better on a White Paper or similar. There are countless tutorials and documents about Core Data already. What I can do however is to provide a small example to illustrate how NanoStore works. I believe (please correct me if I'm wrong) that Core Data stores the data atomically for both, XML and binary formats. That, if I'm not mistaken requires the datafile to be read in memory. That's incorrect, CoreData gives you the choice of XML, binary or SQLite backends. When using the SQLite one it reads the data lazily. Not so with NanoStore: the SQLite database is the storage system and the API stores and retrieves dictionaries. Another strong point is that you can store whatever you want: from the developer's perspective, there is no schema, so objects of different weight or complexity can be stored with ease and retrieved back verbatim. That's certainly a neat trick, I can imagine that lets you get started with this a lot faster than with CoreData. Now... I like Core Data. I really do. But some times I get the feeling that it's too heavy for simple tasks. Plus, making CD work requires some reading, while NanoStore requires a fraction of the time to get it working. I believe that many developers will welcome this addition, as they will be able to concentrate their effort on other parts of their app. In essence, I designed NanoStore to be simple, relatively powerful and fast, while demanding a minimum effort from the developer. Time will tell if I'm wrong :-) Sounds like a neat middle ground, I'll give it a go some time soon! Bob ___ 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: [ANN] Release: NanoStore 1.0 for Mac and iOS
On 23 Sep 2010, at 03:51, Tito Ciuro wrote: Today, Webbo is pleased to announce the release of NanoStore: http://sourceforge.net/projects/nanostore/ NanoStore is a Cocoa wrapper for SQLite, a C library that implements an embeddable SQL database engine. With NanoStore, you store data using a dictionary of any depth. The developer can decide what to store on the fly, unlike other systems that require the developer to design a schema. With NanoStore just build your dictionary and store it. That's all there is to it! Every data element in the dictionary is indexed (except BLOBs) so there's no need to keep a list of indexed separately. You can disable indexing, import your data in batch mode, save it and then reindex at once, which is quite efficient. For even better performance, all I/O can be performed in memory and save the new database to disk at once, which is even faster. And if you feel adventurous, you can even do that in Fast mode and save extra SQLite processing. Sounds like fun! Can you explain some of the differences between using this or using CoreData to achieve a similar thing? Thanks Bob ___ 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
Core Graphics wants 10 petabytes of RAM
I'm having a problem with CoreGraphics periodically deciding it wants to allocate an enormous amount of RAM, the code in question is simply trying to create an NSImage from raw data: CGContextRef context = CGBitmapContextCreate(imgData, width, height, 8, 4 * width, colourSpace, kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedLast); CGImageRef cgImage = CGBitmapContextCreateImage(ctx); NSImage *i = [[[NSImage alloc] initWithCGImage:cgImage size:NSMakeSize(width, height)] autorelease]; CGImageRelease(cgImage); CGContextRelease(context); CGColorSpaceRelease(colourSpace); Creating the image (the call to CGBitmapContextCreateImage) sometimes (seemingly at random) produces this error: Error: CGDataProviderCreateWithCopyOfData: failed to vm_allocate 10248191152060862009 bytes: 3. And returns a nil image. Applying the debugger finds that width, height and imgData are all sane values (512, 512, and 512 * 512 * 4 bytes of data). Cheers to anyone who knows what's up. Bob ___ 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: Core Graphics wants 10 petabytes of RAM
On 7 Sep 2010, at 13:10, Guillem Palou wrote: On Sep 7, 2010, at 2:07 PM, Thomas Davie wrote: I'm having a problem with CoreGraphics periodically deciding it wants to allocate an enormous amount of RAM, the code in question is simply trying to create an NSImage from raw data: CGContextRef context = CGBitmapContextCreate(imgData, width, height, 8, 4 * width, colourSpace, kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedLast); CGImageRef cgImage = CGBitmapContextCreateImage(ctx); Should be CGImageRef cgImage = CGBitmapContextCreateImage(context); ?? Hah! well spotted. I wonder why this ever worked! Schrodingbug! ___ 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: NSOpenPanel -setAllowedFileTypes
On 26 Aug 2010, at 18:41, k...@highrolls.net wrote: I have an accessory view in an NSOpenPanel which contains a NSComboBox. The combo box is a list of file extensions. When the user selects an entry the action method calls --setAllowedFileTypes. All these mechanics work properly. The issue: The open panel does not respond to the new allowed file types. What I am trying to accomplish is a dynamic filter as we see in a Windows open file dialog. Am I barking up the wrong or impossible tree here? Simple solution – don't try to hack Mac OS to be windows. Different UIs are different, let them be so, you users are using macs for a reason. Bob___ 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: Garbage collector
At present, the iPhone SDK does not support garbage collection, so you're best off at least making it GC supported, rather than required. Bob On 8 Jun 2010, at 11:48, Takeichi Kanzaki Cabrera wrote: Hi all, I'm beginning with an application for Mac OS X that in a future could become into an iphone app, could I use the garbage collector or is better don't use it? Regards, Takeichi ___ 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/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: -[NSMutableSet randomObject]
If this is indeed the desired effect, you're much better off writing a - (NSArray *)arrayByRandomlyOrderingObjects in an NSArray category, and then calling [[mySet allObjects] arrayByRandomlyOrderingObjects];. Bob On 25 May 2010, at 17:54, Dave DeLong wrote: Ah, I see; you don't want to provide the same object twice in a row. If that's the case, is it really random? ;) Dave On May 25, 2010, at 10:52 AM, Dave DeLong wrote: What about something like: @implementation NSSet (Random) - (id) randomObject { NSArray * allObjects = [self allObjects]; if ([allObjects count] == 0) { @throw ...; } return [allObjects objectAtIndex:(arc4random() % [allObjects count])]; } @end ___ 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/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: Regarding MVC design pattern
On 20 May 2010, at 15:24, mmalc Crawford wrote: On May 19, 2010, at 4:38 am, Sherm Pendley wrote: If you set the ivars directly, as above, the synthesized setters will NOT be called. For that to happen, you need to use dot-syntax, like this: - (void) dealloc { self.beginButton = nil; self.endButton = nil; // etc... [super dealloc]; } You do not *need* to use the dot syntax to invoke the accessors synthesised for a property. You can also use the corresponding accessor method using [] syntax, e.g. [self setBeginButton:nil]; However, you should typically not invoke accessor methods in init or dealloc methods. Can I ask why you shouldn't use them in init? It makes a lot of sense to not use them in alloc/dealloc, but I'm not using them in init... after all, what if I replace the ivar with a derived property from another object? Why should I have to recode my init? Bob___ 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: Regarding MVC design pattern
On 20 May 2010, at 15:45, Barry Skidmore wrote: If you need to have it set you should create an initWithOptionName: and call that from your standard init, or return an error stating a missing value is needed. Your init should always call down tithe most specific init. Specific examples of this are available as best practice in several cocoa and design pattern books. I think you've misunderstood what I was asking. If I use a setter (in the most specific init), then I don't need to recode (even the most specific init) if I change how the property is implemented. If I don't use the setter, I do. What I was asking was why you would want to avoid using setters in the init method... Is there some safety issue I've missed? Bob___ 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: iPhone: viewDidAppear called, Default.png still visible
On 12 May 2010, at 17:54, sebi wrote: Hello, How can I find out if my first view is up and running? When viewDidAppear is called on my fist UIViewController I'm still looking only at the Default.png. What I do first in my app is: 1. wait for viewDidAppear to be called 2. show some wait-indicator 3. load some data from the net 4. hide the wait-indicator 5. display the loaded data The problem is, that the Default.png doesn't go away until the data is fully loaded, so the user only sees a passive screen for some time and doesn't know what's going on. Where can I start the wait indicator and download process so that the user actually sees it? I use some NavigationControllers within a TabBarController, could that be the problem? It sounds like you're not handing control back to the run loop at any point in this process. What you probably want to do is this instead: Main Thread: 1. wait for viewDidAppear to be called 2. show the wait indicator 3. Start thread B 4. Hand control back by leaving your method's scope Thread B: 1. Load some data from the net. 2. use performSelectorOnMainThread:... to fire off a message that the data has finished loading. Main Thread: 1. On receiving said message, hide the wait indicator 2. display the loaded data. Bob___ 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: premultiplying alpha
On 5 May 2010, at 06:05, Ken Ferry wrote: On Tue, May 4, 2010 at 9:30 AM, David Duncan david.dun...@apple.com wrote: On May 4, 2010, at 8:57 AM, Thomas Davie wrote: After much searching about, I discovered (contrary to what the docs say), that NSBitmapImageReps do not always premultiply their r/g/b by their alpha. I think you're misreading something. NSAlphaNonpremultipliedBitmapFormat exists. :-) Indeed, but nearly the first thing the documentation says is: If a coverage (alpha) plane exists, a bitmap’s color components are premultiplied with it. If you modify the contents of the bitmap, you are therefore responsible for premultiplying the data. For this reason, though, if you want to manipulate the actual data, an NSBitmapImageRep object is not recommended for storage. If you need to work with data that is not premultiplied, you should use Quartz, specificallyCGImageCreate with kCGImageAlphaLast. This is repeated variously through the documentation, with no mention of the alphaNonPremultiplied format except in the constants section. I've filed a documentation bug report :) Bob___ 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: Nil items in NSMutableSet
Your code doesn't account for the possibility that the order of comparison might happen in the other order (i.e. [@123 isEqual: object]). I wouldn't be surprised if NSSet is assuming that equality is transitive (i.e. [a isEqual: b] == [b isEqual: a]). For reference, this property is not transitivity, the transitivity relation is: a - b ^ b - c = a - c (for some relation -) The one you're looking for is commutativity. Bob___ 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: Anything like -[performBlockOnMainThread:]?
Just for reference's sake: @interface NSObject (BlockOnMainThread) - (void)performBlockOnMainThread:(void(^block)()); @end @interface NSObject (BlockOnMainThreadPrivate) - (void)performBlock:(void(^block)()); @end @implementation NSObject (BlockOnMainThread) - (void)performBlockOnMainThread:(void(^block)()) { [self performSelector:(performBlock:) withObject:[block copy] waitUntilDone:YES]; } - (void)performBlock:(void(^block)()) { block(); [block release]; } @end Note though, this was typed entirely into my email client, so YMMV. Bob On 15 Mar 2010, at 22:01, Keith Duncan wrote: On 15 Mar 2010, at 21:47, Rick Mann wrote: Then again, what I was doing before was really: [mTarget performSelectorOnMainThread: mSelector withObejct: data waitUntilDone: true]; In which case: NSBlockOperation *blockOperation = [NSBlockOperation blockOperationWithBlock:^ { ... }]; [[NSOperationQueue mainQueue] addOperation:blockOperation]; [blockOperation waitUntilFinished]; or dispatch_sync(dispatch_get_main_queue(), ^ { ... }); Keith ___ 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/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: Which iPhone Program?
On 13 Mar 2010, at 11:59, Alexander Spohr wrote: This is not really a Cocoa question... - If you want your application in the store you need Company. This is not true, I currently have two applications in the store, and do not have a company account. The important difference is that if you have a VAT number you must select company to reclaim tax. If you do not have a VAT number through not being a company, you must select personal. Bob ___ 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: Which iPhone Program?
On 13 Mar 2010, at 16:41, Alexander Spohr wrote: Am 13.03.2010 um 17:03 schrieb Thomas Davie: On 13 Mar 2010, at 11:59, Alexander Spohr wrote: This is not really a Cocoa question... - If you want your application in the store you need Company. This is not true, I currently have two applications in the store, and do not have a company account. The question here was if he needs company or enterprise. Private was out of the question. That doesn't make the statement any more true. Bob___ 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: EXC_BAD_ACCESS
Your initBezierPath method reallocates and reinitialises a path that's already been created. It also autoreleases the result (as the allocation method doesn't start with alloc, copy, mutableCopy, retain or new). The result is that the first time 'path' is assigned it gets a non-released value. The second time that 'path' is assigned, the original value is leaked, as it is never released, and it is given a new value which is autoreleased. By the time you get to your paint method being called, the runloop has completed, and the path has been deallocated. What you probably want is... - (id)initSquare // Note, id, not Square, this way, when we subclass, the type system won't explode. { self = [super init]; if (nil != self) { path = [[NSBezierPath bezierPathWithRoundedRect:NSMakeRect(0,0,10,10) xRadius:5 yRadius:5] retain]; } return self; } - (void)dealloc { [path release]; } Bob On 11 Mar 2010, at 13:38, Billy Flatman wrote: Hi All, I'm getting a 'EXC_BAD_ACCESS' error when calling the fill on a NSBezierPath. Below is an outline of my code. @interface Shape : NSObject { NSBezierPath *path; } - (void)paint; @end @implementation Shape - (void) paint { [[NSColor redColor] set]; [path fill]; } @end @interface Square : Shape Moveable {} - (Square *) initSquare; - (void)initBezierPath; @end @implementation Square - (Square *) initSquare { self = [super init]; if (self) { path = [[NSBezierPath alloc] init]; [self initBezierPath]; } return self; } - (void) initBezierPath { path = [NSBezierPath bezierPathWithRoundedRect:NSMakeRect(0,0,10,10) xRadius:5 yRadius:5]; [path closePath]; } @end it works if I change initBezierPath content to: path = [path init]; [path appendBezierPathWithRoundedRect:r xRadius:5 yRadius:5]; [path closePath]; From the main body I initialise a Square and call it's paint method in the drawRect method of an NSView. Any help would be greatly appreciated. Billy Flatman b.flat...@googlemail.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/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: EXC_BAD_ACCESS
Oops, sorry, my dealloc was buggy o.O - (void)dealloc { [path release]; [super dealloc]; } Bob On 11 Mar 2010, at 13:38, Billy Flatman wrote: Hi All, I'm getting a 'EXC_BAD_ACCESS' error when calling the fill on a NSBezierPath. Below is an outline of my code. @interface Shape : NSObject { NSBezierPath *path; } - (void)paint; @end @implementation Shape - (void) paint { [[NSColor redColor] set]; [path fill]; } @end @interface Square : Shape Moveable {} - (Square *) initSquare; - (void)initBezierPath; @end @implementation Square - (Square *) initSquare { self = [super init]; if (self) { path = [[NSBezierPath alloc] init]; [self initBezierPath]; } return self; } - (void) initBezierPath { path = [NSBezierPath bezierPathWithRoundedRect:NSMakeRect(0,0,10,10) xRadius:5 yRadius:5]; [path closePath]; } @end it works if I change initBezierPath content to: path = [path init]; [path appendBezierPathWithRoundedRect:r xRadius:5 yRadius:5]; [path closePath]; From the main body I initialise a Square and call it's paint method in the drawRect method of an NSView. Any help would be greatly appreciated. Billy Flatman b.flat...@googlemail.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/tom.davie%40gmail.com This email sent to tom.da...@gmail.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: NSCollectionView deselection
On 2 Mar 2010, at 14:39, Markus Spoettl wrote: On Mar 2, 2010, at 3:36 AM, Thomas Davie wrote: On Mar 1, 2010, at 2:42 PM, Thomas Davie wrote: However, when the user clicks on item B after clicking on item A, setSelected:NO is *not* sent to the NSCollectienViewItem subclass for A. This displeases me greatly :(. Works fine for me. Are you sure it's not called/set? Put a breakpoint into the setter into the setter of your NSCollectienViewItem subclass to find out. Hmm, that's exactly how I'm finding out that it's not being called :/ Then it actually may not be deselected. Are you sure it is being deselected? What controls your selection? What is your binding setup? Do you have multi-selection enabled? Maybe something is wrong with the selectionIndexes of the NSArrayController which I presume provides the content of the collection view and the selection. You're not saying what your setup is like. The NSCollectionView certainly *thought* it was being deselected – if the user clicks A, then A again, only one setSelected:YES gets sent, if the user clicks A, then B, then A again, setSelected:YES gets sent to A twice and B once. I've worked around this now by writing an NSCollectionView subclass with my own selection and drag/drop code. Tom Davie___ 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: NSCollectionView deselection
On 2 Mar 2010, at 04:03, Markus Spoettl wrote: On Mar 1, 2010, at 2:42 PM, Thomas Davie wrote: However, when the user clicks on item B after clicking on item A, setSelected:NO is *not* sent to the NSCollectienViewItem subclass for A. This displeases me greatly :(. Works fine for me. Are you sure it's not called/set? Put a breakpoint into the setter into the setter of your NSCollectienViewItem subclass to find out. Hmm, that's exactly how I'm finding out that it's not being called :/ I wonder what else could be going on here. Tom Davie___ 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
NSCollectionView deselection
Hi, I have, after much struggling with the documentation, managed to create an NSCollectionView that displays all the items I want it to. However, selection isn't quite working right. When the user clicks on item A, setSelected:YES is sent to the NSCollectionViewItem subclass for A. This pleases me :) When the user clicks on item B, setSelected:YES is sent to the NSCollectionViewItem subclass for B. This pleases me too :). However, when the user clicks on item B after clicking on item A, setSelected:NO is *not* sent to the NSCollectienViewItem subclass for A. This displeases me greatly :(. Is there some way I can get my NSCollectionView to tell me when the user deselects items? Thanks Tom Davie ___ 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: Dynamically loading a part of a Window in Cocoa
On 1 Jul 2009, at 09:21, Debajit Adhikary wrote: I have an area of a Window (in my MainMenu.xib) which I'd like to populate dynamically with unrelated views such as an NSTable, IKImageBrowserView etc. at different points of time depending on some user-selected criteria. - How do I define this area of the window such that it can be replaced with different views? Stick an NSView in the gap, add an outlet to your controller, and connect it up. - How do I attach a table or some other view to this area of the window? Using add/removeSubview: (Is it enough to place a generic NSView there and add a subview each time? I'm fairly new to Cocoa, so any pointers are welcome) Yes -- at least that's what I do, if I'm doin it rong, hopefully someone will tell me :) Bob ___ 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: Dispose patern (was: Re: GC pros and cons)
On 28 Jun 2009, at 17:47, Konrad Neitzel wrote: Thomas Davie tom.da...@gmail.com schrieb am 27.06.2009 09:56:31: On 27 Jun 2009, at 01:27, James Gregurich wrote: GC isn't nirvana. it does have its perils and issues, and you have to be aware of them and code around them. You can't just turn it on and some how everything magically works. There is no perfect solution to memory management. I prefer a solution where I manage the dependencies and objects go away in an orderly fashion based on the dependency graph for those objects. Uhhh, you mean a garbage collector? That's exactly what it does -- frees objects when nothing depends on them any more. But a garbage collector must be able to detect an object which memory can / must be released. And for all this, the system has to do some work. As must your program do if it keeps track of memory manually. Are you betting you can make that less work than a bunch of compiler engineers can? Note, this actually isn't a bad bet with GC, but it's not a good one either. I still have to read much more about the GC used within Objective- C / Cocoa so I am not sure, if I am not writing some kind of bullshit from your view: Isn't it possible to simply flag an object to be removed? Is there a dispose pattern in Objective-C? (e.g. http://www.codeproject.com/KB/cs/idisposable.aspx describes such a pattern in C#) Something like that would simply more the world together again. That way, the developer has some more control, the GC has less work and all are maybe happy? So is there such an Dispose Pattern in Objective-C using a GC or is there nothing like that? That sounds exactly like reference counting – and it suffers from all the well known problems (like retain cycles). The point here is that you don't *want* the developer to have control, the developer (myself included) is really really bad at doing this, and introduces a *lot* of bugs in the process. The option for it of course will keep everyone happy, but that doesn't mean it should be encouraged ;) Bob___ 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: Dispose patern (was: Re: GC pros and cons)
On 28 Jun 2009, at 19:27, Stephen J. Butler wrote: On Sun, Jun 28, 2009 at 11:06 AM, Thomas Davietom.da...@gmail.com wrote: On 28 Jun 2009, at 17:47, Konrad Neitzel wrote: I still have to read much more about the GC used within Objective- C / Cocoa so I am not sure, if I am not writing some kind of bullshit from your view: Isn't it possible to simply flag an object to be removed? Is there a dispose pattern in Objective-C? (e.g. http://www.codeproject.com/KB/cs/idisposable.aspx describes such a pattern in C#) Something like that would simply more the world together again. That way, the developer has some more control, the GC has less work and all are maybe happy? So is there such an Dispose Pattern in Objective-C using a GC or is there nothing like that? That sounds exactly like reference counting – and it suffers from all the well known problems (like retain cycles). The point here is that you don't *want* the developer to have control, the developer (myself included) is really really bad at doing this, and introduces a *lot* of bugs in the process. The option for it of course will keep everyone happy, but that doesn't mean it should be encouraged ;) Again, IDisposable in C# has nothing to do with early destruction/deallocation of the object. It's purpose to is perform explicit cleanup of external resources, resources not managed by the GC system. For example: file handles, sockets, OS system handles, etc. Calling Dispose() on a C# system does not mark the object for early collection (AFAIK). Oh, personally I would just let GC deal with that -- tie a handle under GC to them, add a finalizer on the handle, and destroy the reference when the handle is destroyed by the GC system. Bob ___ 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: GC pros and cons
On 27 Jun 2009, at 01:27, James Gregurich wrote: GC isn't nirvana. it does have its perils and issues, and you have to be aware of them and code around them. You can't just turn it on and some how everything magically works. There is no perfect solution to memory management. I prefer a solution where I manage the dependencies and objects go away in an orderly fashion based on the dependency graph for those objects. Uhhh, you mean a garbage collector? That's exactly what it does -- frees objects when nothing depends on them any more. Bob ___ 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: GC pros and cons
On 27 Jun 2009, at 14:04, Klaus Backert wrote: On 27. Jun 2009, at 09:54, Thomas Davie wrote: On 27 Jun 2009, at 01:27, James Gregurich wrote: GC isn't nirvana. it does have its perils and issues, and you have to be aware of them and code around them. You can't just turn it on and some how everything magically works. There is no perfect solution to memory management. I prefer a solution where I manage the dependencies and objects go away in an orderly fashion based on the dependency graph for those objects. Uhhh, you mean a garbage collector? That's exactly what it does -- frees objects when nothing depends on them any more. Now I'm confused, because other people said, GC frees objects *when* nothing depends on them any more *or* at some point later in time. By the way, it would be different, if you said if instead of when, but then, I think, you would have no point in the ongoing discussion. Why is this a problem? Nothing depends on the objects, and hence nothing can see when they're actually collected. If you're worried about running out of space because the collector is lazy, then all you need to know is that as soon as you get to the oh shit, no memory stage, the collector runs and frees some more up (unless there really is none to free up). All you're doing by keeping track of the dependancy graph yourself is reinventing the wheel -- lots of people have put a lot of research into how to keep track of those dependancies fast, and in a way that frees up memory quickly and efficiently. Bob ___ 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