Re: initWithNibName:nil not working for UITableViewController?
Hi Matt, On Fri, Aug 13, 2010 at 8:45 PM, Matt Neuburg m...@tidbits.com wrote: But I had expected initWithNibName: to follow the rule documented under UIViewController: If you specify nil for the nibName parameter and do not override the loadView method in your custom subclass, the default view controller behavior is to look for a nib file whose name (without the .nib extension) matches the name of your view controller class. If it finds one, the class name becomes the value of the nibName property, which results in the corresponding nib file being associated with this view controller. Is this a bug? I've made a small demonstration project that I can easily send in via bugreporter, if so. m. If you review the docs for UITableViewController, you'll see that it changes the standard behavior of a nil nibName argument and instead creates a basic, unconfigured table: If a nib file is specified via the initWithNibName:bundle: method (which is declared by the superclass UIViewControllerfile:///Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiPhone3_2.iPhoneLibrary.docset/Contents/Resources/Documents/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/cl/UIViewController ),UITableViewController loads the table view archived in the nib file. Otherwise, it creates an unconfigured UITableViewfile:///Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiPhone3_2.iPhoneLibrary.docset/Contents/Resources/Documents/documentation/UIKit/Reference/UITableView_Class/Reference/Reference.html#//apple_ref/occ/cl/UITableView object with the correct dimensions and autoresize mask. You can access this view through the tableViewfile:///Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiPhone3_2.iPhoneLibrary.docset/Contents/Resources/Documents/documentation/UIKit/Reference/UITableViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UITableViewController/tableView property. This bit me once as well. I consider it a poor API design choice to change the behavior so drastically from UIViewController, but it is almost certain not to change at this point. Jason ___ 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: NSURLConnection POST issues
On Jan 9, 2010, at 9:31 PM, Damien Cooke wrote: here is my code to send this data [appendedData appendData:[[[NSString stringWithFormat:@ProdName=%@,[self applicationName]] stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding] dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]]; [appendedData appendData:[[[NSString stringWithFormat:@ProdVersion=%@,[self productVersion]] stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding]dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]]; Review the info for the application/x-www-form-urlencoded Form content type here: http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4 In brief, you aren't separating your form variables with an character. You're doing this: ProdName=FooProdVersion=Bar whereas you want this: ProdName=FooProdVersion=Bar NSString *dataLength = [[NSString alloc] initWithFormat:@%d, [appendedData length]]; [request setValue:dataLength forHTTPHeaderField:@Content-Length]; I believe this is unnecessary, as it will be calculated automatically from the data passed to -setHTTPBody. Regards, Jason smime.p7s Description: S/MIME cryptographic signature ___ 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: NSOutlineView expand-by-default with NSTreeController
On Dec 5, 2009, at 12:43 PM, Benjamin Rister wrote: I have an NSOutlineView in which I would like to have newly-appearing items be expanded by default. (It would be nice if NSOutlineView had support for this built in; rdar://problem/7421928.) The list archives and a web search reveal a couple hacks to try and make this work, but they depend on feeding the data to the outline view via the NSOutlineViewDataSource protocol so that they can ask for an expansion either at the time of insertion or in response to the outline view asking about the new pieces of data. I’m using NSTreeController, which makes the situation difficult as the actual “items” the outline view knows about aren’t anything I create myself, so I can’t really queue up an expansion of items as I insert them in the model, nor will the outline view ask me about the new data as it’s getting it from NSTreeController. You can get a collection of NSTreeNode instances from your tree controller like this: [[treeController arrangedObjects] childNodes]; Iterate over this collection and find nodes where [node representedObject] is equal to your newly inserted objects. Then you can pass this NSTreeNode instance to -[NSOutlineView exandItem:]. This isn't terribly clean, and it might fall down if you have a large number of items in your tree controller, but it works for what I need and might work for you. Regards, Jason smime.p7s Description: S/MIME cryptographic signature ___ 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: Best way to hook into the run loop?
On Dec 4, 2009, at 7:18 AM, Graham Cox wrote: I'm looking at the docs now, and for this use, it seems I would want kCFRunLoopAfterWaiting to OPEN any undo groups, because that's just before processing an event, but it's a little less clear when I should do the automatic close. Presumably once the event is finished being handled the loop continues, so would kCFRunLoopBeforeTimers effectively represent the end (as well as the very start) of a given event cycle? I think what you say sounds right. A look through the CF sources might provide some enlightenment here too. I would try kCFRunLoopBeforeTimers to see if that works for your use case. Otherwise how would I know when an event has been completely handled? The only other thing that comes to mind would be to create some autoreleased object when you open the undo group which closes the undo group when released, since each cycle of the run loop should drain the autorelease pool. This feels like a hack though, and it of course doesn't work if you need to support garbage collection. Jason smime.p7s Description: S/MIME cryptographic signature ___ 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: Best way to hook into the run loop?
On Dec 3, 2009, at 10:17 PM, Graham Cox wrote: One thing I'd like to do is to match NSUndoManager's ability to automatically open and close groups as the run loop cycles. What's the best way to do this? Possibly by using a CFRunLoopObserver. You can look into CFRunLoopObserverCreate and the related documentation. This will allow you to observe various stages of the run loop cycle. I notice that NSUndoManager has a 'run loop modes' property but it's unclear where and how that is used. The modes are basically filters for which input sources get processed by a run loop cycle. There is a run loop mode used by modal panels and another for mouse tracking. An undo manager could use this mode to avoid (or explicitly allow) registering undos during a mouse drag, for example. Jason smime.p7s Description: S/MIME cryptographic signature ___ 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 Question: Hide application window after minimising
On Nov 20, 2009, at 2:02 AM, Michael Davey wrote: Hi there, This is my first post, so please be gentle ;o) I am writing an application using obj-c/Cocoa and I was curious about something I have seen in another application that I would like mine to be able to do. Basically, when you minimise the application, it's window goes down into the dock as per normal, but once this has been doe it then vanishes from the dock, and does not re-appear. Does anyone know if this is possible within Cocoa and which class docs I need to look at to begin implementing it? In Snow Leopard there is the Minimize windows into application icon preference in the Dock preference pane. The affects all apps though, but has the benefit of having the windows available for the new Dock expose modes. Otherwise, a good place to start looking might be the NSWindow delegate methods. Regards, Jason smime.p7s Description: S/MIME cryptographic signature ___ 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: NSObjectController add: Method RunLoop Deferral
On Nov 2, 2009, at 2:51 PM, Richard Somers wrote: snip I think the problem is with the add: method. The documentation states Beginning with Mac OS X v10.4 the result of this method is deferred until the next iteration of the runloop so that the error presentation mechanism can provide feedback as a sheet. I can not figure out how to work around this. Use the -newObject method to create a new instance, do what you need to do with it, then pass it to -addObject:. Otherwise, defer the work you need to do with the value until the next runloop as well, using -performSelector:withObject:afterDelay:. Jason smime.p7s Description: S/MIME cryptographic signature ___ 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: MutableDictionary setValue:forKeyPath - strange behavior
On Sep 20, 2009, at 1:54 PM, Steve Cronin wrote: Kyle; Thanks for such a speedy response. (and on a Sunday afternoon too!) That code is a fairly complex set of interlocking methods. Why would the construction of this NSMutableDictionary have anything to do with this error? Because the error quite clearly indicates you're trying to mutate an immutable object, so myBaseSettings seems to be not an NSMutableDictionary like you believe it to be, but just an NSDictionary. I believe the reason using a multipart keypath works is that it conceptually ends up doing something like this: [myBaseSettings setValue:@whatever forKeyPath:@foo.bar] = id tmp = [myBaseSettings valueForKey:@foo]; [tmp setValue:@whatever forKey:@bar]; You aren't mutating myBaseSettings in this case, but mutating whatever is stored in foo in myBaseSettings. Whatever *that* is is likely a mutable object, but your myBaseSettings is not. So somewhere in your complex set of interlocking methods it seems you're ending up with an immutable myBaseSettings instead of a mutable one. Jason smime.p7s Description: S/MIME cryptographic signature ___ 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: favicon of address
On Sep 20, 2009, at 1:53 PM, Mitchell Livingston wrote: Hey, I want to get the favicon of a URL address, but don't actually need any of the page's content. Is there an efficient way to do this besides hammering the site for this info? This image isn't critical, so something that works most of the time should be fine. This isnt really a Cocoa question, so you're asking the wrong list. That said, a large majority of sites still store favicons at / favicon.ico, so you can just try to download that URL and hope for the best. Otherwise you have to get the page content and look for the link element that specifies the correct favicon url. See http://en.wikipedia.org/wiki/Favicon Jason smime.p7s Description: S/MIME cryptographic signature ___ 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: getline 'free' problem
On Sep 16, 2009, at 5:41 AM, Aron Nopanen wrote: Hi All, Not a Cocoa problem as such, but not sure if there's a better list for it: For this question, Xcode-users is probably a better list. On Snow Leopard (using gcc 4.2), I'm getting a 'double free' error in the guts of the C++ std::getline. The 'free' in question is being performed by std::string::reserve. This happens any time I run 'getline' (reading from cin) on a fresh, virgin string. (The error is only seen in the Debug configuration.) Try removing these definitions from the preprocessor flags of your Debug configuration: _GLIBCXX_DEBUG=1 _GLIBCXX_DEBUG_PEDANTIC=1 I think there are some issues when those are defined that can cause some unexpected behavior, such as what you're seeing. Jason smime.p7s Description: S/MIME cryptographic signature ___ 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
CGWindowListCreateImage fails on Snow Leopard with kCGNullWindowID
I am attempting to use the CGWindowListCreateImage function to capture a desktop screenshot. The following code (taken straight from the SonOfGrab sample) works on Leopard, but is failing on Snow Leopard: CGImageRef screenShot = CGWindowListCreateImage(CGRectInfinite, kCGWindowListOptionOnScreenOnly, kCGNullWindowID, kCGWindowImageDefault); On Leopard, the returned CGImageRef is what I expect: an image of the desktop and all on-screen windows. On Snow Leopard, the CGImageRef is NULL and the following message is printed to the console: Error: CGImageCreate: invalid image bits/pixel or bytes/row. I have filed a bug (7212104), but wonder if there is a workaround that I can use in the meantime, or if I should just use another method of capturing the desktop. Has anyone else encountered this issue? Thanks, Jason smime.p7s Description: S/MIME cryptographic signature ___ 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: CGWindowListCreateImage fails on Snow Leopard with kCGNullWindowID
On Sep 10, 2009, at 12:34 PM, David Duncan wrote: On Sep 10, 2009, at 7:32 AM, Jason Foreman wrote: CGImageRef screenShot = CGWindowListCreateImage(CGRectInfinite, kCGWindowListOptionOnScreenOnly, kCGNullWindowID, kCGWindowImageDefault); On Snow Leopard, the CGImageRef is NULL and the following message is printed to the console: Error: CGImageCreate: invalid image bits/pixel or bytes/row. Your bug will end up dup'd to rdar://problem/7022171. The basic problem is using CGRectInfinite from a 32-bit process when the Window Server is running as a 64-bit process – when the rect comes out at the other end it is no longer interpreted as infinite but rather as very very large. Since you can't create an image that large, the creation code fails and you get back a NULL CGImageRef instead. The current best work around is to determine a proper bounding box for the desktop and pass it for the given rect. Thanks David, your suggestion works great. I appreciate the quick response. For the benefit of the archives and anyone else having a similar issue, here is how I calculate the bounding box: NSRect desktopRect = NSZeroRect; for (NSScreen *screen in [NSScreen screens]) { desktopRect = NSUnionRect(desktopRect, [screen frame]); } This seems to give me exactly what I want when passed to CGWindowListCreateImage. smime.p7s Description: S/MIME cryptographic signature ___ 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: Scripting Bridge link error
On Sep 9, 2009, at 8:52 PM, Randall Meadows wrote: AdobePhotoshopCS3JPEGSaveOptions *options = [AdobePhotoshopCS3JPEGSaveOptions new]; [...] It compiles fine, but I get this link error: Undefined symbols: .objc_class_name_AdobePhotoshopCS3JPEGSaveOptions, referenced from: literal- poin...@__objc@__cls_r...@adobephotoshopcs3jpegsaveoptions in AMBatchEditMonitor.o ld: symbol(s) not found collect2: ld returned 1 exit status You don't actually instantiate ScriptingBridge objects directly like that. The interface header is generated so you can get type checking when you call methods, but the actual class is acquired dynamically at runtime. See the documentation for -classForScriptingClass: in SBApplication. You'll need to do something more like: AdobePhotoshopCS3JPEGSaveOptions *options = [[psApp classForScriptingClass:@AdobePhotoshopCS3JPEGSaveOptions] new]; Jason smime.p7s Description: S/MIME cryptographic signature ___ 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: Sheets positioning.
On Sep 8, 2009, at 12:53 PM, Brent Smith wrote: Hello I have a new file dialog that pops up as a sheet, hwoever on the first popup of this sheet, Its not positioned below the titlebar http://i29.tinypic.com/2k287p.jpg But if I hit cancel, and then open the dialog again, Its perfect. http://i27.tinypic.com/e9uurl.jpg Any idea what Im doing wrong? You very likely have the Visible at Launch property of your sheet window turned on. Turn this property off in the nib and it should show at the correct location the first time. Jason smime.p7s Description: S/MIME cryptographic signature ___ 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: Continuous NSTextField not updating bound value continuously?
On Sep 8, 2009, at 1:05 PM, Doug Knowles wrote: Hi, I have a text field (two, actually) bound to a string value in a controller object, and I'd like to validate the value on each keystroke so that I can enable other controls appropriately depending on the content of the field. The text fields are set to continuous updating in IB, and I have confirmed this by checking the fields' isContinuous in the code. However, the bound value is not updated on every keystroke, but only when the field loses key status. The only thing that I can think is different between this case and most other uses is that the window is application modal, but I can't think of why that would affect continuous updating. Any thoughts of something else I might be missing? It sounds like you've set the Continuous property of the text field. When using bindings, you need to set the Continuously Updates Value property of the binding in order to get the effect you're looking for. Can you verify that you've set the property on the binding and not just the text field? Jason smime.p7s Description: S/MIME cryptographic signature ___ 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: NSTableView and programmatic changing of contextual menu
On Aug 24, 2009, at 7:44 PM, Kyle Sluder wrote: On Mon, Aug 24, 2009 at 5:39 PM, Jack Carbaughintrn...@aol.com wrote: My question is how do i change the contextual menu when the user right clicks. Override -menuForEvent:. Another way is to implement the - tableView:willDisplayCell:forTableColumn:row: delegate method and assign the cell's menu there. Jason smime.p7s Description: S/MIME cryptographic signature ___ 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: applicationWillTerminate: issue
On Aug 24, 2009, at 10:26 PM, Michael de Haan wrote: -applicationWillTerminate: doesn't magically get called. NSApplication posts this notification to the default notification center. NSApplication also automatically signs its delegate up for this notification. Kyle, from the Cocoa Fundamentals Guide: Although you can dynamically change the delegate, only one object can be a delegate at a time. Thus if you want multiple objects to be informed of a particular program event at the same time, you cannot use delegation. So, if I understand you and the documentation correctly , even though I had implemented the delegate of NSApplication in **both** of my classes, **only** one of those classes will respond to applicationWillTerminate: at a time. If this is indeed correct, then I need to rethink the design of my application, and you have already suggested how to do this. True, only one object can be the application delegate at any one time. However, multiple objects can be subscribed to application notifications, and the notification will be sent to all subscribed objects when it is posted. You should read up on NSNotificationCenter, and on the notifications that NSApplication posts, specifically NSApplicationWillTerminateNotification in your case. Your second object should not set itself as the application delegate, but rather should subscribe to this notification and handle it accordingly. Jason smime.p7s Description: S/MIME cryptographic signature ___ 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: Message from view to viewController
On Fri, May 29, 2009 at 11:18 AM, Pierre Berloquin pie...@berloquin.com wrote: Yes, I did import too many times, but that was in a desperate attempt to import enough!I corrected that and now I have my original error : MyAppViewController may not respond to +manageMyViews which blocks the program You've defined manageMyViews as an instance method: - (void)manageMyViews:(id)sender { but you're trying to call it as a class method: [MyAppViewController manageMyViews] Notice in the warning you get MyAppViewController may not respond to +manageMyViews. The '+' there means it is trying to call that as a class method. You need to create an instance of MyAppViewController somewhere, and call that method on the instance, or redefine the method to be a class method. You may also not have declared that MyAppViewController responds to manageMyViews in the header file. Jason ___ 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 set horizontal scroller for NSTextView?
On Fri, May 29, 2009 at 11:20 AM, archana udupa udupachu...@gmail.com wrote: Hi list... I m new to cocoa. I ve a NSTextview, for which i ve set a scrollerview. I can scroll it vertically.But i wanted to scroll it horizontally also. I ve used [NSScrollView setHasHorizontalScroller:YES]; But i m wondering why its not workingPlease help me..:( http://devworld.apple.com/documentation/Cocoa/Conceptual/TextUILayer/Tasks/TextInScrollView.html#//apple_ref/doc/uid/2938-164652 Jason ___ 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: performSelectorOnMainThread problem SOLVED
On May 28, 2009, at 12:13 PM, Ben Einstein wrote: Thanks for the advice, I had actually tried that as well to no avail. After playing around a bit, I'm fairly certain I've solved it, although I'm not really sure why it was a problem. At the top of the worker method, I was locking the NSManagedObjectContext and unlocking it just before return, but all the NSManagedObject stuff should be happening on a separate thread. I'll try to track that down in a minute, but it appears that was blocking the main thread. I suppose I should have asked Instruments before asking you all. Hi Ben, FYI, sharing an NSManagedObjectContext between threads is discouraged (strongly discouraged according the the docs). The recommended approach is to create separate contexts on each thread, which might help avoid problems like you've just had: http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdMultiThreading.html Jason smime.p7s Description: S/MIME cryptographic signature ___ 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: Newbie question on listing out detailed items
On May 22, 2009, at 5:33 PM, Stamenkovic Florijan wrote: What I want: a listout of items, each of which presents info and a number of controls. Typical example: Safari's downloads window. ... Any pointers to documentation on how to deal with this would be very appreciated. Perhaps I am simply using the wrong terms to search. You might like to check out Joar Wingfors' Subview-Tableview example. I believe it does almost exactly what you want: http://joar.com/code/ There is also AMCollectionView from Andreas Mayer that is similar: http://www.harmless.de/cocoa-code.php Jason smime.p7s Description: S/MIME cryptographic signature ___ 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: Integer as key in NSMutableDictionary
On May 4, 2009, at 2:22 AM, Weydson Lima wrote: I am getting warnings when adding integers in the array and assigning the integer ID as a key. The code does work though, but I am guessing there is a better way to accomplish what I want. I know that these methods are expecting pointers as parameters and I am passing a scalar. So, what's the best way to approach that? Actually, as the documentation specifies, setObject:forKey: expects an object that conforms to the NSCopying protocol as the key parameter. Keys are copied when objects are inserted. You could use an NSNumber, e.g.: [result setObject:... forKey:[NSNumber numberWithInt:ID]]; Jason smime.p7s Description: S/MIME cryptographic signature ___ 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 Data and the Application Delegate
On Apr 23, 2009, at 7:37 PM, Jon Gordon wrote: But I understand (I think) also that, in a Core Data document-based application, the application delegate is set to one provided by Core Data. And in such cases, providing my own delegate breaks Core Data functionality that I'd otherwise get for free. The Core Data Application Xcode template does create an class that is hooked up as the application delegate. However you are certainly free to add code to it or replace it with your own delegate, as long as your delegate also provides the functionality that the generated template delegate does (setting up Core Data stack, etc). The default delegate isn't so much provided by Core Data as it is an default generated for you by Xcode. Jason smime.p7s Description: S/MIME cryptographic signature ___ 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 doesn't this work on my device?
On Thu, Feb 26, 2009 at 3:37 PM, James Cicenia ja...@jimijon.com wrote: Why doesn't this work on the device? Help this is causing me hours of grief with errors like these. What errors? You haven't shown any, just code. Define doesn't work and you'll get better help. if (sqlite3_open([path UTF8String], database) == SQLITE_OK) { Use -fileSystemRepresentation, not -UTF8String. Are you sure the file exists where you think it does? tmp = [tmp stringByAppendingString:[self currentLatitude]]; tmp = [tmp stringByAppendingString:@,]; tmp = [tmp stringByAppendingString:[self currentLongitude]]; tmp = [tmp stringByAppendingString:@) ]; tmp = [tmp stringByAppendingString:miles]; tmp = [tmp stringByAppendingString:@ and state_abbr NOT NULL ;]; -stringByAppendingFormat might clean this up. Jason ___ 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: Needed : set class for Cocoa
You could throw the pointers into NSValue objects and store those in an NS[Mutable]Set.. Jason On Feb 5, 2009, at 5:29 PM, Tommy Nordgren tommy.nordg...@comhem.se wrote: Do anyone know of a set container class for Cocoa objects, that use pointer semantics. Like this: NSMutableString * s1 = [@Hello mutableCopy], * s2 = [@Hello mutableCopy]; Somesetclass *someSet = [[Somesetclass alloc]init]; [someSet add:s1]; [someSet add: s2]; // After these calls, someSet should contain 2 elements because s1 != s2 by pointer semantics -- Home is not where you are born, but where your heart finds peace - Tommy Nordgren, The dying old crone tommy.nordg...@comhem.se ___ 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/jason%40threeve.org This email sent to ja...@threeve.org ___ 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: NIB's owner doesn't get released because of NSArrayController
On Wed, Jan 14, 2009 at 11:58 PM, Vitaly Ovchinnikov vitaly.ovchinni...@gmail.com wrote: Well, OK. I am ready to release all root objects myself. Just tested with subclassed NSView from that NIB - it didn't get released automatically. So I added several -release calls to -dealloc method of my NIB's owner and now it will release everything. But the problem is still there: -dealloc of my view controller didn't get called because array controller still retains it! As I wrote above, I added special killer method that breaks binding and after calling it I can call -release and it will call NIB owner's -dealloc. But this is ugly... It's not clear to me from this response, so just to double check: do you -release the array controller when you -release the view? The array controller is also a top-level object in your nib, so it needs to be released. This will have a similar effect to you calling -unbind..., but is more correct. What you are doing with -unbind is likely leaking NSArrayController instances, so while your NSView will have its -dealloc called, the array controller will not. Jason ___ 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: NIB's owner doesn't get released because of NSArrayController
On Thu, Jan 15, 2009 at 10:04 AM, Vitaly Ovchinnikov vitaly.ovchinni...@gmail.com wrote: - (void) dealloc { // next two lines added after your comment [pView release]; [pArrayController release]; [super dealloc]; } This won't work as you intend, see below for explanation. In the main window controller I do the following: - (void) windowDidLoad { pViewController = [[MyViewController alloc] init]; pCustomView = [pViewController view]; // I will use this view on the main window } - (void) dealloc { [pViewController release]; // this should call -dealloc method of MyViewController, but it doesn't // if I call [pViewController retainCount] here, it returns 1 [super dealloc]; } You are seeing the correct results here. The array controller is still holding a reference to your view controller, so it will not be deallocated at this time. Hope, you got the idea of the code. Array controller is bound to file's owner in NIB, so it holds reference to it and -release doesn't call -dealloc that should release array controller that holds a reference... etc If I remove binding in NIB file, MyViewController's -dealloc is called after -release. I added method to MyViewController that breaks binding and call this method before releasing MyViewController. This helps, but I think there is a better way to do this. After your nib is loaded, your MyViewController will be retained both by the window controller and the array controller that is bound to it. Also remember that -dealloc is not called until the retain count is zero. So your view controller cannot possibly be deallocated while the array controller holds a reference to it. You need to release the array controller somewhere other than the view controller's -dealloc method. You can choose to do this wherever is appropriate for your application. One possibility might be the window controller's -close method. Or you can do it in whatever method you are unbinding the array controller, as you've done already. Just make sure that you do release the array controller so as not to leak it. Jason ___ 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: NIB's owner doesn't get released because of NSArrayController
On Wed, Jan 14, 2009 at 3:51 PM, Vitaly Ovchinnikov vitaly.ovchinni...@gmail.com wrote: Hello all, I have a custom-loaded NIB file with NSView and NSArrayController. Array controller is bound to file's owner (NSObject's derived class) and use some keypath for contentArray. The problem is when I close a window and main window controller tries to release this file's owner - array controller still holds a reference to it and doesn't allow to do that. So I have two questions: 1. What is the correct way to catch closing of the view to unbound array controller? 2. Do I really need to catch something? Maybe there is a simpler solution? Any ideas? Top-level objects in a nib need to be released. You can do this in the File's Owner object when the window is closed, for example. See this page for some additional info on nib object memory management: http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemMgmtNibObjects.html Jason ___ 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: Works in main Thread, but not in background Thread (modified)
Hi John, On Wed, Jan 7, 2009 at 9:01 AM, John Love wrote: NSWorkspace *workSpace = [NSWorkspace sharedWorkspace]; Let me wrap this up by saying when myRoutine is called in my main thread, everything works fine .. but when called by my background thread (via [NSThread detachNewThreadSelector:toTarget:withObject:] it definitely does not work. There was a discussion recently on Twitter of all places regarding the thread safety of various Cocoa classes. Thread safety includes non-main thread usability, and it was determined that many Cocoa classes aren't safe to use on non-main threads. It's possible that NSWorkspace falls into this category. The solution for NSFileManager was to alloc/init a new one on the thread[1], but I'm not sure if that will work for NSWorkspace. Otherwise you're forced to make all those calls on the main thread. Typically, if a class isn't documented as thread-safe, that implies it is only main-thread safe as well. Jason [1] Tweet from Dave Dribin: http://twitter.com/ddribin/status/1097936172 ___ 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: Odd EXEC_BAD_ACCESS after executing URLRequest [SOLVED]
On Wed, Jan 7, 2009 at 9:43 AM, marc hoffman m...@elitedev.com wrote: wow, that was indeed it. odd, i could have /sworn/ i had seen a separate class method in the docs with a shouldStart parameter, and that this one was supposed to not start it. teaches me to trust my memory ;P Well, your memory isn't *that* bad :) There is -initWithRequest:delegate:startImmediately:, but it starts the connection unless you pass NO to startImmediately. The other forms of init for NSURLConnection (including +connectionWithRequest:delegate:) will start immediately. anyways, all working now, thanks a lot! Great! You may want to consider filing a bug with Apple about your case. Seems like -start should be benign on an already started connection, but they can probably at least clear up the documentation about when one can and/or should call -start. The docs say Causes the receiver to begin loading data, if it has not already., but it seems here it caused the data to begin loading a second time, later crashing after the connection was released. Jason ___ 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: Odd EXEC_BAD_ACCESS after executing URLRequest
Hi Marc, On Tue, Jan 6, 2009 at 2:42 AM, marc hoffman m...@elitedev.com wrote: any other ideas? I did notice one thing from your original code: NSURLConnection *conn = [[NSURLConnection connectionWithRequest:request delegate:self] retain]; @try { [conn start]; The way you've allocated the connection, it should start automatically. You shouldn't need to call -start manually. This *might* be causing some issues. The documentation doesn't say not to call it on a connection that is already started, but there might be a bug. Try removing this call to see if it helps at all. Otherwise, it sounds like you've maybe got a memory management issue. Double check all your retains and releases. You may want to try releasing the connection in -connectionDidFinishLoading: rather than where you're releasing it now, though I've never needed to do that before. Jason ___ 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: Odd EXEC_BAD_ACCESS after executing URLRequest
On Tue, Dec 30, 2008 at 10:10 AM, marc hoffman m...@elitedev.com wrote: while (!done) { [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:timeout]]; } Since you want the request to happen synchronously, why not just use +[NSURLConnection sendSynchronousRequest:returningResponse:error:] ? Recursively pumping the run loop like that in the default mode is discouraged. I don't know the specifics of why, but crashes such as you're seeing could be part of it. Jason ___ 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: Sizing text to fit into UITextView
On Mon, Dec 29, 2008 at 1:57 PM, Steve Wetzel stevewet...@mac.com wrote: Is there any easy way to change the size of the font so a string will fit into UITextView? You'll probably want to look at the stuff in the NSString UIKit additions. I believe the category is UIDrawing. There you'll find various methods to determine the best font size for drawing a string in a given rect or with a particular width, etc. Jason ___ 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: Thread crashing problem
On Dec 22, 2008, at 9:42 AM, Ken Tozier wrote: Problem is, I'm a thread noob so have no idea which type of lock is right for my situation. As to @synchronized, Robert Marini seemed to suggest that that was a Leopard-pnly solution. This app has to work on Tiger as well. As a self professed thread noob, make sure you've read this: http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/Multithreading/ You might also be well served to do some research on pthreads, and make sure you understand the synchronization primitives such as semaphores and mutexes. You'll only end up doing bodily harm to yourself and others if you don't understand the basics of threading at a fundamental level. After you've read those, you should realize that, as Kyle points out, your code does not determine when it is safe to run. Instead it should acquire a lock to tell the threading system that it wants to do something (e.g. modify a data structure), and the threading library will let your code run when it is safe to do so (it can acquire the lock). @synchronized is essentially some syntax sugar that wraps a block of code with a lock, so that only one thread can be executing that code at a time. Any code which modifies a shared data structure should be protected by a lock. The lock is there to ensure that only one thread can modify the data at a time. So all your code that modifies the data structure should use a (the same) lock. So to answer one of your questions: yes, make the lock a property of the class--you need to use *the same* lock in each method to ensure proper synchronization. Also, you needn't determine if the lock is locked. Look at the docs for the NSLocking protocol. You'll want to call -[NSLock lock], which will block the calling thread until the lock can be acquired. Your concerns about multiply calling tryLock are only applicable to acquiring a lock recursively, i.e. acquiring the lock again on a thread which already holds it. This is a very simplified account however, so please make sure you understand what you're doing and why--don't just take my word for it (I could be full of it). Threaded programming can be hard and is very easy to get wrong. Good luck! Jason smime.p7s Description: S/MIME cryptographic signature ___ 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 separate the path name from a file name
On Wed, Dec 17, 2008 at 5:52 AM, wamozart mozartco...@gmail.com wrote: Hi, I'm writing an NSDocument class code. I would like to separate the path name from a file name. NSString *filename = [self fileName]; returns the full path and file name. How do I get the path name only? See this section of the NSString doc about working with paths: http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/doc/uid/2154-SW38 Jason ___ 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