Re: Core Data with ODBC databases?
I don’t have a degree in comp sci and, while I program in Cocoa and Rails on a daily basis, it’s not my primary job function, so, I’m sure I don’t fully appreciate a statement like “Core Data has no semantics for asynchronous, failed, or cancelable operations.” I’m not in any way trying to pick a fight with anyone. I want to build an app to help run my small business. I want to provide a way for my employees, who are scattered across the country, to be able to share data to make our business more efficient and more scaleable. A pure Rails app served through a browser seems to be a well-accepted multi-user database solution, allowing thousands to interact with the same set of data simultaneously. It also seems fairly common to use Rails as a back-end for native iOS and OS X apps (hence, the popularity of AFNetworking). The problem seems to be injecting Core Data into that mix. Is that a fair summary? IMO, Core Data makes creating and updating the UI much more straight-forward. And, it makes view controllers thinner. It’s a good fit for the rest of Cocoa. It may be because the only tool I have is a hammer, but fighting to bring Core Data into the picture seems like a worthwhile endeavor. I believe there are two options to use CD locally with a Rails API backend: 1. Manual. Core Data attributes are serialized into JSON objects and sent to the server. JSON comes back and is manually parsed to update affected objects. My understanding is that typically, a MOC on the main thread is backed by a second MOC on a background thread. The backing MOC handles requests to and responses from the server asynchronously and changes bubble up from a managedObjectContextDidSave: notification. Are there serious concerns about this method? Or, is it just the use of NSIncrementalStore that’s at issue? 2. AF/NSIncrementalStore. CD itself may not be asynchronous, but the network calls to the Rails API are asynchronous and cancelable, and, we get notified if they fail. Again, I’m no expert here, but it seems that the introduction of NSURLSession and background fetching along with real time web apps (via something like Rocket.io) improve the situation. If an NSURLSessionDataTask fails, notify the user and rollback the local store. I know there was an issue with the synchronous nature of CD and temporary vs. permanent managedObjectIDs, but AFIncrementalStore seems to have solved this. I’m looking forward to seeing what Matt Thompson does with AFIncrementalStore once the dust has settled on AFNetworking 2.0. On Oct 16, 2013, at 7:46 PM, Kyle Sluder k...@ksluder.com wrote: On Wed, Oct 16, 2013, at 04:26 PM, Alex Kac wrote: Can’t you use NSIncrementalStore to talk with REST services as a backend for Core Data? I remember seeing some articles on this. You can, and many people have tried, but it inevitably fails because Core Data has no semantics for asynchonous, failed, or cancellable operations. https://twitter.com/JimRoepcke/status/301893533860757505 Don't use NSIncrementalStore for remote operations until Apple fixes the API. --Kyle Sluder ___ 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/bradgibbs%40mac.com This email sent to bradgi...@mac.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 Data with ODBC databases?
Flavio responded while I was editing, so, this is just re-iterating some of his points. I’m not sure whether you (Dru) were responding to my post, or just responding to the thread, in general. Using a Rails API-based backend with a PostgreSQL database means that Core Data doesn’t have to scale at all. Postgres and the Rails API need to be scaleable, but, that’s exactly what they’re designed for. Core Data is still a local cache being used by a single user, but instead of persisting to the local disk, it’s persisting to the Postgres server. There are issues there revolving around cache policies, etc., but, I think NSURLSessiion and background fetching will ease a lot of that pain. As for two people making changes to a record simultaneously, it would be handled in the same way a Rails web app would handle it. Rails and Postgres have been designed for this use case. As for large data sets, that’s part of the beauty of the NSIncrementalStore approach. In its purest form, the full data set wouldn’t exist on any one user’s device. Instead, NSIncrementalStore would fetch the data requested by the user from the server, as needed, by firing faults. If NSIncrementalStore worked as advertised, there would be no need to persist the entire data set to a user’s device. Additionally, mobile apps would probably be written for specific uses. Maybe the entire company’s data set is 10GB, but the sales team really only needs access to 1GB of that information and perhaps even less for a mobile app while they’re in the field. I honestly don’t know whether Apple has provided a “complete enough” stub-out with NSIncrementalStore. Mattt and Heroku seem to think so. It seems like there are still some hurdles to overcome with the current implementation of AFIncrementalStore. I’m assuming that Mattt is laying the groundwork in AFNetworking 2.0 first, and will then come back to AFIS, update it for AFN 2.0 and work out some of the remaining kinks. I think there’s a huge need for something like this in SMB. iCloud + Core Data doesn’t serve the purpose, whether it works or not. It took Apple 2+ years to provide any real documentation for NSIS and there’s no sample code from Apple. Maybe that’s because it doesn’t / can’t work, or, maybe it’s just not high enough on their list of priorities. Has anyone seen a non-trivial example of NSIS or AFIS with multiple entities, relationships and a complete CRUD implementation? Not the sample code that’s packaged with AFIS, but something more substantial? On Oct 17, 2013, at 8:23 AM, Andrew Satori d...@druware.com wrote: Actually, there is no reason CoreData can't be used in this manner, but there are things that will have to be dealt with outside of CoreData. How do you deal with two people making changes to the same record concurrently as an example ( this is not an issue exclusive to CoreData, but multi-user design ). How do you deal with scalability issues when you have data sets that start creeping into the 5 or 10gb ranges? But the big one that I see with CoreData powered web apps is something that boils down to a design pattern. In the easiest deployment model, you are looking at using CGI, which means that your server app runs in very short lifecycles and when multiple requests come in you get multiple instances of the same CGI application running and accessing the same CoreData data files at the same time. This is an access model that can be problematical. You can work around it, and honestly, Cocoa makes that fairly easy to do, but it is something that has to be dealt with. The net result is this (IMO, and it is just that Opinion): CoreData is incredibly powerful and a truly fantastic tool well designed and well implemented to meet it's primary goal of serving as a robust data store for Cocoa applications. Though it has many features that enable it to play against larger scale RDBMS platforms for small implementations, it is not a full on RDBMS system. When you start talking server class applications with multi-user access and large datasets, it is time to look beyond the CoreData world. I generally advocate starting in the RDBMS world if a project has any potential to scale beyond CoreData simply because there is not a good migration path from CoreData to something larger. I find this frustrating, because EO was truly revolutionary and even today competes well against similar projects, and it hasn't been actively updated for at LEAST 5 years. Dru On Oct 17, 2013, at 8:05 AM, Brad Gibbs bradgi...@mac.com wrote: I don’t have a degree in comp sci and, while I program in Cocoa and Rails on a daily basis, it’s not my primary job function, so, I’m sure I don’t fully appreciate a statement like “Core Data has no semantics for asynchronous, failed, or cancelable operations.” I’m not in any way trying to pick a fight with anyone. I want to build an app
Re: Core Data with ODBC databases?
Mattt also has a Rack Middleware project called Rack::CoreData that links to a Core Data model and builds out a RESTful web service based on the Core Data model. https://github.com/mattt/rack-core-data and a more comprehensive solution that incorporates AFIS, AFN, Rack::CoreData, Passbook and a bunch of other goodies — Helios. http://helios.io On Oct 17, 2013, at 11:51 AM, Flavio Donadio fla...@donadio.com.br wrote: Dru, [...] if you use CoreData on the server as well, you get into issues where things are a little more complex. Well, this is a path that I'm pretty much convinced that wouldn't work. Almost everyone on this list told me it would be a bad idea. But it would solve the two identical models in different formats problem that I was talking about. And create a lot of other problems, for sure. ;) Best regards, Flavio ___ 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 Data with ODBC databases?
Between background fetches and server-sent events (like Rocket.io , local data is going to be updated more often, and, therefore, in smaller chunks. Instead of logging in after 24 hours of inactivity and needing to fetch everything that has happened in the past 24 hours, your app is going to be fetching small chunks of data all by itself during that 24-hour period and should be more-or-less up-to-date at launch. There could be cases where someone wants to access blueprints or some engineering document that’s several megabytes in size, but those operations could be conducted through an NSURLSessionConfiguration where allowsCellularAccess is set to NO. Optionally, you could add a parameter in the JSON request informing the server that the user is on a cellular network and the server could decide whether they’re requesting too much information for the connection. If a user is trying to access some large data set over a 3G network, you could post an alert informing them it ain’t gonna happen until they get back on wifi. The point is, Rails is as popular as it is largely because it makes assumptions and takes a convention over configuration approach to the most common problems. Maybe something like AFIS can solve 80% of the most common problems elegantly and leave room for devs to solve the remaining 20% on a case-by-case basis. On Oct 17, 2013, at 11:45 AM, Scott Ribe scott_r...@elevated-dev.com wrote: On Oct 17, 2013, at 9:19 AM, Brad Gibbs bradgi...@mac.com wrote: As for large data sets, that’s part of the beauty of the NSIncrementalStore approach. In its purest form, the full data set wouldn’t exist on any one user’s device. Instead, NSIncrementalStore would fetch the data requested by the user from the server, as needed, by firing faults. If NSIncrementalStore worked as advertised, there would be no need to persist the entire data set to a user’s device. Which works fine as long as users have always-on connectivity, with reasonably good bandwidth latency, and the data they need to work with is not too huge. That's not to pick on you or the particular solution, just to point out that one reason that there is not a single good solution in this space is that there is no one-size-fits-all solution simply because there are too many variables to allow that. I think there’s a huge need for something like this in SMB. Agreed. Probably assuming always-on connectivity, since people usually have 3G or 4G. Do a decent job with managing bandwidth demands and controlling the number of requests/responses, and in cases where the bandwidth/latency is not good enough for a decent user experience, oh well... -- Scott Ribe scott_r...@elevated-dev.com http://www.elevated-dev.com/ (303) 722-0567 voice ___ 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/bradgibbs%40mac.com This email sent to bradgi...@mac.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 Data with ODBC databases?
You make some great points, Jens. Yes, the scenario I’m considering is a Rails server, hosted on Heroku, backed by a Postgres database. Regarding your point about Core Data not being atomic: 1. It sounds like a perfectly reasonable and valid argument, but, then, why would Apple release NSIncrementalStore at all? What purpose would it serve? Was it just a mistake on their part? Something they didn’t think through fully? I believe you used to be an Apple employee. I’ve known a couple Apple software engineers and they’re not dumb people, by any stretch. Was this just a complete oversight, or is there some other intended use for NSIS that actually makes sense? 2. To make this more concrete, one of the objects in the app I’m pondering is a Project. The Project has attributes and relationships to other objects, like Phases, Products, LaborEntries, etc. The Project will have an owner (the Project Manager) and there might be one or two others with write access to make changes to a Project. If I’m being wildly optimistic, I may one day have 50 users who can all view some or all of the Project information, but only three of whom may edit it. Say one of the users with write access edits the Project by changing five of its attributes. Before the user is allowed to move to another view to edit a different object or view another Project, he is required to confirm that he wants the changes to be saved. If the save is confirmed, an NSManagedObjectContextDidSave notification fires. At that point, the userInfo dictionary contains a single object — the updated Project in the userInfo’s NSUpdatedObjects dictionary. That Project object is then serialized and POSTed to the server. It’s possible that one of the other two users with write access could be making changes to one of those five fields at the same time. If this happens, whichever save operation happens last wins and this could produce some undesirable consequences if the person who posted the second commit entered incorrect information. BUT, unless both users confirm their changes at precisely the same moment, isn’t it more-or-less equivalent to two transactions where the last one in wins? In other words, if the app is written such that users are forced to commit changes frequently enough, doesn’t it at some point become a transaction? Furthermore, with server-sent events (a la Rocket.io), if two users are editing the same project simultaneously and one commits his changes, the other will be notified of the changes immediately and will know if he is overwriting changes someone else made (seeing a record change while you’re looking at it could take some getting used to…). I can definitely see how this lack of atomicity could cause serious problems if you’ve got 10,000 users with edit permissions and users can make several changes to several objects before committing, but, in this particular use case, maybe it isn’t a big enough issue to throw the baby out with the bathwater? What better options should I look at, instead? My company is three employees strong at the moment and we’re never going to be on the same LAN. I’ve looked at CouchBase, but I’m not sure NoSQL is the right fit. On Oct 17, 2013, at 12:49 PM, Jens Alfke j...@mooseyard.com wrote: On Oct 17, 2013, at 8:19 AM, Brad Gibbs bradgi...@mac.com wrote: Core Data is still a local cache being used by a single user, but instead of persisting to the local disk, it’s persisting to the Postgres server. But not directly, right? You said there was a Rails app in the middle serving up a REST API. As for two people making changes to a record simultaneously, it would be handled in the same way a Rails web app would handle it. Rails and Postgres have been designed for this use case. It’s been a while since I used Rails, but the typical way that a database-driven app manages this is using transactions. Begin transaction, update rows, end transaction. That makes all the updates atomic. But NSIncrementalStore doesn’t have a notion of a transaction, because CoreData doesn’t care about concurrency, because it’s not multi-user. So if your Core Data app makes a bunch of changes, they’re going to be sent to the store, which is going to send them off as individual PUT/POST/DELETE requests. These can’t be handled atomically by the server; they’re independent requests. So they can be interleaved with other updates being made by other clients, causing trouble. Or one of them might fail for some reason, but then there’s no way to back out to a consistent state; more trouble. As for large data sets, that’s part of the beauty of the NSIncrementalStore approach. In its purest form, the full data set wouldn’t exist on any one user’s device. Instead, NSIncrementalStore would fetch the data requested by the user from the server, as needed, by firing faults. If NSIncrementalStore worked as advertised, there would
Re: Core Data with ODBC databases?
Thanks again, Jens, for the lengthy and thoughtful response. I’ve been looking at Couchbase for a couple of years now (wasn’t it initially called Couchbase Mobile?), and I’ve used Blip in the past. Great stuff. I read through some of the Couchbase Lite conceptual documentation. Since we’ve been focusing on conflict resolution, I was particularly interested in that section. Couchbase Lite’s conceptual documentation regarding Conflict Resolution and Revisions doesn’t, at first glance (and after a glass of wine — it’s okay, I’m on the East Coast, where it’s after 7pm), appear to be all that different from NSIncrementalStore’s. From Apple’s NSIncrementalStore Programming Guide: Best Practices: Optimistic Locking Optimistic locking is a mechanism in Core Data that gives the persistent store coordinator the ability to detect when in-memory conflicts occur and also handle when your incremental store detects that another client has made changes the backing store; Core Data manages multiple in-memory snapshots of your data, holding each snapshot inside a managed object context. When you insert, update, or delete managed objects in one context, that change is not reflected in other contexts. This allows you to do work on multiple contexts in different threads simultaneously without worrying about merge conflicts. Merging is deferred until the contexts are saved to the store. At that point, the merge policy you specify is applied by the persistent store coordinator. To facilitate the persistent store coordinator’s in-memory locking mechanism, your store should store a version number for each record in the backing store and increment it every time that record is saved. Detecting conflicts in the backing store is the responsibility of your custom incremental store. A conflict in the backing data store happens when records in the backing data store are changed by another persistent store coordinator or another client. For example, a client could fetch data from a web service and modify it. In the meantime, another client could fetch data from the web service, modify the records, and save. When the first client goes to save, your incremental store compares the optimistic locking version number of the incremental store node and the version number in the backing store and reports the conflict to the persistent store coordinator. The coordinator detects a merge conflict, and applies your merge policy. Optimistic locking failures are encountered when processing a save request inside executeRequest:withContext:error:. To report an optimistic locking failure in the backing data store, constructNSMergeConflict objects for each conflicting object in the save request, set the error parameter, and return nil from the method. You should not attempt to partially fulfill the save request. See theNSMergeConflict Class Reference for more information. The sections that follow I think are also applicable to the conversation: Working with Web Services When you create an incremental store that interfaces with a web service, you must take into account several unique factors: latency, network availability, and conflict management. Use your app requirements, use cases, and the Instruments app to choose what matters most and then profile until your store meets your needs. Threading When fetch and save requests are executed by managed object contexts on different threads, the persistent store coordinator collects the requests into a serial queue and dispatches each request to a single instance of your incremental store in the order in which they were received. Because the persistent store coordinator requires that results be returned immediately (rather than by a deferred callback mechanism), your store must synchronously return data from the backing data store. If your backing data store supports concurrent read and/or write operations, for optimal performance consider using multiple persistent store coordinators when designing your Core Data stack. NextPrevious On Oct 17, 2013, at 4:35 PM, Jens Alfke j...@mooseyard.com wrote: On Oct 17, 2013, at 11:05 AM, Brad Gibbs bradgi...@mac.com wrote: Regarding your point about Core Data not being atomic: 1. It sounds like a perfectly reasonable and valid argument, but, then, why would Apple release NSIncrementalStore at all? What purpose would it serve? It would work well for other _local_ data stores. For example, we’re considering making an NSIncrementalStore adapter for Couchbase Lite, because the programming model for Couchbase Lite is that you work with a local database, which gets synced with a server behind the scenes. Another possibility is if you want to persist to a static file, kind of like the built-in XML store, but maybe with JSON. It could also work well in some kind of constrained network environment, like running on a desktop computer with the server nearby on a LAN. It’s also possible
AVFoundation -- Authorization for Playback of Protected Content?
There's a note in AV Foundation Release Notes for iOS 4.3 that reads: Note that the value of each of these properties is YES even if the associated operation is only conditionally supported. Examples: playable is YES even if the asset has protected content and requires authorization of both the application and the content for playback. You can determine whether an asset has protected content via hasProtectedContent (AVAsset). I can't find anything more on the requires authorization of both the application and the content for playback part. Is this saying that an authorized app, such as iTunes or QuickTime is required to play protected content? Or, is there some way for me to authorize my own AV Foundation-based app and protected content and then play it back in an AVPlayer? Thanks. Brad ___ 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: AVFoundation -- Authorization for Playback of Protected Content?
Thanks for the response. On the desktop, I'd be limited to AppleScript control over iTunes or Quicktime Player X? QTKit can't play protected content, can it? On Apr 17, 2011, at 9:17 AM, Eli Bach wrote: On Apr 17, 2011, at 10:10 AM, Brad Gibbs wrote: Is this saying that an authorized app, such as iTunes or QuickTime is required to play protected content? Yes. Or, is there some way for me to authorize my own AV Foundation-based app and protected content and then play it back in an AVPlayer? Currently, only Apple can 'make' protected content and applications that can play it. Eli ___ 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/bradgibbs%40mac.com This email sent to bradgi...@mac.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
iTunes Scripting Bridge - -fullScreen not working with iTunes 10?
I've been trying [self.iTunesApp setFullScreen:YES] and self.iTunesApp.fullScreen = YES but [self.iTunesApp lastError] always returns NULL, despite the fact that iTunes is not going fullscreen. I've also tried setting the bounds of the main browser window to the frame of the screen, which works, but, it's not the same thing as going fullscreen. I've been testing the command while a video is playing (ie, while cmd-F actually does run iTunes fullscreen). Is -fullScreen broken with iTunes 10, or am I an idiot? (I understand that these things aren't mutually exclusive... ) Thanks. Brad ___ 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
Sample App Similar to Core Data Data Modeler?
Hi, I've been looking for some sample code similar to Core Data's data modeler. I've seen TreeView and I've watched the Crafting Custom Views presentation from WWDC 2010. Both are excellent, but, I'm hoping to find some code that shows views representing data that are connected with lines. I'm hoping to create a custom view that represents a device and has multiple connection points to connect the device's inputs and outputs to inputs and outputs of other devices. Users should be able to move the device views while lines stay connected. Hopefully, the lines are orthogonal. In sum, it's something very similar to the Core Data data modeler. Thanks in advance for any suggestions. Brad ___ 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 Lightweight Migration Woes
Well, that's the way I started doing things, but, on pages 130-131 of the book More iPhone 3 Development (written by Dave Mark Jeff LaMarche -- your co-authors for Learn Cocoa on the Mac) make a point of saying that the new version is the unnumbered version. In some ways, I wouldn't think it would matter. When first created, they're exact replicas, and you can change the names of both of these files. What the compiler(?) is looking for are the version hashes for each of the entities. As long as it can find both the version marked current and another version with entity hashes that match those stored in the data file to be migrated, I would think it would be able to decide which is the old version, and which is the new. My classes are organized into folders on my desktop (and in Git). I pulled all four data models out of folders and put them at the top level of the folder hierarchy. This *seems* to have helped. Although I've still gotten the missing source model error since then, it seems to be happening less frequently. The other thing I did was to create a new set of data while the section of code that merges the second data model in with the main data model was commented out. After the model was created, I uncommented that code and made changes to the first model and everything seems ok. It made me realize that I don't know whether the app is having a hard time finding the source model for the first model, or, if it thinks that there should be two versions of the second model. Since there's only a single version of the second model (.mom), it may be getting hung-up there, although that would seem to be more of a bug than user error. I wish I could submit a simplified version to Apple, but, since I have no idea what's actually causing the problem and I can't seem to replicate it in the little test apps I've been making, I don't know how I'd do that. I do live about 45 minutes from Cupertino. Maybe it's time to pester Chris Hanson at the next NSCoder Night... On Aug 21, 2010, at 7:37 AM, Jack Nutting wrote: On Fri, Aug 20, 2010 at 8:46 PM, Brad Gibbs bradgi...@mac.com wrote: I highlighted the .xcdatamodel and did a Design Data Model Add New Version. That created the Config.xcdatamodeld with an unnumbered version of the datamodel (Config.xcdatamodel) and a numbered copy named Config 2.xcdatamodel. I go into Config.xcdatamodel and add a single string attribute to one entity, Clean and Build Go. I get the missing source model error. I think you're looking at the versioning the wrong way around! The data model with the 2 in its name is the new one, THAT's where you should add new attributes etc. When your app runs, it will find the existing data store which is version 1, both model files (the old one is 1, the new one is 2), and do the conversion for you. I don't have it in front of me, but I think that if you bring up the info window for each of the model files, you'll see that each shows a version number. Core Data will always work to bring lower-versioned data stores up to whatever you've marked as the current version. -- // jack // http://nuthole.com // http://learncocoa.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: Core Data Lightweight Migration Woes
I'm still having some serious issues. I've tried all suggestions from all three responses. One or two of the suggestions worked once or twice, but nothing worked reliably. Is it possible that the dataModel itself is corrupt? I rebuilt it by creating a new data model and copying all of the objects into it. Didn't make a difference. After copying the entities into the new data model and rearranging them, I created the custom classes for each. I've been putting my methods in categories on each of the individual classes so I can quickly delete the custom classes and re-create them after making model changes without having to cut and paste the methods. I ran the app once to confirm that it was working and added some sample data, saved and quit. I highlighted the .xcdatamodel and did a Design Data Model Add New Version. That created the Config.xcdatamodeld with an unnumbered version of the datamodel (Config.xcdatamodel) and a numbered copy named Config 2.xcdatamodel. I go into Config.xcdatamodel and add a single string attribute to one entity, Clean and Build Go. I get the missing source model error. Quincey, you asked about the log for PrototypePath. It's: 2010-08-20 11:44:12.044 IconConfig[86221:a0f] Prototype path is /Users/brad/iconConfigClone/IconConfig/IconConfig/build/Debug/IconConfig.app/Contents/Resources/Config.momd 2010-08-20 11:44:12.046 IconConfig[86221:a0f] Prototype URL is file://localhost/Users/brad/iconConfigClone/IconConfig/IconConfig/build/Debug/IconConfig.app/Contents/Resources/Config.momd/ If I delete the attribute I just added, it compiles and runs. The two versions appear in my target's Compile Sources, but the .xcdatamodeld does not. Could this have something to do with the problems I'm having? Is there some build setting that might be causing this? I don't think there's anything tricky going on with my -managedObjectModel or -persistentStoreCoordinator, but, I'd be glad to post the code. Thanks in advance. This is driving me nuts! Brad On Aug 20, 2010, at 12:28 AM, Jack Nutting wrote: On Fri, Aug 20, 2010 at 8:21 AM, Steve Steinitz stein...@datatactics.com.au wrote: - Removed any stray mopping models, just in case I didn't see your question until you'd already solved it yourself, but I just wanted to highlight this one point; Assumming you're referring here to old .mom files, I'd almost bet money that this is the only thing you needed to do (either manually delete the old file from your target app, or build clean). Like Quincey mentioned, if your app at runtime finds both Model.mom and Model.momd, it will use the former and then either ignore the latter or give you cryptic errors (I forget which). -- // jack // http://nuthole.com // http://learncocoa.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
Core Data Lightweight Migration Woes
I'm still having problems migrating to a new version of my data model. I created a small project to test migration and everything worked smoothly -- so smoothly that trying to get it to fail wasn't easy. But, doing the same sorts of things to migrate to a new version of the data model in my main app is failing all over the place and I have no idea why. I'm using versioning. I use Design Data Model Add Model Version. A new version of the data model is created. I edit the unnumbered data model and make sure it's set as the Current Model Version. To keep things simple, I've been trying to add a single string attribute to a single entity. Build Go and I get: Error Domain=NSCocoaErrorDomain Code=134130 UserInfo=0x2002a29a0 Persistent store migration failed, missing source managed object model. If I delete the attribute that I just added and Build Go again, everything works smoothly. All entities in the model have their own custom classes and several of those custom entities have categories, where I've been keeping the methods. If I'm building a managedObjectModel using -modelByMergingModels, do I need to be doing something differently? My managedObjectModel method is below. I'll post the -persistentStoreCoordinator method, as well, if it would help (adding it to this email puts me over the size restriction). Thanks. - (NSManagedObjectModel *)managedObjectModel { if (managedObjectModel) return managedObjectModel; NSManagedObjectModel *prototypeModel; // create object for prototype model NSString *prototypePath = [[NSBundle mainBundle] pathForResource:@IconConfig ofType:@mom]; if (prototypePath == nil) { prototypePath = [[NSBundle mainBundle] pathForResource:@IconConfig ofType:@momd]; } NSLog(@Prototype path is %@, prototypePath); NSURL *prototypeURL = [NSURL fileURLWithPath:prototypePath]; NSLog(@Prototype URL is %@, prototypeURL); prototypeModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:prototypeURL]; if (!prototypeModel) { NSLog(@prototype model couldn't be found.); } // create object for media resouces model NSString *resourcesPath = [[NSBundle mainBundle] pathForResource:@MediaResources ofType:@mom]; if (!resourcesPath) { return nil; } NSURL *resourcesURL = [NSURL fileURLWithPath:resourcesPath]; NSManagedObjectModel *resourcesModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:resourcesURL]; // create merged model managedObjectModel = [NSManagedObjectModel modelByMergingModels:[NSArray arrayWithObjects:prototypeModel, resourcesModel, nil]]; return managedObjectModel; } ___ 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
MOC Migrations Using .xcdatamodeld
I'm having some real problems performing my first migration. I'm trying to add a single attribute to two entities in my model. I created a new version of the model using Design Data Model Add Model Version. This converted the .xcdatamodel into a .xcdatamodeld with two model versions. I renamed them to v1.xcdatamodel and v2.xcdatamodel. I set the new model as the current version using Design Data Model Set Current Version. I hit Build and Run and I'm getting an error message saying that it can't find the source data model. I found a post by Adam Swift on August 21, 2008, which states: If you want to use a model version bundle (xcdatamodeld) to group versions of your data model, then you need to write code to find the path for the source model, destination model and mapping model, then call the migration manager directly to perform the migration Is this still true? I used the code he provided and was able to make the migration happen, but, it seems like it's going to be a big hassle to update this code each time I make a change to the model that necessitates a new model version. If it makes a difference, I have 4 different models in the project. So, I'm using -modelByMergingModels rather than -mergedModelFromBundle. Thanks in advance. Brad ___ 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 : Multiuser ?
I've been developing an app meant to run strictly on a local network. I'd like to have the capacity to run 50 clients and a single server (although most installations will have fewer than 20 clients). My plan has been to have each client maintain its own Core Data database and sync with the Core Data db on the server. I've been using BLIP to message over TCP. Communication should work like this: 1. Client sends command to server 2. Server updates its CD db 3. On a didSave notification, server messages changes to all connected clients 4. Connected clients receive the update message and update their db's accordingly 5. If a client is offline for a period of time, when it rejoins the network, it asks the server for a batch update (I haven't decided whether this will request the entire data file as it stands at that moment, or just ask for incremental changes since the client's last save, but I'm leaning towards re-sending the entire db, which is typically smaller than 1 MB) In my app, objects are infrequently being created and destroyed. The changes are primarily just attributes of existing objects being updated. I don't believe this runs afoul of the patterns Ben is describing, does it? I'm not sharing the Core Data db, I'm just keeping several Core Data db's in sync by providing methods on the server that each client can call remotely. Also, I attended a session at WWDC this year that describes extending Core Data for use in a multi-user environment. I'd have to watch the video again to get the specifics, but, I think the gist of it was to keep a local copy of the data and sync with the server. I hope rampant speculation about an unannounced OS doesn't run afoul of any NDAs, but, I've got to believe that Apple is working on extending Core Data for use in a multi-user environment. With iPhone, iPad and desktop users and Apple's recent push into SMB, accessing a central database from each of these devices via Core Data just makes too much sense. Maybe it isn't exactly Core Data and maybe it's some tie-in to FileMaker, but, I've got to believe it's a priority for them. It's just too big of a nut to ignore. Brad On Aug 6, 2010, at 11:38 PM, Ben Trumbull wrote: Can more than one process be accessing the same Core Data sqlite file? This post from author Marcus Zarra says no∑ http://forums.pragprog.com/forums/90/topics/1476 But this post from Ben Trumbull seems to say yes, as long as the two processes are accessing it via the same filesystem: http://www.cocoabuilder.com/archive/cocoa/184606-core-data-file-sharing-via-an-afp-alias.html Which one am I misunderstanding? There is a big difference between multiple processes accessing the same Core Data file and multiple machines. Multiple processes on the same local machine work fine. Several Apple products do this. Multiple processes across multiple physical machines will not work well (AFP) or at all (NFS). So we don't recommend targeting a multi-user configuration. As I mentioned in that earlier post, your best bet is probably write the proper service that uses Core Data, and vends to your client processes via IPC (like a web service). The client processes might independently use Core Data for local caching (replication). It possible, but inefficient, for a very limited number of clients to share over AFP. NFS doesn't work correctly at all. This is restricted by file caching issues underneath us. There are a lot of limitations and sharp edges here, so we actively recommend against multiple computers simultaneously accessing the same db. Support for it is disabled by default for projects built with a deployment target = 10.6 - Ben ___ 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/bradgibbs%40mac.com This email sent to bradgi...@mac.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: Core Data : Multiuser ?
It's Session 117 - Building a Server-Driven User Experience. About half-way through they move to a discussion involving Core Data. It's clear that at least some people at Apple have spent some time thinking about this. On Aug 7, 2010, at 8:53 AM, Hunter Hillegas wrote: Which session are we talking about? I'd like to go watch that video and I don't recall seeing it. As for the second bit, I'm not so sure... If they had wanted to port EOF they would have just ported EOF. Of course, I could be wrong but I'm not holding my breath for robust, multi-user Core Data. Hunter On Aug 7, 2010, at 8:43 AM, Brad Gibbs wrote: Also, I attended a session at WWDC this year that describes extending Core Data for use in a multi-user environment. I'd have to watch the video again to get the specifics, but, I think the gist of it was to keep a local copy of the data and sync with the server. I hope rampant speculation about an unannounced OS doesn't run afoul of any NDAs, but, I've got to believe that Apple is working on extending Core Data for use in a multi-user environment. With iPhone, iPad and desktop users and Apple's recent push into SMB, accessing a central database from each of these devices via Core Data just makes too much sense. Maybe it isn't exactly Core Data and maybe it's some tie-in to FileMaker, but, I've got to believe it's a priority for them. It's just too big of a nut to ignore. ___ 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: Error 134100 - Core Data models incompatible
Seriously? I let people know which versions of the OSes I was running, but I don't see how this problem has anything to do with an NDA, unless it's a bug in the dev tools. Core Data for the iPhone OS has been available for many moons now, and, for all intents and purposes, this appears to be an issue with Core Data. Furthermore, I have the dev tools for OS 4 installed, but, obviously, that's not what I'm running on the iPad, since the iPad doesn't support anything newer than 3.2, which is not under NDA. On May 20, 2010, at 4:33 PM, eric dolecki GMail wrote: Well said. Sent from my iPad On May 20, 2010, at 6:54 PM, Fritz Anderson fri...@manoverboard.org wrote: On 20 May 2010, at 4:13 PM, Brad Gibbs wrote: Mac OS X 10.6.2, iPhone OS 4.0 beta 2 (although the iPad client started life before the first OS 4 beta was released). And here is why you won't get any answers. The NDA you agreed to in order to get the 4.0 SDK forbids you, and anyone who knows the answer, to discuss it in public. The penalties can be draconian. If you have access to prerelease software, you have access to the Apple Developer Forums behind your login at developer.apple.com/iphone. Try there. — F ___ 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/edolecki%40gmail.com This email sent to edole...@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
Error 134100 - Core Data models incompatible
Hi, I'm writing an iPad app with an OS X-based configuration utility. The user enters data in the OS X-based config utility and exports it. The iPad then picks up the SQLite file and uses it as its persistent store. This was working fine 2 months ago. I took a break on the iPad app to make some changes to the config utility. After making changes to the data model used for the export, I deleted the data model in the iPad client app and copied the export data model from the config utility to the iPad app. Now, i'm getting the dreaded Cocoa error 134100 - the model used to open the store is incompatible with the model used to create the store. I've logged the metadata from the export store's persistent store and the persistent store the iPad client is trying to use. They're identical. Any ideas on what's causing the problem or how to troubleshoot this? Mac OS X 10.6.2, iPhone OS 4.0 beta 2 (although the iPad client started life before the first OS 4 beta was released). I only have one version of the data model. Thanks in advance. Brad ___ 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
[iPhone] Nested UIViewControllers, InterfaceOrientation Rotation
I've done some reading and some testing, but can't seem to make this work properly -- ie, I can't get a nested VC's interfaceOrientation property to update to the current interfaceOrientation of the device. I've got a main UIViewController with code to support a toolbar with buttons across the top of its view and another toolbar and buttons across the bottom. In the middle of the screen is a view, called oTargetView, which is owned by the main UIViewController. The buttons on the toolbars launch other view controllers with views to occupy the middle of the screen -- their views are loaded into oTargetView. Rotation is a problem. oTargetView autorotates and I can even get the views of the subview viewControllers to resize to fit oTargetView, but these subview viewControllers' interfaceOrientation properties don't seem to change. interfaceOrientation is a read-only property, but, I thought that manually passing the willRotate and didRotate down to the subview viewControllers would cause the subview viewController to update its interfaceOrientation property. This doesn't seem to be the case. The logs show that an interfaceOrientation call to the subview viewController always returns 1, whether it's made in the willRotate method, in the didRotate method or, even in a separate method. Is this the case? Or, am I doing something wrong? If this is the case, does it mean that I can't rely on the subview VC's interfaceOrientation property? Do I just bypass this and make changes based on toInterfaceOrientation in willRotate and fromInterfaceOrientation in didRotate? Or, should I be using one of the other hacks out there (ie, relying on deviceOrientation notifications, or releasing and re-instantiating the subview VC on each rotation)? FWIW, this seems like something Apple needs to fix in OS 4.0. Sending these calls to a single UIViewController seems to work for an iPhone app, but, the iPad has so much more screen real estate that it doesn't seem reasonable to not have nested VC's. ___ 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: iCal-style NSTextFields
I've been working through this a bit more. To get bindings to work, I added the following to my custom textfield: if (!bindingsDict) { self.stringValue = newStringValue; } if (bindingsDict) { NSString *boundObject = [bindingsDict valueForKey:@NSObservedObject]; NSString *boundKeyPath = [bindingsDict valueForKey:@NSObservedKeyPath]; [boundObject setValue:newStringValue forKeyPath:boundKeyPath]; } [self.window endEditingFor:self]; There's a lot more to mimicking the look of iCal / AddressBook editing, though. Both apps use attributed strings, and the text fields and borderless windows are sized to fit the attributed string (or the attributed placeholder string, if no string has been entered). If the string being entered will exceed the width of the window that popped up, the window will begin to grow to accommodate the additional letters, and will push text in the main window to the side to make room once the enter button is pressed. AddressBook-style editing with the plus and minus buttons to add or remove fields is also not insignificant. On Jan 13, 2010, at 2:23 PM, Josh Abernathy wrote: This sounds more like a CoreData or general controller problem than anything specific to iCal-style text fields. You might want to create a new thread for this. On Jan 13, 2010, at 11:44 AM, Brad Gibbs wrote: I'm trying to implement this. I created a custom NSTextField subclass, called ICNTextField. When an ICNTextField instance receives a mouseDown event, it initializes a custom NSWindow subclass with a borderless window mask. In the window subclass, I've overridden -canBecomeKeyWindow: so that it always returns yes. When ICNTextField receives the controlTextDidEndEditing notification, it takes the string value from the text field in the borderless window and displays it properly, but the Core Data attribute to which the original text field is bound does not update its value. I've looked into endEditing and endEditing:, nextKeyView and various forms of commit, but can't seem to find a way to get the bindings to recognize the new string value. I'd like to do this in a generic fashion, so I can make any text field an ICNTextField and know that its bound attributes will be updated without having to write additional code for each text field. Any help would be appreciated. On Jan 10, 2010, at 2:54 PM, Josh Abernathy wrote: If you're asking about the shadow, create a child window and move them to that when they're editing. On Jan 10, 2010, at 11:56 AM, Seth Willits wrote: On Jan 10, 2010, at 11:49 AM, Ulai Beekam wrote: Go into iCal (in Snow Leopard) and create a new event and and then click outside that event. Then double-click on that event and hit the Edit button. In the window you see, you have some neat looking text fields that show only text when not in focus but show you a white background with a shadow effect when in edit mode. How can I make such text fields? Does anyone happen to have them ready-made? They're just text fields. Change the background color, turn off the border, and make them read-only when not in edit mode. -- Seth Willits ___ 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/joshaber%40gmail.com This email sent to josha...@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/bradgibbs%40mac.com This email sent to bradgi...@mac.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/joshaber%40gmail.com This email sent to josha...@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: iCal-style NSTextFields
I'm trying to implement this. I created a custom NSTextField subclass, called ICNTextField. When an ICNTextField instance receives a mouseDown event, it initializes a custom NSWindow subclass with a borderless window mask. In the window subclass, I've overridden -canBecomeKeyWindow: so that it always returns yes. When ICNTextField receives the controlTextDidEndEditing notification, it takes the string value from the text field in the borderless window and displays it properly, but the Core Data attribute to which the original text field is bound does not update its value. I've looked into endEditing and endEditing:, nextKeyView and various forms of commit, but can't seem to find a way to get the bindings to recognize the new string value. I'd like to do this in a generic fashion, so I can make any text field an ICNTextField and know that its bound attributes will be updated without having to write additional code for each text field. Any help would be appreciated. On Jan 10, 2010, at 2:54 PM, Josh Abernathy wrote: If you're asking about the shadow, create a child window and move them to that when they're editing. On Jan 10, 2010, at 11:56 AM, Seth Willits wrote: On Jan 10, 2010, at 11:49 AM, Ulai Beekam wrote: Go into iCal (in Snow Leopard) and create a new event and and then click outside that event. Then double-click on that event and hit the Edit button. In the window you see, you have some neat looking text fields that show only text when not in focus but show you a white background with a shadow effect when in edit mode. How can I make such text fields? Does anyone happen to have them ready-made? They're just text fields. Change the background color, turn off the border, and make them read-only when not in edit mode. -- Seth Willits ___ 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/joshaber%40gmail.com This email sent to josha...@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/bradgibbs%40mac.com This email sent to bradgi...@mac.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: Core Data Bindings: NSFaultingMutableSet...addObserver...notSupported
Thanks for the pointers, Quincey. I tried a few of the things you suggested, but settled on the filter predicate. I added my view controller for the projects detail view as an observer to self.selections.account. Each time the selected account changes, I set the filter predicate to filter the list of projects to show only the projects for the newly-selected account. Everything seems to be working fine, now. Thanks again. Brad On Dec 30, 2009, at 12:44 PM, Quincey Morris wrote: On Dec 30, 2009, at 10:12, Brad Gibbs wrote: Account ---ProjectSite---Project I'm trying to get the projects array controller to load all projects for the selected Account (so, all Projects for all ProjectSites). I've got an NSTableView listing accounts on the left, and view controllers to display detail table views to the right. One of the detail table views lists all ProjectSites for the selected Account. That's working fine. Another detail table view should list all Projects for the Account, but I can't get the Projects array controller to bind to the selected Account. These methods list all projects for the selected Account: NSLog(@Projects for account are %@, [self.selections.account valueForKeyPath:@projectSites.projects.displayName]); NSLog(@All projects for account are %@, [[self.selections.account allProjectsForAccount] valueForKey:@displayName]); But, I can't translate that into the proper ContentSet binding for the Projects AC. I've tried every combination I could think of, including: 1. creating an Object Controller for the selectedAccount and binding the Project's ContentSet to that controller with projectSites.projects 2. creating an Array Controller for the selectedAccount's ProjectSites and binding to that 3. creating a managedObject subclass for Project with a method that returns [self valueForKeyPath:@projectSites.projects] and binding the projects AC's contentSet to that property 4. using combinations of @distinctUnionOfSets Basically, there are two usual ways you use an array controller: 1. In entity mode, where its contentSet binding is bound to a Core Data (set) property of a data model object. It's going to use *all* the objects of the configured Core Data entity, unless you use a filter predicate or a fetch predicate, or unless you actually use a transient property that you've coded to fetch only some of the objects. You *could* use this for your projects list, but you'd have to write code to maintain a suitable filter predicate or fetch predicate or transient property, based on the selected account. 2. In class mode with a source array, where its contentArray binding is bound to a non-Core Data (array) property of a data model object. It's up to you to maintain that data model array property KVO-compliantly, or the binding won't update reliably. See: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/CocoaBindingsRef/BindingsText/NSArrayController.html So I think you'll need to: -- bind accountsArrayController's contentSet binding to your data model object's accounts property -- bind projectSitesArrayController's contentArray binding to accountsArrayController.selection.projectSites -- bind projectsArrayController's contentArray binding to projectsitesarraycontroller.arrangedobjects.projec...@distinctunionofarrays (because you said all projects for the account, not all projects for the selected sites) With these bindings (if I've got them right), only the first array controller is in entity mode. So, you cannot use projectSitesArrayController or projectsArrayController to create or delete objects directly. If you have + and - buttons for them your interface, their action methods need to be in (say) your document or window controller class, and you have to write code to create suitable objects and relationships. Your references, above, to selections and allProjectsForAccount methods suggest that you've been trying to solve the problem by adding custom properties to your NSManagedObject custom subclasses. The problem *is* solvable that way, but you have to be careful to distinguish non-Core Data custom properties, which are arrays, from Core Data custom (i.e. transient) properties, which are sets. And, you have to make sure you get KVO-compliance right -- not always easy. And, when you're using Core Data you have to be careful that you don't mess up undo using non-Core Data custom properties. ___ 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/bradgibbs%40mac.com This email sent to bradgi...@mac.com
Core Data Bindings: NSFaultingMutableSet...addObserver...notSupported
Hi, I'm trying to bind through a keyPath, but I'm getting nothing but errors. The most common is: [_NSFaultingMutableSet 0x200267fe0 addObserver:forKeyPath:options:context:] is not supported. Key path: projectCode I've read that bindings don't necessarily cause faults to fire, but I've got to believe there's some way to make this work. I've been working on this for a few hours, I've looked through Core Data and KVO/KVC documentation, Googled and searched through the list. I may have read the answer without realizing it... My data: Account ---ProjectSite---Project I'm trying to get the projects array controller to load all projects for the selected Account (so, all Projects for all ProjectSites). I've got an NSTableView listing accounts on the left, and view controllers to display detail table views to the right. One of the detail table views lists all ProjectSites for the selected Account. That's working fine. Another detail table view should list all Projects for the Account, but I can't get the Projects array controller to bind to the selected Account. These methods list all projects for the selected Account: NSLog(@Projects for account are %@, [self.selections.account valueForKeyPath:@projectSites.projects.displayName]); NSLog(@All projects for account are %@, [[self.selections.account allProjectsForAccount] valueForKey:@displayName]); But, I can't translate that into the proper ContentSet binding for the Projects AC. I've tried every combination I could think of, including: 1. creating an Object Controller for the selectedAccount and binding the Project's ContentSet to that controller with projectSites.projects 2. creating an Array Controller for the selectedAccount's ProjectSites and binding to that 3. creating a managedObject subclass for Project with a method that returns [self valueForKeyPath:@projectSites.projects] and binding the projects AC's contentSet to that property 4. using combinations of @distinctUnionOfSets I've seen posts with others having similar problems, but none of their solutions seem to be working for me. Any help would be greatly appreciated. Thanks. Brad ___ 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
Does NSData rearrange the order of bits?
Hi, I'm doing bit-packing via a C function. Logging the bits of the C function shows the expected result. If I create a string with a hex value format, I get the correct hex string, but, if I try to put the bytes into an NSData object with [NSData dataWithBytes: length], the order of the bits changes. All of the right elements are there, but they're in the wrong order (target data should be f651, as shown in the Target string is ... log). My code: // get the target int from the text field unsigned int tgtValue = [self.tgtTF intValue]; // use the target int and type to pack the bits into an int uint32_t tgtBinary = setAnalogValueForIndex(cid, tgtValue); NSString *tgtString = [NSString stringWithFormat:@%x, tgtBinary]; NSData *tgtData = [NSData dataWithBytes: tgtBinary length: sizeof(tgtBinary)]; NSLog(@Target data is %...@. Target string is %@, tgtData, tgtString); The logs: 011001010001 2009-11-30 11:02:26.126 CertTest[11959:a0f] Target data is 510600f0. Target string is f651 2009-11-30 11:02:26.204 CertTest[11959:a0f] After adding target, cmdData is 510600f0 If NSData is rearranging the bits, is there some way to prevent this? Thanks. Brad ___ 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: Does NSData rearrange the order of bits?
I guess it is. I had another issue that was preventing the code from working properly. Another list member mailed me an explanation offline, causing me to look for and find the real problem preventing my code from running. Thanks for the response. On Nov 30, 2009, at 12:22 PM, Jens Alfke wrote: On Nov 30, 2009, at 11:27 AM, Brad Gibbs wrote: I'm doing bit-packing via a C function. Logging the bits of the C function shows the expected result. If I create a string with a hex value format, I get the correct hex string, but, if I try to put the bytes into an NSData object with [NSData dataWithBytes: length], the order of the bits changes. All of the right elements are there, but they're in the wrong order (target data should be f651, as shown in the Target string is ... log). ... 2009-11-30 11:02:26.126 CertTest[11959:a0f] Target data is 510600f0. Target string is f651 Isn't this the expected byte ordering for a little-endian CPU like x86? The least-significant byte of an integer appears first. —Jens ___ 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
Looking for PCI card with IR transmitter ports and OS X drivers
Hi, I couldn't find a dedicated hardware list, so, I thought I'd post this here. I've Googled this several times over the past year or so, but can't find anything relevant. I'm looking for a PCI card or even a USB or firewire device with 3.5mm ports for IR transmitters (or bugs or eyes) and OS X drivers. Not an IR blaster, like iRed, but a programmable card with 3-6 or more ports for IR bugs. There are several PCI cards with serial (RS-232) ports and I've got to believe someone makes an IR card with OS X drivers, but I can't find it. If anyone has any information on this, I'd really appreciate it. Thanks. Brad ___ 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: keyPathsForValuesAffectingValueForkey: not updating immediately
I don't think there's anything wrong with the method -- I've used it successfully in other apps and have seen it work in Apple sample apps, it just isn't working in this particular case. I'm sure that there's something wrong on my end. Just looking for a little help in figuring out what that could be... In IB, I have the text fields bound to the model as follows: self.mSelectedProjectSite.address.streetAddress In the Address category, I have: - (NSString *)fullAddress { return [NSString stringWithFormat:@%@, %@, %@ %@, self.streetAddress, self.city, self.state, self.zipCode]; } - (NSSet *)keyPathsForValuesAffectingValueForFullAddress { return [NSSet setWithObjects:self.streetAddress, self.city, self.state, self.zipCode, nil]; } I've also tried: - (NSSet *)keyPathsForValuesAffectingValueForFullAddress { return [NSSet setWithObjects:@streetAddress, @city, @state, @zipCode, nil]; } On Oct 26, 2009, at 7:43 PM, Jim Correia wrote: On Mon, Oct 26, 2009 at 10:03 PM, Brad Gibbs bradgi...@mac.com wrote: I did read the documentation, which is why I used +keyPathsForValuesAffectingFullAddress. I also tried +keyPathsForValuesAffectingValueForFullAddress: Both methods work, but only after changing the view and then coming back to it. +keyPathsForValuesAffectingKey is not fundamentally broken - I use it on my NSManagedObject subclasses as needs dictate. At this point, I think we need more information to help. At the very least, let's see your implementation of + keyPathsForValuesAffectingFullAddress. - Jim ___ 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: keyPathsForValuesAffectingValueForkey: not updating immediately
Thanks for the pointers. I need to learn to rely on the debugger more than log messages. It also turns out that I had the method wrong. Although + (NSSet) keyPathsForValuesAffectingValueForkey: doesn't create any errors, it doesn't get called. The ValueFor near the end of the method is extraneous and causes the method not to get called. I could swear I copied that from the Departments Employees sample app. In any case, everything is now working as expected and I learned a few important lessons. Thanks again. Brad On Oct 27, 2009, at 8:59 AM, Jim Correia wrote: On Tue, Oct 27, 2009 at 11:39 AM, Brad Gibbs bradgi...@mac.com wrote: I don't think there's anything wrong with the method -- I've used it successfully in other apps and have seen it work in Apple sample apps, it just isn't working in this particular case. I'm sure that there's something wrong on my end. Just looking for a little help in figuring out what that could be... We are at the point where we can't offer useful advice without seeing your code. Since +keyPathsForValuesAffectingKey is not fundamentally broken, the most likely cause is a problem with your code. - (NSSet *)keyPathsForValuesAffectingValueForFullAddress { return [NSSet setWithObjects:self.streetAddress, self.city, self.state, self.zipCode, nil]; } This is wrong for 2 reasons. Reason #1 - see below. Reason #2 - you should be passing the literal key paths which affect the value, not self.streetAddress which is the current value of that key path. I've also tried: - (NSSet *)keyPathsForValuesAffectingValueForFullAddress { return [NSSet setWithObjects:@streetAddress, @city, @state, @zipCode, nil]; } +keyPathsForValuesAffectingKey should be implemented as a class method. (That's what the + prefix means.) You've implemented it as an instance method. Change it to a class method and you should find that it works correctly. (If you set a breakpoint on your code as written, you'll find that it is never called, which should be a warning sign to you that something is wrong.) - Jim ___ 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
keyPathsForValuesAffectingValueForkey: not updating immediately
Hi, I have a Core Data app with a category on a model object, Address. The category has a method to return a fullAddress property, which is composed of the streetAddress, city, state and zipCode. Updating one of the dependent properties only updates the fullAddress property after I've switched views. I've tried saving the context and reloading the view programmatically, but neither method works. All of the text fields for the dependent keys are set in IB to continuously update values. Is there any way to get fullAddress to update to reflect changes immediately? Thanks. Brad ___ 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: keyPathsForValuesAffectingValueForkey: not updating immediately
I did read the documentation, which is why I used +keyPathsForValuesAffectingFullAddress. I also tried +keyPathsForValuesAffectingValueForFullAddress: Both methods work, but only after changing the view and then coming back to it. On Oct 26, 2009, at 6:27 PM, I. Savant wrote: On Oct 26, 2009, at 9:07 PM, Brad Gibbs wrote: I have a Core Data app with a category on a model object, Address. The category has a method to return a fullAddress property, which is composed of the streetAddress, city, state and zipCode. Did you read the documentation for this method? Note: You must not override this method when you add a computed property to an existing class using a category, overriding methods in categories is unsupported. In that case, implement a matching +keyPathsForValuesAffectingKey to take advantage of this mechanism. -- I.S. ___ 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
NSToolbarGroupItem not showing labels of subitems
Hi, I'm trying to create a toolbar with NSSegmentedControl as a custom view for an NSToolbarItemGroup in 10.6, but I can't get the labels for the subitems to appear. I added an NSSegmentedControl to the toolbar item in IB and set images in the segmented control in IB. I did not give the NSToolbarGroupItem a label. I added the following code to my appDelegate (oProjectsGroup is an IBOutlet, which is bound to the NSToolbarGroupItem in IB): - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Insert code here to initialize your application NSToolbarItem *item1 = [[[NSToolbarItem alloc] initWithItemIdentifier:@Item1] autorelease]; NSToolbarItem *item2 = [[[NSToolbarItem alloc] initWithItemIdentifier:@Item2] autorelease]; [item1 setImage:[NSImage imageNamed:@Activities]]; [item2 setImage:[NSImage imageNamed:@Projects]]; [item1 setLabel:@Prev]; [item2 setLabel:@Next]; [oProjectsGroup setSubitems:[NSArray arrayWithObjects:item1, item2, nil]]; for (id item in [oProjectsGroup subitems]) { NSLog(@label is %@, [item label]); } } The console displays the labels, so, apparently, the labels are being set, but they do not appear beneath their respective segments in the running app. I've looked through the documentation and a list thread both of which seem to indicate that my code should be working Any help would be appreciated. Thanks. Brad ___ 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
Address Book-style editing
Hi, I'm trying to re-create Address Book's editing style - if a user pushes a button labeled Edit, subsequent clicks on a label bring up what looks like a separate view for the new information. Clicking return after editing commits the edit and moves on to the next field. I'd also like to be able to have the plus and minus signs next to phone numbers, email fields, etc. I don't see a stock Cocoa / AppKit way to do this. Does anyone know of a public framework that mimics this behavior? Short of that, any ideas on how to re-create the editing field that pops up? Thanks. Brad ___ 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
Easy Question re NSWindowController
I've done some testing, but I just can't make this work... I have an NSWindowController that manages a pop-up window and a button in the main window that launches the pop-up window when it's pressed. I need to pass a managedObjectContext to the window controller. If I create the NSWindowController programmatically with a custom initializer: NSWindowController *myWindowController = [[NSWindowController alloc] initWithWindowNibName:@MyWindow moc:self.managedObjectContext]; everything works fine. I can also pass the managedObejctContext separately without breaking anything. But, things fall apart when I try to add the window controller to the main window's nib. Once I add an object for the window controller in the main window's nib and set its class to NSWindowController, the app uses NSWindowController's designated initializer, initWithWindow to initialize the window controller. By default, NSWindowController contains an outlet for its window. If I connect the NSWindowController's window outlet to the pop up window and add an NSLog to the initWithWindow method asking for NSWindowController's self.window, it comes back null and the window doesn't load. It seems like the connection in the pop up window's nib file from File's Owner (the NSWindowController) outlet to the window is not being honored. Even if I create another outlet (oWindow), connect it to the window controller and try to set it in initWithWindow with: - (id)initWithWindow:(NSWindow *)window { if (self == [super initWithWindow:self.oWindow]) { //NSLog(@Window is %@, self.window); NSLog(@MOC is %@, self.mMainManagedObjectContext); self.window.title = @New Account; } return self; } it fails. How can I make this work? Thanks. Brad ___ 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
Multi-User DB That Talks to Core Data?
I'm trying to meet the following requirements: 1. Back-end multi-user database to manage products, contacts, projects, inventory, etc. 2. Ability to access and edit that DB over the Internet and the iPhone 3. Ability to import/export some data in the main database to/from a single-user Core Data app Filemaker seems like the easiest route to achieving 1 2, but I'm not sure how well it interacts with Core Data. I don't have any experience with SQL databases, but I have seen mention of BaseTen, although only people recommending it -- I haven't seen posts from anyone claiming to use it. I've also looked into Ruby on Rails and RubyCocoa, but I'm not sure how well the importing / exporting would work. I'd appreciate any suggestions for the most reliable and most direct route for interactions between single-user Core Data-based apps and a multi-user back-end. Thanks. Brad ___ 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: Multi-User DB That Talks to Core Data?
I understand that Core Data is an object graph management tool, rather than a database. I'm trying to create a single-user app that uses Core Data, but gets the data for its object graph from a multi-user database app. For instance, product information stored in the main database app could be exported to a catalog in the Core Data-based app. The user can build a system in the CD-based app and the built system can be imported back into the main database. On Aug 14, 2009, at 9:49 AM, Kyle Sluder wrote: Core Data is not a database. You will want to look elsewhere (though you might be able to use Core Data to keep track of an in-memory object model). --Kyle Sluder ___ 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: Multi-User DB That Talks to Core Data?
Actually, I wouldn't mind sending the relevant portion of the persistent store over the network. The database is an in-house app that many people will need to be able to work in simultaneously. We'll use that database to create products and packages and to update pricing and information. That data needs to be sent to the Core Data client. The Core Data-based app is something we'll give to perspective customers, loading it onto their computer when the time is right. Only one user at a time will access that software, and we won't need access to the information until the client is done with it (maybe a week or two later). Then, we'll import the system they've built back into the main database app. So, transfers might happen a few times per month and they can all be done over a local network. Making the client app would be much easier using Core Data (and, I've already actually started working on it). On Aug 14, 2009, at 10:13 AM, Kyle Sluder wrote: On Aug 14, 2009, at 10:02 AM, Brad Gibbs bradgi...@mac.com wrote: I'm trying to create a single-user app that uses Core Data, but gets the data for its object graph from a multi-user database app. For instance, product information stored in the main database app could be exported to a catalog in the Core Data-based app. The user can build a system in the CD-based app and the built system can be imported back into the main database. Like I said, you're going to want to look elsewhere. Core Data doesn't support the pattern you want, unless you're willing to send the entire persistent store over the network for each read and write. All custom store types mist be atomic. You might want to consider using Core Data on the backend and presenting a custom interface to clients (a la Web Services, or a RESTful interface). Then if it makes sense the client can use an in- memory store, hooking into Core Data notifications to perform it's updates. But at that point you might just want to serialize NSDictionaries over the wire. --Kyle Sluder ___ 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: Giving the Root Object of an Outline View a Different Background Color.
Apple has a sample app called DragNDropOutlineView that's helpful when getting comfortable with outline views. Also, Jonathan Dann has two useful outline view sample apps -- one to show sorting with Core Data and another that animates the expansion of a root object to reveal its contents (Animating Outline View). His site is http://espresso-served-here.com/ On Aug 8, 2009, at 10:04 AM, Quincey Morris wrote: On Aug 8, 2009, at 08:30, Joshua Garnham wrote: I am looking for some code to make the root object's in an outline view have a different background color to the other rows. I am pretty sure I need to sub-class the outline view but I don't know what code to add to the sub-class to do what I want it to do (which is what I described above). There shouldn't be any need to subclass the outline view -- you will most likely be able to set the desired background color in outlineView:willDisplayCell:forTableColumn:item: (and/or outlineView:willDisplayOutlineCell:forTableColumn:item:). Another possibility, if it's important that the top level object rows need to look different but it's not crucial that you use a specific background color, is to implement outlineView:isGroupItem: (another delegate method), which gives group rows a distinctive look. ___ 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/bradgibbs%40mac.com This email sent to bradgi...@mac.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
***SOLVED*** Re: NSArrayController Managing / Sorting NSManagedObjects
I found some sample code that addresses this: http://shanecrawford.org/2008/37/sorting-a-coredata-backed-nsarraycontroller/ On Aug 7, 2009, at 2:50 PM, Brad Gibbs wrote: Hi, I have an NSTableView that displays a set of Activity objects, which are subclasses of NSManagedObject, all of which are managed by a custom NSArrayController. Each Activity has a sortIndex property, which is used to... wait for it... sort the activities. The array controller adds logic to update the sortIndex as objects are added, removed or re-ordered. It's this last part that's giving me grief. The table supports drag-and-drop. The idea is that when an Activity is dragged up or down in the list, the sortIndex for all of the activities get updated, so that the next time the list of activities is displayed, the activities maintain the order in which they were placed by the user. The array controller's sort descriptors binding is bound to an array with a single NSSortDescriptor, set to order the objects by sortIndex. I think this is causing some grief. Also, the code that assigns new sortIndexes for each object calls [arrayController arrangedObjects] to get the array controller's objects. From my reading of the documentation, this calls arrangeObjects on the underlying array, which I don't really want to do until all of the Activity objects' sortIndexes have been updated to reflect their new positions in the array. The objects that are dropped are assigned new sortIndexes based on their new indexes immediately after being dropped into the array. I'm not doing anything with the sortIndexes for the items in the array that haven't been moced until later. In the interim, I believe that calling [arrayController arrangedObjects] is trying to make the NSArrayController arrange its objects based on its sort descriptor (sortIndex), while one or more of the objects in the set share the same sortIndex. This is causing problems. I'm hoping someone can point me to some sample code that addresses this issue. I've looked at Demo Monkey and a couple of other samples I found on the web without being enlightened. Jonathan Dann has sample code using sortIndex and an NSTreeController, but updating the treeController doesn't involve rearranging its items first, so, it doesn't quite work. Possible solutions I can see: 1. manually assigning new sortIndexes to all objects from the point of insertion through the end of the array / set immediately upon insertion of the moved objects, or: 2. copying the entire array after insertion and then using the copied array to assign new indexes: for (Activity *anActivity in activitiesArrayCopy) { [anActivity setValue:[NSNumber numberWithInt:[activitiesArrayCopy indexOfObject:anActiviity]] forKey:@sortIndex] } But, I think there's a cleaner, more elegant solution out there that I'm not seeing. Any suggestions would be appreciated. Thanks. Brad ___ 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/bradgibbs%40mac.com This email sent to bradgi...@mac.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
NSArrayController Managing / Sorting NSManagedObjects
Hi, I have an NSTableView that displays a set of Activity objects, which are subclasses of NSManagedObject, all of which are managed by a custom NSArrayController. Each Activity has a sortIndex property, which is used to... wait for it... sort the activities. The array controller adds logic to update the sortIndex as objects are added, removed or re-ordered. It's this last part that's giving me grief. The table supports drag-and-drop. The idea is that when an Activity is dragged up or down in the list, the sortIndex for all of the activities get updated, so that the next time the list of activities is displayed, the activities maintain the order in which they were placed by the user. The array controller's sort descriptors binding is bound to an array with a single NSSortDescriptor, set to order the objects by sortIndex. I think this is causing some grief. Also, the code that assigns new sortIndexes for each object calls [arrayController arrangedObjects] to get the array controller's objects. From my reading of the documentation, this calls arrangeObjects on the underlying array, which I don't really want to do until all of the Activity objects' sortIndexes have been updated to reflect their new positions in the array. The objects that are dropped are assigned new sortIndexes based on their new indexes immediately after being dropped into the array. I'm not doing anything with the sortIndexes for the items in the array that haven't been moced until later. In the interim, I believe that calling [arrayController arrangedObjects] is trying to make the NSArrayController arrange its objects based on its sort descriptor (sortIndex), while one or more of the objects in the set share the same sortIndex. This is causing problems. I'm hoping someone can point me to some sample code that addresses this issue. I've looked at Demo Monkey and a couple of other samples I found on the web without being enlightened. Jonathan Dann has sample code using sortIndex and an NSTreeController, but updating the treeController doesn't involve rearranging its items first, so, it doesn't quite work. Possible solutions I can see: 1. manually assigning new sortIndexes to all objects from the point of insertion through the end of the array / set immediately upon insertion of the moved objects, or: 2. copying the entire array after insertion and then using the copied array to assign new indexes: for (Activity *anActivity in activitiesArrayCopy) { [anActivity setValue:[NSNumber numberWithInt:[activitiesArrayCopy indexOfObject:anActiviity]] forKey:@sortIndex] } But, I think there's a cleaner, more elegant solution out there that I'm not seeing. Any suggestions would be appreciated. Thanks. Brad ___ 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
Anyone Using ZeroC's Internet Communications Engine (ICE)?
Is anyone here using ZeroC's Internet Communications Engine? I found it in Apple's Developer Downloads section. Looks like a worthy replacement for DO and they've recently added support for iPhone OS. Just wondering whether it's worth looking into further for an app I'm working on that requires a fair amount of messaging among Macs and iPhones over a LAN. I've been using BLIP. I don't have any complaints with BLIP -- I actually like it quite a bit. But, if Ice is faster, easier to implement, more secure, or has richer features... Thanks. Brad ___ 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
iTunes DB Change Notifications?
I've looked through the docs and Googled, but may not be looking for the right terms. Are there change notifications for the iTunes database? I'd like to have an iTunes client on a different machine on the local network be notified of changes, rather than having to poll and reload the database regularly. Thanks. Brad ___ 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: iTunes DB Change Notifications?
If Apple is providing the XML file for third party developer use, but they don't provide any way to monitor changes, does that mean that their intention is for third party apps to regularly refresh from the XML file? Isn't this an extremely expensive operation? Particularly when moving data across a network? How about interjecting a Core Data app, running on the machine that maintains the XML file? That machine could monitor the XML file with FSEvents and maintain a CD DB that mirrors the XML file, adding new objects or fetching, updating and then saving changes, as appropriate. On the context's WillSaveNotification, it could alert its clients, sending just the updated information. If this works, the question is, would it be better to maintain mirrored CD DB's on each of the clients (clients will be a mix of Macs and iPhones), and update those databases when changes occur? Or, should they query the server when they need information? The client UI's would be much more responsive if the clients each maintained their own databases, particularly if I wanted to get cover art to the clients, but maintenance gets more complicated. On Jul 27, 2009, at 10:48 AM, Kyle Sluder wrote: On Jul 27, 2009, at 10:38 AM, Brad Gibbs bradgi...@mac.com wrote: Are there change notifications for the iTunes database? I'd like to have an iTunes client on a different machine on the local network be notified of changes, rather than having to poll and reload the database regularly. Nope. No public ones, anyway. You could watch the iTunes DB files with FSEvents or kqueue and refresh over Apple events when you detect a change. File a Radar, too. --Kyle Sluder ___ 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
Custom NSArrayController - Dynamic Class?
I have a Core Data app and several tables for adding various entities. I want to add an index to each new object so I can sort them after fetching. I've been using a custom NSArrayController and overriding the addObject:, insertObject: atArrangedObjectIndex:, and removeObject: methods to add or update the indices as I go, using, for example: - (void)addObject:(Floor *)object { [super addObject:object]; object.index = [NSNumber numberWithInt:[[self arrangedObjects] indexOfObject:object]]; NSLog(@Added %@, [object description]); } This means that I need a custom NSArrayController for each entity. Is there a way to make the entity name dynamic? In other words, can I ask the array controller for the name of the entity it's managing, so I only need one custom NSArrayController subclass to manage this for several different entity types? I guess I'm looking for a way to replace the argument (Floor *) from the example above with something like: [[[self arrangedObjects] objectAtIndex:0] class] If I use id, the code doesn't know that the object being added should have an index. Thanks. Brad ___ 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: Custom NSArrayController - Dynamic Class?
Not exactly. Sorry I've done such a poor job describing what I'm after. I've got an entity named Building (and also entities named Floor and Room). Each of these entities has an index attribute, which is an int16 type. All three entities inherit the index attribute and others from a common parent, which I'm calling IndexedObject. The UI has tables for each entity and '+' and '-' buttons to add and remove entities from the table and drag-and-drop to reorder the entities. The '+' button is linked to the NSArrayController subclass' add: method, which automatically invokes insertNewObjectForEntityForName: inManagedObjectContext:. I've been using: - (void)addObject:(Building *)object { [super addObject:object]; object.index = [NSNumber numberWithInt:[[self arrangedObjects] indexOfObject:object]]; NSLog(@Added %@, [object description]); } to override NSArrayController's standard implementation and assign an index to the newly-created object, based on its index within the underlying array. The problem is the type for the argument in the method declaration. With the standard method signature: - (void)addObject:(id)object the runtime doesn't have a specific entity to look to for a definition, so it doesn't know that I really want to be adding a Building entity, which does have an index attribute, and it throws an error. If I change the method declaration to: - (void)addObject:(Building *)object it knows that the Building entity has an index attribute, so the error goes away. But, that means that I need to create separate NSArrayController subclasses to control the arrays of the Floor and Room entities. I'm hoping to find a method declaration that can look to the entity type of the objects that the array controller is controlling (as set in IB), so that I can use the same subclass for the Building, Floor and Room arrays. Having separate NSArrayController subclasses for Floor and Room isn't the end of the world, but if there's a cleaner way to do this, I'd like to learn about it. Thanks for all of your help. Brad On Jul 18, 2009, at 12:24 PM, Quincey Morris wrote: On Jul 18, 2009, at 10:36, Brad Gibbs wrote: Can I use that to indicate the type for the argument to the method? On Jul 18, 2009, at 9:45 AM, Quincey Morris wrote: Perhaps NSSClassFromString ([[self entityName] managedObjectClassName])? Sorry, I took your example too literally, and gave you the expression for the class name (apart from the typo). For insertNewObjectForEntityForName:inManagedObjectContext: you'd just need the entity name: insertNewObjectForEntityForName: [self entityName] inManagedObjectContext: [self managedObjectContext] Is that what you wanted? ___ 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/bradgibbs%40mac.com This email sent to bradgi...@mac.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: iTunes COM interface for Windows; need the equivalent for
Thanks for sharing your code, George. Is there any way to access AirTunes with Objective-C / Cocoa or AppleScript? I've seen some information on daap that allows the use of AirTunes, but it's a private API, so I'm hesitant to use it, even for my own personal projects. Although, given the fact that it apparently hasn't changed much since iTunes 4, it seems unlikely that Apple would make any sweeping changes. I read somewhere that Apple had planned on making the daap API public years ago, but I guess either that information was incorrect or they had a change of heart. It'd be nice to see a Cocoa-native iTunes 9 with a Core Data database to coincide with the release of Snow Leopard... ___ 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
Public API for AirTunes?
Hi, I've been looking for a public API for AirTunes without success. Maybe I have the wrong name? Is it available under another name? There are a number of apps out now that use AirTunes (VLC, Rogue Amoeba's AirFoil, FireFly and others). Are they all hacking the daap? Daap is pretty well understood at this point and, given that it has been around since iTunes 4, it seems unlikely that Apple would break it, but I'm a little surprised so many released apps are using a private API. Thanks. Brad ___ 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
Looking for a Mentor in the SF Bay Area
Hi, I'm looking for an experienced Objective-C programmer in the SF Bay Area with a little extra time on his / her hands to meet for an hour or two per week and correspond over e-mail. I *think* I have a decent grasp of the basics (I'm currently trying things with Core Data, Core Animation and BLIP), but I've never had any formal programming education and have never worked in a programming environment. I have well-developed ideas, requirements and use cases for three related apps, but the implementation needs some work. I spend too much time stumbling over how best to approach problems and too much time in the documentation. I don't have the budget to hire someone full-time or on a contract basis right now, but I would like to hire someone to provide guidance and nudges in the right direction to keep these projects moving forward. If the apps develop into working, shipping products, there will be a need for at least one full-time developer. Finally, the projects are fun. My company (www.peaktopeaksystems.com) will use them in our residential audio and video installations. I apologize if this is the wrong forum for this post. If you're interested, please reply privately. Thanks. Brad ___ 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
UML Diagramming or Other Helpful Software?
Hi, I'm wondering if there are some tools commonly in use in the Mac software development community for diagramming an app, creating use cases and / or requirements, etc. I've seen OmniGraffle and ConceptDraw. I'm just wondering how other people go about laying out their apps from 30,000 feet, and whether there are tools for this I haven't bumped into, yet. Thanks. Brad ___ 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: Passing References During Initialization / Nib Loading
There's a great macro available for creating singletons on the cocoa with love blog. It's dead simple to use and it does override init and copy methods to make sure only one instance is created. On Jun 12, 2009, at 8:50 AM, Michael Ash michael@gmail.com wrote: On Fri, Jun 12, 2009 at 4:13 AM, Quincey Morrisquinceymor...@earthlink.net wrote: On Jun 12, 2009, at 00:27, Michael Ash wrote: Singleton-ness is a property of the API, not the implementation. If the API provides a single instance which you use, then it's a singleton. Enforcing that single instance is entirely up to the implementation of the API. It's not a necessary feature of a singleton, and it's not even necessarily a good feature to have. Perhaps so. I'm not inclined to insist on my perspective if you feel it misrepresents the situation enough to comment on it. I'll point out, though, that there is no inherent singleness in Brad's situation (that is, barring information about the application design that's not been part of the discussion, there's no obvious reason why he can't choose to have multiple main window controllers) *beyond* the proposed decision to implement [MainWindowController sharedWindowController]. That proposal was a pragmatic solution to a design problem that didn't really involve the cardinality of main window controllers. That last point is really the point I was trying to make. Fair enough. I just didn't want others to think that if they wanted a true singleton then they had to go through and override alloc, init, etc., the way certain Apple sample code does. Nothing more. Mike ___ 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/bradgibbs%40mac.com This email sent to bradgi...@mac.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: Passing References During Initialization / Nib Loading
Well, I've got about 20+ different view controllers I was trying to avoid dropping all of those into the main window controller's nib file. Maybe that's what I need to do, though. I was taking self.view.window.windowController, which was working fine, as long as it was being called after awakeFromNib. On Jun 11, 2009, at 11:58 AM, Kyle Sluder wrote: On Thu, Jun 11, 2009 at 11:52 AM, Brad Gibbsbradgi...@mac.com wrote: Is there something I'm missing? It sounds like you're going about it wrong. Create outlets on your objects and wire them up to your window controller, which should be the File's Owner of the nib. No passing references required. --Kyle Sluder ___ 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: Passing References During Initialization / Nib Loading
Also, if I drop an object into the MainWindowController's nib file and that object is also the File's Owner for another nib file, won't the awakeFromNib method for that object be called twice? I'm doing some fetching in awakeFromNib methods to fetch information that needs to load as the view is loading, so, I'd effectively be performing each fetch twice, wouldn't I? Thanks. On Jun 11, 2009, at 12:45 PM, Brad Gibbs wrote: Well, I've got about 20+ different view controllers I was trying to avoid dropping all of those into the main window controller's nib file. Maybe that's what I need to do, though. I was taking self.view.window.windowController, which was working fine, as long as it was being called after awakeFromNib. On Jun 11, 2009, at 11:58 AM, Kyle Sluder wrote: On Thu, Jun 11, 2009 at 11:52 AM, Brad Gibbsbradgi...@mac.com wrote: Is there something I'm missing? It sounds like you're going about it wrong. Create outlets on your objects and wire them up to your window controller, which should be the File's Owner of the nib. No passing references required. --Kyle Sluder ___ 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/bradgibbs%40mac.com This email sent to bradgi...@mac.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: Passing References During Initialization / Nib Loading
Hi, Thanks for the response. I was trying to make the post short, hoping to up my chances of getting someone to read through the entire thing and take the time to respond. I guess I just made it confusing. So, now for the long(er) version. I have a single window application. It's a Core Data, non-document- based app. At launch, the appDelegate loads the mainWindowController, which controls the app's only window. In the main window, there are three views -- a status bar across the top, a menu view down the left side (Jonathan Dann's Animating Outline View embedded in a view, rather than a window) and a content view, which takes up the rest of the main window. The mainWindowController loads initial views for these containers. In each section of the menu (the outline view) is a table view with a single column, which lists the titles for the view controllers. For the most part, a single view controller controls a single view, which is displayed in the content view portion of the main window. These view controllers are subclasses of a custom subclass of NSViewController with variables for the main managedObjectContext and the mainWindowController. The method call to remove the view currently in the content view portion of the main window and replace it with the new view controller's view is in the main window controller. I had been manually instantiating the view controllers and passing references to the main window controller and the main managed object context with a custom init method ( initWithMoc: andWindowController:) and using these arguments to set variables in the view controllers. Today, I decided to try to refactor and clean up some code by instantiating the view controllers in nibs, but I ran into the problem I'm trying to describe. Yes, I'm using 10.6, but I think the problem can be abstracted enough to be discussed without breaking the NDA. On Jun 11, 2009, at 1:59 PM, Quincey Morris wrote: On Jun 11, 2009, at 11:52, Brad Gibbs wrote: In short, I need a more reliable way to pass references to my MainWindowController into objects that are awaking from nib files. Trying to set the mMainWindowController variable to self.view.window.windowController in the awakeFromNib method seems to be happening before the MainWindowController is instantiated, so, it sets the variable to NULL. I need to call a method in the MainWindowController to switch views / viewControllers, passing in the new viewController as an argument. I can set the mainWindowController variable in the method that actually invokes the view switch, but that seems clunky. It seems like there should be a method I can call to set the variable once the view controller has awoken and the app has fully loaded. initWithCoder and awakeFromNib happen too soon and applicationDidFinishLaunching only gets sent to the app delegate. You haven't really described how things are arranged, in a way that we can understand. You have a window controller, plus a view controller for each set of controls/objects in its own nib file? How do the view controllers get created? As Kyle said, to avoid having to manually resolve the timing of when instance variable can be set in objects loaded from nib files, you should use outlets instead of instance variable in objects coming from nib files. I think your mistake is trying to connect directly to the window controller across multiple nibs. Probably the correct solution involves putting a 'main window controller' property in each view controller, and putting a mViewController reference in the nib objects. Then you'd refer to the main window controller as mViewController.mainWindowController (or whatever). If your view controllers are being created programmatically, you'd pass the window controller as a parameter when creating them. If, for some reason, you have the view controllers in your main window nib file, then you'd use outlets to connect them to the main window controller. But that's all guesswork, without further information. ___ 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/bradgibbs%40mac.com This email sent to bradgi...@mac.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: Passing References During Initialization / Nib Loading
hmm... Sounds like a clever solution. On Jun 11, 2009, at 4:30 PM, Kyle Sluder wrote: On Thu, Jun 11, 2009 at 3:53 PM, Brad Gibbsbradgi...@mac.com wrote: I have a single window application. It's a Core Data, non-document- based app. At launch, the appDelegate loads the mainWindowController, which controls the app's only window. In the main window, there are three views -- a status bar across the top, a menu view down the left side (Jonathan Dann's Animating Outline View embedded in a view, rather than a window) and a content view, which takes up the rest of the main window. The mainWindowController loads initial views for these containers. It sounds like you've got a standard master-detail interface going on here. In this case, the master view typically doesn't change, and so does not need to exist in a separate nib. Since your window can't really exist without that view, you gain nothing by lazily loading it. Same with the status bar. It does sound like a fairly standard master-detail view, although the menu items in each view of the animating outline view (the number of view controllers and views) will change at runtime. Is your suggestion predicated upon having the menu view in the main window controller's nib? If so, I'll have to look at this more closely to figure out how to make it happen. The animating outline view code loads the viewControllers in code, rather than using nib files. In each section of the menu (the outline view) is a table view with a single column, which lists the titles for the view controllers. For the most part, a single view controller controls a single view, which is displayed in the content view portion of the main window. These view controllers are subclasses of a custom subclass of NSViewController with variables for the main managedObjectContext and the mainWindowController. NSViewController has a representedObject binding. You should add a property to your window controller called managedObjectContext and set up your view controllers such that their represented object is the window controller. This is what we do in document-based applications, except we have the extra step of going through the window controller to get to the persistent document's managedObjectContext property. When / where do I set the representedObject? I don't see an exposed binding for representedObject in IB and if I don't set it in IB, it seems as though I'm back to the chicken-or-egg problem I'm try to work my way out of... The method call to remove the view currently in the content view portion of the main window and replace it with the new view controller's view is in the main window controller. Method Call means? Are you saying your window controller subclass has a method that looks something like -switchToContentViewController: ? Because that's exactly what you should be doing. Yes, that's what I meant. I had been manually instantiating the view controllers and passing references to the main window controller and the main managed object context with a custom init method ( initWithMoc: andWindowController:) and using these arguments to set variables in the view controllers. Today, I decided to try to refactor and clean up some code by instantiating the view controllers in nibs, but I ran into the problem I'm trying to describe. The view controllers are very similar to window controllers. They should be the File's Owner of the nibs. You instantiate the view controllers in your window controller's initializer (the view controller takes care of lazily loading its nib). Put all this together and your view controller subclasses (if you even need to subclass them) don't need to have a reference the view controller. The standard -[NSViewController representedObject] property will be more than sufficient to get from your view controller or view objects back at both your window controller and its MOC. Don't need a reference to the view controller? or the main window controller? Yes, I'm using 10.6, but I think the problem can be abstracted enough to be discussed without breaking the NDA. There's nothing substantively different about this on 10.6 than on 10.5. If you're at WWDC, hit me up and I'll explain in person. Ask anyone in an Omni jacket if they've seen me. --Kyle Sluder ___ 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
DVDPlayer Deinterlacing
Hi, It looks like the Scripting Bridge header file for Apple's DVD Player offers nearly the same options as the DVDPlayer framework, and neither seem to offer control over the deinterlacing options present in the DVD Player app itself. Apple's deinterlacing actually became pretty respectable in 10.5 and I'd like at least the option to invoke it. Is there any way to set deinterlacing in code, either through the Scripting Bridge or by using DVDPlayer.framework + some Quartz filter that didn't show up in my searches of the documentation? If not, is deinterlacing turned on or off by default? Also, I'm leaning towards using the DVDPlayer.framework. Is there any strong reason I should use the Scripting Bridge approach instead? Thanks. Brad ___ 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
Displaying an NSSet in a Single Table Cell?
I have a Core Data app for cataloging objects. Each object has a to- many relationship for Type that describes the type of the object. An object can have multiple types (hence, the to-many relationship...) -- usually 2-4 types per object. Objects are displayed in a table, one per row. I made the table rows tall enough to display three lines of text. I'd like to display one type per line for each object so that the user can click on one of the types and sort the table according to the type selected. Essentially, I guess I want to put three cells in a single cell, or a matrix in a cell, both to display the data and to get the selection and act upon it. There must be a way to do this, but I haven't been able to find it. Thanks. Brad ___ 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
Scrolling Title in IKImageBrowserView?
Is it possible to set the title of an image in an IKImageBrowserView to scroll when the item is selected? Thanks. ___ 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
Search Fields, Array Controllers and Multiple NIBs
I'm having a fundamental disagreement with Cocoa and I'm really hoping someone can help me see it her way... I have a Core Data app with a container view controller and multiple subviews, each with a view controller and a separate NIB. Subview switching is done via a segmented control. The subviews each display the same data, but in different ways -- one is a table view, another is an image view and the third is a cover flow view. The container view displays the segmented control that does the switching and a search field that is used to filter what is shown in the subviews. My aim is to have the search field filter the three views equally, such that if the user performs a search, all three subviews will show the filtered results of that search. So, the user the perform the search and each of the three views will display the filtered results of the same search. I've tried a number of approaches. To me, it seems the most logical approach is to have the container view pass its MOC and NSArrayController instance to each of the subviews as it creates them. I still need to create an NSArrayController instance in each view's NIB file in IB to bind the objects in each of the views, but I can create an outlet in each view controller and set it to the NSArrayController instance passed in from the main view when the subview is instantiated. But, this doesn't seem to work. I can NSLog each array controller to see that each view has the same instance of the NSArrayController, but searching in the main view doesn't seem to filter any of the subviews properly. I'm sure I haven't described the issues clearly but I'm hoping someone will understand this well enough to propose a solution. Thanks in advance, Brad ___ 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
Sample Code from WWDC 2008?
I attended a couple of great sessions on Core Data at WWDC 2008. I believe I remember the presenters saying that the code developed in those sessions was going to be made available to attendees (I believe it was going to be made available in two versions -- one emphasizing the use of bindings and another primarily code-derived). The videos have been available for a while now, but I haven't been able to find the sample code anywhere. If this is available, would someone please point me in the right direction? Thanks. Brad ___ 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: Sample Code from WWDC 2008?
I've checked there, but I didn't see the Core Data samples I was looking for. In fact, there are only two sample code entries in the Cocoa section that are dated the week of WWDC 2008 ( one is on subpixel antialiasing and the other deals with layer-backed views) and no files dated after the end of the conference. Most of the rest of the code in the Mac / Cocoa section is documentation and sample code dating back to 2005. On Jan 17, 2009, at 1:05 PM, Robert Marini wrote: If you check out the WWDC attendee site (https://developer.apple.com/wwdc/attendee/index.php ) you can pick a track-specific reference library. The sample code will be available there. -rob. On Jan 17, 2009, at 12:22 PM, Brad Gibbs wrote: I attended a couple of great sessions on Core Data at WWDC 2008. I believe I remember the presenters saying that the code developed in those sessions was going to be made available to attendees (I believe it was going to be made available in two versions -- one emphasizing the use of bindings and another primarily code- derived). The videos have been available for a while now, but I haven't been able to find the sample code anywhere. If this is available, would someone please point me in the right direction? Thanks. Brad ___ 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/wisequark %40gmail.com This email sent to wisequ...@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/bradgibbs%40mac.com This email sent to bradgi...@mac.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
Scripting Bridge: Targeting Another Mac on the LAN
Happy New Year. I'm trying to create a small app to control Apple's DVD Player on a Mac Mini using a MacBook Pro. I've got a small start with Scripting Bridge and I have control over the DVD Player app on my laptop. I've read through the Distributed Objects documentation and Async Sockets, but I wonder if there's a better or more straightforward approach to targeting another computer on the LAN when using Scripting Bridge? For example, in AS, I can simply tell a computer at an IP address to play, stop, pause, etc. Is there a way to set a variable to another computer's IP address and send Scripting Bridge commands directly to that computer using the variable? Thanks in advance. Brad ___ 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
NSNumberFormatter Currency Symbol
Is it possible to have a text field with a currency symbol that appears automatically? For instance, if the user types 400, $400.00 appears in the text field. I've been using IB's formatter with 10.4+ and I don't see any options that would allow for this. As it stands, if the formatter is configured for currency, the text field won't allow an entry that doesn't start with a $. Thanks as always, Brad ___ 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 [EMAIL PROTECTED]
Core Data, Filtering by PopUps Bindings Confusion
I've been using Jonathan Dann's excellent Core Data Sorted sample code to create an outline view consisting of two concrete entities -- Categories and Types (each parent Category can have an unlimited number of children types). The only real adjustment I've made to his code is to put the parent relationship in the Category entity and the children relationship in the Type entity. I've also modified the indexPath of the addGroup method so that categories are always root objects. The outline view seems to be working fine. I'm using the addGroup method to add categories and addLeaf to add types. This outline view is in a preferences window in my app. This section of the app is meant to be a product library. Users will be able to sort and search by category or type. When adding a new product, a type is assigned to the product, using the selected value of a popup button. I'd like to limit the number of types in that popup button by using a category popup button. In other words: 1. User indicated s/he wants to add a new product 2. User selects a category from a popbutton menu 3. App loads the selected category's types in the the types popup button 4. User selects a type and the type is assigned to the type relationship for the product being created or edited. I've got two array controllers in my nib file -- one for categories and another for types. I've tried just about every combination of bindings I can imagine, but I can't get the types popup button to limit itself to the types associated with the selected category -- at best it either displays all types of every category or it populates the types popup menu for a selected category but doesn't update itself when a different category is selected. Should I be using a fetch request or a filter predicate instead? If bindings is the right approach, could someone describe the bindings that need to be made? Also, if there's a website, or something other than Apple's documentation on Core Data, bindings, fetch requests and filter predicates, I'd really appreciate the pointer. I've Googled and read through Pragmatic Programmer's Core Data beta book, but the section on bindings hasn't been released, yet. Thanks in advance. Brad ___ 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 [EMAIL PROTECTED]
Re: Core Data, Filtering by PopUps Bindings Confusion
Thanks for the thoughts, Quincey, but I couldn't make that work. I have a categoriesAC which is bound to File's Owner's MOC and set to Entity mode for Category. My categories Popup Button (categoriesPUB) is bound to the categories array controller as follows: Content.arrangedObjects ContentValues.arrangedObjects.displayName I've tried a variety of bindings for the popup button's selectedObject binding, but I'm not sure how to bind it in this instance. I tried binding the typesAC's contentSet to File's Owner.categoriesPUB.selectedItem.representedObject.children but nothing showed up in the typesPUB. Re: Core Data, Filtering by PopUps Bindings Confusion FROM : Quincey Morris DATE : Fri Nov 14 22:31:26 2008 On Nov 14, 2008, at 12:06, Brad Gibbs wrote: I've been using Jonathan Dann's excellent Core Data Sorted sample code to create an outline view consisting of two concrete entities -- Categories and Types (each parent Category can have an unlimited number of children types). The only real adjustment I've made to his code is to put the parent relationship in the Category entity and the children relationship in the Type entity. I've also modified the indexPath of the addGroup method so that categories are always root objects. The outline view seems to be working fine. I'm using the addGroup method to add categories and addLeaf to add types. This outline view is in a preferences window in my app. This section of the app is meant to be a product library. Users will be able to sort and search by category or type. When adding a new product, a type is assigned to the product, using the selected value of a popup button. I'd like to limit the number of types in that popup button by using a category popup button. In other words: 1. User indicated s/he wants to add a new product 2. User selects a category from a popbutton menu 3. App loads the selected category's types in the the types popup button 4. User selects a type and the type is assigned to the type relationship for the product being created or edited. I've got two array controllers in my nib file -- one for categories and another for types. I've tried just about every combination of bindings I can imagine, but I can't get the types popup button to limit itself to the types associated with the selected category -- at best it either displays all types of every category or it populates the types popup menu for a selected category but doesn't update itself when a different category is selected. Should I be using a fetch request or a filter predicate instead? If bindings is the right approach, could someone describe the bindings that need to be made? I haven't tried this, but if I understand the setup, the current Category would be available from the popup button as button.selectedItem.representedObject, assuming the button was bound to a Categories NSArrayController which itself was bound to the categories. Therefore, your Types array controller would be need to be bound to button.selectedItem.representedObject.types, and the only way I know to do that is to add the button as an outlet on the file's owner, so the actual binding is to File's Owner.button.selectedItem.representedObject.types (or if there's a more direct way, I'd be interested to know what it is). HTH ___ 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 [EMAIL PROTECTED]
Apple's NSPersistentDocument Tutorial and MOCs
Hi, I've followed along through the NSPersistentDocument tutorial from Apple and made some adjustments for my own needs. I now have a sheet that drops down to allow the user to add a new product record. This is handled in its own MOC and the relevant key/value pairs are copied to the main MOC when the user clicks Add to dismiss the sheet. This works fine for attributes, but I'd also like to create relationships between the new product and existing category and manufacturer objects in the main MOC using pop up buttons. I can populate the pop up buttons easily enough in IB using bindings, but I can't bind across from the main MOC where the categories and manufacturers arrays live into the special new product MOC created for the sheet. I've mucked about a bit with NSPopUpButton's titleForSelectedItem and some other methods, but, it feels as though I'm fighting the frameworks. Can someone recommend an elegant solution for this? Thanks. Brad ___ 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 [EMAIL PROTECTED]
Pop-Up Graphical Calendar
Hi, I'm trying to replicate one of the pop-up calendars you see on Orbitz, Hotwire, etc. , where the user clicks a calendar icon, the calendar appears and then the calendar disappears once the user has selected a date. I've got a graphical NSDatePicker and I can show and hide it with an NSButton and an IBAction, but I'd like to make the calendar hide itself automatically after the user has selected a date. I don't see a delegate method to notify a delegate that a date has been selected. I suppose I could use a notification when the date has been changed, but I'm wondering if there's a more elegant way to do this. Maybe with bindings? Thanks. Brad ___ 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 [EMAIL PROTECTED]
Re: Help for a beginner..
I had no knowledge of or experience with programming when I started last April. I started with Kochan's Objective-C book, then Hillegass Third Edition, then XCode Unleashed. That happened to be the order in which they were released, but it was a good way to go -- I felt one led right into the other. Safari has a beta version of Objective-C 2.0 available now as a PDF. It's not complete, but there's enough there to make it worth a look. Also, Pragmatic Programmer's has a beta version of Cocoa Programming: A Quick Start Guide for Developers. I think you'd still want to be familiar with Kochan's material before starting this book, but you might read through it before starting Hillegass to get a 50,000-ft view of Cocoa before diving down to the 10,000-ft. view offered in Hillegass. XCode Unleashed gets further down into the mechanics of XCode, version control, etc. Apple's documentation and sample code are helpful, but, for me, I needed a good understanding of Kochan's material and some of Hillegass before Apple's documentation made any sense, even the conceptual docs on Objective-C 2.0 or Cocoa. I'd like to find a good book on object-oriented design and how to go about designing classes, etc., if anyone has any ideas... On Oct 4, 2008, at 6:12 AM, Jason Stephenson wrote: Rob Keniger wrote: On 04/10/2008, at 9:46 AM, mmalc crawford wrote: Start with Programming in Objective-C by Stephen Kochan (depending on how quickly you want to get underway, you may consider waiting for the second edition): http://www.amazon.com/Programming-Objective-C-Developers-Library-Stephen/dp/0672325861/ http://www.amazon.com/Programming-Objective-C-2-0-Developers-Library/dp/0321566157/ I totally agree with mmalc, this is the first book you should buy. Despite what others have said, I highly recommend that you do NOT start with Kernigan and Richie, it's simply not the best learning tool for getting into Mac programming. KR is extremely dry and although it teaches you plain C, you don't need to know most of the stuff in that book to write good Objective-C. Stephen Kochan's book teaches you everything you need to know about programming in Objective-C, including the bits of the C language you need to know and none of the bits you don't. It is also one of the most well-written technical books I have ever read. Ditto. Plus, I'd like to add that Kochan also introduces you to the basic programming concepts along the way. He doesn't just teach the language or the Objective-C idioms, but several chapters discuss things like basic data types and looping. So, you'll not learn just Objective-C the language, but you'll get a fairly decent introduction to the basics to be an effective programmer in any language. Kernighan and Ritchie don't do this in their small book. They assume you already know the basics of programming, and they are only interested in introducing you to the C language. It would help to have some basic programming knowledge: data structures, looping, recursion, etc. *before* reading KR. I've never read it, but I imagine that the book on C by Kochan (http://search.barnesandnoble.com/Programming-in-C/Stephen-G-Kochan/e/9780672326660/?itm=1 ) is equally as good as his book on Objective-C. Once you've read the Kochan book you should get Aaron Hillegass' Cocoa Programming for Mac OS X, which goes beyond the Objective-C language to teach you the mechanics of working with the Cocoa frameworks. Ditto, and Fritz Anderson's Xcode Unleashed is another good choice for a second or third book. It covers the Xcode 3 programming environment in a bit more detail than Hillegass's book, and has some excellent chapters on using libraries and private frameworks. 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/bradgibbs%40mac.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Drawing an NSImage in a CALayer
Hi, I'm trying to draw an NSImage (a PNG) in a CALayer. The goal is to create a method that allows me to pass an NSImage as an argument to create a layer-hosting view. I have: -(id)drawButton: (NSView *)button withImage:(NSImage *)anImage { ... // image layer imageLayer=[CALayer layer]; [imageLayer drawLayer:imageLayer inContext:ctx]; imageLayer.masksToBounds=YES; [imageLayer addConstraint:[CAConstraint constraintWithAttribute:kCAConstraintMaxY relativeTo:@superlayer attribute:kCAConstraintMaxY offset:-(height/2)]]; [imageLayer addConstraint:[CAConstraint constraintWithAttribute:kCAConstraintMidX relativeTo:@superlayer attribute:kCAConstraintMidX]]; [titleLayer addSublayer:imageLayer]; [titleLayer layoutIfNeeded]; ... And I found this snippet in the Core Animation Cookbook: - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx { NSGraphicsContext *nsGraphicsContext; nsGraphicsContext = [NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:NO]; [NSGraphicsContext saveGraphicsState]; [NSGraphicsContext setCurrentContext:nsGraphicsContext]; // ...Draw content using NS APIs... NSRect aRect=NSMakeRect(10.0,10.0,30.0,30.0); NSBezierPath *thePath=[NSBezierPath bezierPathWithRect:aRect]; [[NSColor redColor] set]; [thePath fill]; [NSGraphicsContext restoreGraphicsState]; } But I don't know how to get the current CGContextRef for the second parameter. Thanks in advance. Brad ___ 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 [EMAIL PROTECTED]
Re: Drawing an NSImage in a CALayer
On Sep 18, 2008, at 3:18 PM, Matt Long wrote: You've got some fundamental issues here. That doesn't surprise me... This call in particular: imageLayer drawLayer:imageLayer inContext:ctx]; It doesn't make sense. -drawLayer:inContext is a delegate method. You are overriding drawing functionality for the layer in question. Instead you would set the layer's delegate to your app delegate (or whatever controller you're using) and then implement drawLayer:inContext in your controller. e.g. [imageLayer setDelegate:self] then implement - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx { if( layer == imageLayer ) { [layer setContents:imageRef]; } } There are other deeper problems here, so maybe I'll just answer how to get a CGImageRef... Use this code: - (CGImageRef)nsImageToCGImageRef:(NSImage*)image; { NSData * imageData = [image TIFFRepresentation]; CGImageRef imageRef; if(imageData) { CGImageSourceRef imageSource = CGImageSourceCreateWithData( (CFDataRef)imageData, NULL); imageRef = CGImageSourceCreateImageAtIndex( imageSource, 0, NULL); } return imageRef; } you then call [imageLayer setContents:imageRef] where imageRef is the CGImageRef object returned. It looks like you're making things more difficult than they need to be. Maybe clarify a little what you are doing. What does this mean: The goal is to create a method that allows me to pass an NSImage as an argument to create a layer-hosting view.? I'm trying to create two classes that generate views that will be used as buttons. One class generates a button view with a title, the other generates a view with an image. I'm using CA to animate a CIBloom filter that pulses once when the button is pressed. There will be several of each of these buttons in my UI, the only difference between them will be the titles or images on them. So, I'm trying to encapsulate the button-making behavior into a single class that I can pass a title or image to in order to create a new instance of a button, which will be displayed and controlled from the appropriate view controller or window controller. I have the title button maker working, but I'm stumbling with the image button maker, as you've noticed. Best regards, -Matt On Sep 18, 2008, at 3:54 PM, Brad Gibbs wrote: Hi, I'm trying to draw an NSImage (a PNG) in a CALayer. The goal is to create a method that allows me to pass an NSImage as an argument to create a layer-hosting view. I have: -(id)drawButton: (NSView *)button withImage:(NSImage *)anImage { ... // image layer imageLayer=[CALayer layer]; [imageLayer drawLayer:imageLayer inContext:ctx]; ___ 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 [EMAIL PROTECTED]
[SOLVED] Re: Newb: Targeting an instance of a class instantiated by a NIB file
I had a panel controlled by a window controller that needed access to code in the main window's window controller. Panels are key windows, but not main windows. The responder chain rolls up through the panel's window controller (the key window chain) and then up through the main window's responder chain, which, in my case, runs up through the MainWindowController, where the view switching model lives. So, once I figured out how the responder chain works and how to invoke it properly, everything worked like a charm. I can't say this was a fun experience, but the responder chain is really cool! (and useful). Thanks to everyone who helped point me in the right direction. Brad On Sep 12, 2008, at 8:37 PM, Brad Gibbs wrote: Hey Jon, It is a non-document-based app. Only one instance of each window should ever be open at one time. I have an AppController class that is the NSApp delegate. In the AppController's awakeFromNib I alloc the MainWindowController and initWithNib. In the MainWindowController, I have an IBAction for a button that allocs the MainMenuWindowController and initWithNib's the MainMenu (which I'm implementing with a HUD panel and the BGHUDAppKit). I'll have to look into putting some references in the AppController. Brad On Sep 12, 2008, at 7:52 PM, Jonathan Hess wrote: Hey Brad - What code is responsible for creating each of the two window controllers? Perhaps that code could tell each of the window controllers about each other. Or, it sounds like your application isn't document based. Are there ever multiple instances of the two windows you're currently working with? If not, perhaps your NSApplication subclass, or application delegate, should have a reference both window controllers and you could use that object to be the missing link. Jon Hess ___ 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/bradgibbs%40mac.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Newb: Targeting an instance of a class instantiated by a NIB file
I'm working on an application with a single main window and a number of views and view controllers. I have a navigation window that pops up and allows users to set preferences and also switch views in the main portion of the app's main window. I want to write the code to switch views in the MainWindowController.m, since it controls the window that contains the views that will be switched. But, the buttons that control the view switching are located on a panel being controlled by a different view controller. The main window and its window controller are instantiated when the program is launched. Creating another instance in the view controller that contains the buttons (either by adding a MainWindowController object in IB or by creating another instance in the view controller code) doesn't target the existing main window, and, therefore, doesn't cause views to be switched in the main window that is instantiated on launch. So, how can I target the instance of the main window controller that was instantiated on launch from the NSViewController controlling the view with the view switching buttons, in order to switch views? Or should I be doing something else entirely? Thanks. Brad ___ 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 [EMAIL PROTECTED]
Re: Newb: Targeting an instance of a class instantiated by a NIB file
Thanks for the reply. Unfortunately, the navigation panel is too complicated not to have a controller (it has several, actually). I haven't used the responder chain yet, but I'll give it a go. It's disappointing that there's no way to target the instance directly... On Sep 12, 2008, at 12:41 PM, Jamie Hardt wrote: On Sep 12, 2008, at 12:17 PM, Brad Gibbs wrote: I want to write the code to switch views in the MainWindowController.m, since it controls the window that contains the views that will be switched. But, the buttons that control the view switching are located on a panel being controlled by a different view controller. So you have the buttons on the navigation panel, that control the main window view. You have a few options: 1) Connect the buttons on the panel to the changeView: (or whatever you call it) actions on the main window windowController. This is the easiest. Just leave your Navigation Panel in your main windows nib, and don't bother writing a window controller for it. If the navigation panel starts getting more complicated and chatty with a bunch of other components, or particularly if it can alter document state, THEN consider making a separate NIB for it. 2) Implement changeView: on your Document class instead, and make the buttons on the panel send a changeView: selector to the first responder. The changeView: message will eventually find its way to your NSDocument, and then you write code in the NSDocument that tells the MainWindowController to do the view switching. All roads in the responder chain lead to the NSDocument eventually. Jamie Hardt The Sound Department http://www.soundepartment.com/ http://www.imdb.com/name/nm0362504/ ___ 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 [EMAIL PROTECTED]
Re: Newb: Targeting an instance of a class instantiated by a NIB file
If I'm reading your mail correctly, I've tried that without success. I have a MainWindowController controlling MainWindow. On MainWindow.xib is a button which launches another window (MainMenu,xib) with a window controller (MainMenuWindowController.m). A couple of NSViewControllers down is a view with the buttons in question. I've tried creating an instance of MainWindowController in that view's NSViewController (declaring MainWindowController *iMainWindowController in the interface, using @property and @synthesize and then calling iMainWindowController = [[MainWindowController alloc] init] in the NSViewController's implementation section). I can tell the method is being called by an NSLog statement posted to the Console, but the view doesn't swap in. I'm assuming this is because I've programmatically created another instance of the MainWindowController class in the NSViewController and I'm targeting that instance with the buttons, rather than the instance created at launch, which is controlling the MainWindow. Calling a method on the MainWindowController instance created by the NSViewController would still cause the log file to print the message without swapping in the view on the instance of the Main Window created when I launch the app. So, I'm left to assume that I need to target the instance created at launch. According to the Event Handling Guide: If an NSWindowController object is managing the window, it becomes the final next responder. Is this going to be a problem, since the NSViewController with the button code is underneath its own NSWindowController? Would the responder chain just stop there and so that messages wouldn't make their way over and up to the MainWindowController? Thanks again. Brad On Sep 12, 2008, at 1:38 PM, Jonathan Hess wrote: Hey Brad - So it sounds like you have two controllers, A, and B, and they each have their own NIB. Sound like you're on the right track. Now you want to have an action in B's NIB affect controller A. Does controller B have an instance variable, or other mechanism, for referencing controller A? If so, you could put an action method on controller B and have that be the target of your button in NIB B. The implementation of that action can then call a method on controller A. Jon Hess On Sep 12, 2008, at 12:17 PM, Brad Gibbs wrote: I'm working on an application with a single main window and a number of views and view controllers. I have a navigation window that pops up and allows users to set preferences and also switch views in the main portion of the app's main window. I want to write the code to switch views in the MainWindowController.m, since it controls the window that contains the views that will be switched. But, the buttons that control the view switching are located on a panel being controlled by a different view controller. The main window and its window controller are instantiated when the program is launched. Creating another instance in the view controller that contains the buttons (either by adding a MainWindowController object in IB or by creating another instance in the view controller code) doesn't target the existing main window, and, therefore, doesn't cause views to be switched in the main window that is instantiated on launch. So, how can I target the instance of the main window controller that was instantiated on launch from the NSViewController controlling the view with the view switching buttons, in order to switch views? Or should I be doing something else entirely? Thanks. Brad ___ 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/jhess%40apple.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: Newb: Targeting an instance of a class instantiated by a NIB file
I run into a stumbling block once I get to the first NSWindowController, whether I'm trying your method, or trying to use the Responder Chain, as Jamie suggested. I get what you're suggesting and I tried going that route before making the original post, but I don't know how to go from the NSWindowController that contains the buttons over to the other NSWindowController that contains the view switching code. A button on the MainWindowController launches the MainMenuWindowController, but the two don't have any kind of direct relationship through a hierarchy. So, when I use [self.view.window.windowController], i can get to the controller of the view containing the buttons, but I don't where to go from there, given that there is no direct relationship between that window controller and anything on the main window or its controller. I tried to make the MainMenuWindow a child of the MainWindow, and while that did allow the buttons to control the view switching, it caused all sorts of other problems, since calls such as [self.view.window close] that were intended to close just the MainMenuWindow began closing both windows. I tried: [self.view.window.parentWindow.windowController removeChildWindow: [self.view.window]]; [self.view.window close]; but XCode spit out an error -- I suppose XCode sees this as self- referential? So, the problem remains... As far as the responder chain goes, the message goes up from the NSViewController containing the buttons through its window, to that window's controller and then to NSApp. I don't know how to cause it to jump to the main window's window controller. On Sep 12, 2008, at 5:15 PM, Jonathan Hess wrote: On Sep 12, 2008, at 3:07 PM, Brad Gibbs wrote: Thanks for the help. I'm trying to understand your code suggestion below. My app isn't document-based, so I don't think I have a document to refer to... Can I just leave that part out, or will things work differently in a non-document-based app? Ah. That was just an example that I figured would be close enough to lead you to the solution that was right for your App. You'll need to replace the windowController] document] mainWindowController] part with whatever series of messages allow you to get a reference back to your main view controller. As for deciding what the right chain of messages is ... At some point your view controller probably knows about some object, that knows some other object, that knows another object ... that finally knows your main window controller. If there isn't some chain of relationships you can follow through your objects to get from your view controller to your window controller, you could introduce one. Once you've done that, you'll use that path to get from self, the view controller, to your main window controller. I've also re CC'd the list because I think this thread will be interesting to new cocoa developers searching through the list history for help - Jon Hess The bit I wrote about the responder chain was in response to Jamie Hardt's suggestion that I use the responder chain (which I couldn't get to work, either). On Sep 12, 2008, at 2:43 PM, Jonathan Hess wrote: On Sep 12, 2008, at 2:25 PM, Brad Gibbs wrote: If I'm reading your mail correctly, I've tried that without success. I have a MainWindowController controlling MainWindow. On MainWindow.xib is a button which launches another window (MainMenu,xib) with a window controller (MainMenuWindowController.m). A couple of NSViewControllers down is a view with the buttons in question. I've tried creating an instance of MainWindowController in that view's NSViewController (declaring MainWindowController *iMainWindowController in the interface, using @property and @synthesize and then calling iMainWindowController = [[MainWindowController alloc] init] in the NSViewController's implementation section). The problem is that this creates a new 'MainWindowController'. The object you get in response to [[MainWindowController alloc] init] is unrelated to the one previously created. I can tell the method is being called by an NSLog statement posted to the Console, but the view doesn't swap in. I'm assuming this is because I've programmatically created another instance of the MainWindowController class in the NSViewController and I'm targeting that instance with the buttons, rather than the instance created at launch, which is controlling the MainWindow. Exactly. Calling a method on the MainWindowController instance created by the NSViewController would still cause the log file to print the message without swapping in the view on the instance of the Main Window created when I launch the app. So, I'm left to assume that I need to target the instance created at launch. Yep. According to the Event Handling Guide: If an NSWindowController object is managing
Re: Newb: Targeting an instance of a class instantiated by a NIB file
OK XCode doesn't put up any errors or any warnings for this code and the app works as intended. The code is in an NSViewController, so I was targeting the view controller's view and then the view's window. What is the correct approach? On Sep 12, 2008, at 7:09 PM, Bill Bumgarner wrote: On Sep 12, 2008, at 7:08 PM, Brad Gibbs wrote: [self.view.window.parentWindow.windowController removeChildWindow: [self.view.window]]; [self.view.window] doesn't make any sense. b.bum ___ 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 [EMAIL PROTECTED]
Re: Newb: Targeting an instance of a class instantiated by a NIB file
Hey Jon, It is a non-document-based app. Only one instance of each window should ever be open at one time. I have an AppController class that is the NSApp delegate. In the AppController's awakeFromNib I alloc the MainWindowController and initWithNib. In the MainWindowController, I have an IBAction for a button that allocs the MainMenuWindowController and initWithNib's the MainMenu (which I'm implementing with a HUD panel and the BGHUDAppKit). I'll have to look into putting some references in the AppController. Brad On Sep 12, 2008, at 7:52 PM, Jonathan Hess wrote: Hey Brad - What code is responsible for creating each of the two window controllers? Perhaps that code could tell each of the window controllers about each other. Or, it sounds like your application isn't document based. Are there ever multiple instances of the two windows you're currently working with? If not, perhaps your NSApplication subclass, or application delegate, should have a reference both window controllers and you could use that object to be the missing link. Jon Hess ___ 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 [EMAIL PROTECTED]
Fade In and Fade Out Transitions Missing in IB
I'm sure this is user error, but the Order In and Order Out options shown and described in the IB User Guide as being available in the View Effects tab under Transitions don't seem to be available in my version of IB. I'm using XCode and IB 3.1, and my project is targeted for 10.5, but I can't seem to cause these these options to appear. What am I doing wrong / not doing? Thanks, Brad ___ 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 [EMAIL PROTECTED]
Re: Fade In and Fade Out Transitions Missing in IB
hmmm that's a bummer looked like a nice feature. On Sep 9, 2008, at 9:39 PM, Seth Willits wrote: On Sep 9, 2008, at 6:50 PM, Brad Gibbs wrote: I'm sure this is user error, but the Order In and Order Out options shown and described in the IB User Guide as being available in the View Effects tab under Transitions don't seem to be available in my version of IB. I'm using XCode and IB 3.1, and my project is targeted for 10.5, but I can't seem to cause these these options to appear. What am I doing wrong / not doing? It's not just you. They're not there. The screenshots are just from an earlier version. In general, my experience with IB3's view transition settings is: don't bother. They either don't work at all or are somehow incomplete/broken. Others (at least one Apple engineer included) have testified to this as well. -- Seth Willits ___ 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/bradgibbs%40mac.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: Sending a GET or POST HTTP request with Cocoa
You might find the discussion here helpful: http://deusty.blogspot.com/search/label/NSURLRequest After getting NSURL's to work, I decided I'd be better off with TCP sockets. If you find yourself in the same position, you might try AsyncSockets (also available at the link above). It's non-blocking, fast, easy and reliable. Todd Ditchendorf also created some very useful tools for working with XMLRPC and SOAP servers, available here: http://scan.dalo.us/ Brad On Aug 31, 2008, at 9:30 AM, Sam Schroeder wrote: Hi all, I'm new to Cocoa development and I'm trying to learn the basics of sending HTTP GETs and POSTs from Cocoa. I've been reading up on NSURL and searching for decent sample code. However, I've been unable to find something simple that _just_ explains how to send a GET and capture the returned results. My google_fu is weak. My ultimate goal is to send and receive XML (or maybe JSON) requests over HTTP, but first I want to understand simple GETs and POSTs. Any links or sample code would be greatly appreciated. -- Thanks, Sam ___ 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/bradgibbs%40mac.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: Newb Question re NSUserDefaults and Ints
Thanks for all of the responses. After some monkeying around, I figured out that I'd used an NSNumber where I should have used an NSString. The code is now compiling and running happily. While I did learn some things from this, I'm confused about NSUserDefaults and the values it can store. I created an NSMutableDictionary to register the defaults, which is, I believe archived as a property list. Floats can be associated with NSString keys and stored in dictionaries, and there are methods for floatForKey: and setFloat: forKey: so, storing floats in a dictionary is supported, but, according to my understanding of Apple's documentation, I can't archive floats in a property list. I thought that I needed to transform the float into an NSNumber before saving to NSUserDefaults, and then transform the NSNumber to a float before I could use it to set the gradient angle. In Introduction to User Defaults, Apple states: The NSUserDefaults class only supports the storage of objects that can be serialized to property lists. This limitation would seem to exclude many kinds of objects, such as NSColor and NSFont objects, from the user default system. But if objects conform to the NSCoding protocol they can be archived to NSData objects, which are property list– compatible objects. For information on how to do this, see “Storing NSColor in User Defaults“; although this article focuses on NSColor objects, the procedure can be applied to any object that can be archived. In the Property List Programming Guide, Apple states: If a property list object is a container (an array or dictionary), all objects contained within it must also be supported property list objects. (Arrays and dictionaries can contain objects not supported by the architecture, but are then not property lists, and cannot be saved and restored with the various property list methods.) Moreover, although dictionary keys in NSDictionary and CFDictionary are defined to be an object of any type, for property lists they must be string objects. Cocoa property lists organize data into named values and lists of values using these classes: NSArray NSDictionary NSData NSString (java.lang.String in Java) NSNumber (subclasses of java.lang.Number in Java) NSDate What am I not getting? Looking forward to not having to prefix my posts with Newb Question... Brad On Aug 29, 2008, at 9:07 PM, Graham Cox wrote: On 30 Aug 2008, at 2:04 pm, Graham Cox wrote: You can really tell I meant of course that you CAN'T really tell... G. ___ 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 [EMAIL PROTECTED]
Newb Question re NSUserDefaults and Ints
I'm having a hard time with what should be a simple task - storing an integer for a gradient angle as a user default and then updating the screen. When I quit the app and open it again, the NSTextField shows the last value I set for the gradient, but with the following code: - (IBAction)changeElementBarGradientAngle:(id)sender { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSLog(@gradient angle is %d, [elementBarGradientAngleTextField intValue]); [defaults setInteger:[elementBarGradientAngleTextField intValue] forKey:ICNElementBarGradientAngleKey]; NSLog(@Element bar angle is now: %d, [ICNElementBarGradientAngleKey intValue]); } I get: 2008-08-29 18:42:10.627 Icon[35645:10b] gradient angle is 75 2008-08-29 18:42:10.628 Icon[35645:10b] Element bar angle is now: 0 I've also tried turning the int into an NSNumber object and using defaults setObject: foKey: without success. It seems as though I have to use: [gradient drawInRect:[self bounds] angle: [ICNElementBarGradientAngleKey intValue]]; turning ICNElementBarGradientAngleKey back into an int, which makes me wonder, is setInteger in: [defaults setInteger:[elementBarGradientAngleTextField intValue] forKey:ICNElementBarGradientAngleKey]; meant to be used with an int, or an object, such as NSUInteger? What am I doing wrong? Thanks, Brad ___ 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 [EMAIL PROTECTED]
Re: Newb Question re NSUserDefaults and Ints
Thanks. I'd read that dictionaries and plists were particular in the types they accept, but I was looking at page 201 of Hillegass (3rd edition), which shows: - (void)setInteger:(int)value forKey:(NSString *)defaultName and - (int)integerForKey:(NSString *)defaultName and blindly followed Apple's NSUserDefaults documentation shows: - (void)setInteger:(NSInteger)value forKey:(NSString *)defaultName which makes more sense. Must be a typo in the book? On Aug 29, 2008, at 7:14 PM, Andrei Kolev wrote: Brad, You can't store an int into a Dictionary or user defaults. For the objects you can use, see here: http://developer.apple.com/documentation/Cocoa/Conceptual/PropertyLists/Articles/AboutPropertyLists.html#/ /apple_ref/doc/uid/20001010 NSNumber and NSString should work. Also, [ICNElementBarGradientAngleKey intValue] will try to turn the key into a number, not get it's value. You want to use: [[defaults objectForKey: ICNElementBarGradientAngleKey] intValue]; Andrei On 30.08.2008, at 04:54, Brad Gibbs wrote: I'm having a hard time with what should be a simple task - storing an integer for a gradient angle as a user default and then updating the screen. When I quit the app and open it again, the NSTextField shows the last value I set for the gradient, but with the following code: - (IBAction)changeElementBarGradientAngle:(id)sender { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSLog(@gradient angle is %d, [elementBarGradientAngleTextField intValue]); [defaults setInteger:[elementBarGradientAngleTextField intValue] forKey:ICNElementBarGradientAngleKey]; NSLog(@Element bar angle is now: %d, [ICNElementBarGradientAngleKey intValue]); } I get: 2008-08-29 18:42:10.627 Icon[35645:10b] gradient angle is 75 2008-08-29 18:42:10.628 Icon[35645:10b] Element bar angle is now: 0 I've also tried turning the int into an NSNumber object and using defaults setObject: foKey: without success. It seems as though I have to use: [gradient drawInRect:[self bounds] angle: [ICNElementBarGradientAngleKey intValue]]; turning ICNElementBarGradientAngleKey back into an int, which makes me wonder, is setInteger in: [defaults setInteger:[elementBarGradientAngleTextField intValue] forKey:ICNElementBarGradientAngleKey]; meant to be used with an int, or an object, such as NSUInteger? What am I doing wrong? Thanks, Brad ___ 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/andreikolev %40mac.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: Newb Question re NSUserDefaults and Ints
Well, it appears that I need to convert either an NSNumber or an NSString to a CGFloat, rather than an int: - (void)drawInRect:(NSRect)rect angle:(CGFloat)angle There don't appear to be any methods in either NSNumber or NSString to do this On Aug 29, 2008, at 7:36 PM, Brad Gibbs wrote: Thanks. I'd read that dictionaries and plists were particular in the types they accept, but I was looking at page 201 of Hillegass (3rd edition), which shows: - (void)setInteger:(int)value forKey:(NSString *)defaultName and - (int)integerForKey:(NSString *)defaultName and blindly followed Apple's NSUserDefaults documentation shows: - (void)setInteger:(NSInteger)value forKey:(NSString *)defaultName which makes more sense. Must be a typo in the book? On Aug 29, 2008, at 7:14 PM, Andrei Kolev wrote: Brad, You can't store an int into a Dictionary or user defaults. For the objects you can use, see here: http://developer.apple.com/documentation/Cocoa/Conceptual/PropertyLists/Articles/AboutPropertyLists.html#/ /apple_ref/doc/uid/20001010 NSNumber and NSString should work. Also, [ICNElementBarGradientAngleKey intValue] will try to turn the key into a number, not get it's value. You want to use: [[defaults objectForKey: ICNElementBarGradientAngleKey] intValue]; Andrei On 30.08.2008, at 04:54, Brad Gibbs wrote: I'm having a hard time with what should be a simple task - storing an integer for a gradient angle as a user default and then updating the screen. When I quit the app and open it again, the NSTextField shows the last value I set for the gradient, but with the following code: - (IBAction)changeElementBarGradientAngle:(id)sender { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSLog(@gradient angle is %d, [elementBarGradientAngleTextField intValue]); [defaults setInteger:[elementBarGradientAngleTextField intValue] forKey:ICNElementBarGradientAngleKey]; NSLog(@Element bar angle is now: %d, [ICNElementBarGradientAngleKey intValue]); } I get: 2008-08-29 18:42:10.627 Icon[35645:10b] gradient angle is 75 2008-08-29 18:42:10.628 Icon[35645:10b] Element bar angle is now: 0 I've also tried turning the int into an NSNumber object and using defaults setObject: foKey: without success. It seems as though I have to use: [gradient drawInRect:[self bounds] angle: [ICNElementBarGradientAngleKey intValue]]; turning ICNElementBarGradientAngleKey back into an int, which makes me wonder, is setInteger in: [defaults setInteger:[elementBarGradientAngleTextField intValue] forKey:ICNElementBarGradientAngleKey]; meant to be used with an int, or an object, such as NSUInteger? What am I doing wrong? Thanks, Brad ___ 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/andreikolev%40mac.com This email sent to [EMAIL PROTECTED] ___ 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/bradgibbs%40mac.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Preferred Wrapper for TCP Sockets Over Local Network?
Hi, I'm looking for a Cocoa class to establish a TCP socket with another machine on a local network (non-OS X). I've found Omni Networking, AsyncSocket and NetSocket. I've read conflicting reports of the suitability of NSSocketPort for non-DO-related work. I would like to be able to use an SSL certificate, but, beyond that, my needs aren't exotic. Ease-of-use and reliability would be a big plus. I've also considered a Ruby class that would handle the TCP messaging and pass responses back to the Cocoa-based app. Any suggestions? Thanks, Brad ___ 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 [EMAIL PROTECTED]
[NEWB] Filling a rect with an Image
I'm trying to create a view with a background image, but getting error after error... - (void)drawRect:(NSRect)rect { NSRect bounds = [self bounds]; NSImage *background = [[NSImage alloc] init]; [background setImage:@ScrollBackground]; [[NSColor colorWithPatternImage:background] set]; [NSBezierPath fillRect:bounds]; } I've added a .png named ScrollBackground to my Resources folder. The code compiles but I get a warning: NSImage may not respond to '- setImage'. How can I make this right? Thanks. Brad ___ 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 [EMAIL PROTECTED]
Re: [NEWB] Filling a rect with an Image
Thanks. I was looking at NSImageView (which does have a setImage: method). On Aug 6, 2008, at 8:58 AM, Kyle Sluder wrote: On Wed, Aug 6, 2008 at 11:50 AM, Brad Gibbs [EMAIL PROTECTED] wrote: I've added a .png named ScrollBackground to my Resources folder. The code compiles but I get a warning: NSImage may not respond to '- setImage'. That would be because, indeed, NSImage does not respond to -setImage. http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSImage_Class/Reference/Reference.html How can I make this right? Use the +[NSImage imageNamed:] convenience constructor. You're best off doing this once and stuffing it in an ivar; just remember to retain it. --Kyle Sluder ___ 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 [EMAIL PROTECTED]
Newb Question re Messaging and Return Values
I'm having a hard time understanding return values and maybe messaging in general. I've looked through Programming in Objective-C, Hillegass Third Edition and through Apple's documentation, but don't seem to know enough to find the answer or a proper example I can implement. I have a view controller that handles button presses, tracks variables and updates button states and text fields for a number of devices represented on the UI. A button press - (IBAction)statusQuery:(id)sender; sends a message from the view controller to an object named device. The device object has a method - (NSString *)statusQuery { [webServer getVariableValueByName:@status]; } webServer is an instance of a class that handles HTTP Posts to a web server on my local network via NSURLConnection. This is working well and webServer is getting the expected responses and logging them to the console. But, I can't figure out how to send the response string from the connectionDidFinishLoading method of the webServer object back to the device's statusQuery method, which needs to parse the response and send the parsed response back to the view controller to update the UI. I'm hoping for a generic message that can send any response back to any object that invokes the NSURLConnection method. connectionDidFinishLoading is set to return (NSString *). Is it possible to have the delegate method connectionDidFinishLoading send its response back to the object that invoked the NSURLConnection request? If so, what is the proper syntax? Thanks. Brad ___ 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 [EMAIL PROTECTED]
Re: Newb Question re Messaging and Return Values
Looking at my problem further, I'm thinking I should make webServer a delegate of each of the devices. That would allow me to encapsulate the HTTP Posts and Gets for all of the devices in a single class. A device's methods could invoke the webServer delegate when they need to send information to the server or get information back. The webServer delegate would return the response to the device method that called the webServer method and that method could parse the response and update the UI directly or through an NSNotification. Does this sound right? Thanks again. On Jul 24, 2008, at 11:00 AM, Brad Gibbs wrote: I'm having a hard time understanding return values and maybe messaging in general. I've looked through Programming in Objective- C, Hillegass Third Edition and through Apple's documentation, but don't seem to know enough to find the answer or a proper example I can implement. I have a view controller that handles button presses, tracks variables and updates button states and text fields for a number of devices represented on the UI. A button press - (IBAction)statusQuery:(id)sender; sends a message from the view controller to an object named device. The device object has a method - (NSString *)statusQuery { [webServer getVariableValueByName:@status]; } webServer is an instance of a class that handles HTTP Posts to a web server on my local network via NSURLConnection. This is working well and webServer is getting the expected responses and logging them to the console. But, I can't figure out how to send the response string from the connectionDidFinishLoading method of the webServer object back to the device's statusQuery method, which needs to parse the response and send the parsed response back to the view controller to update the UI. I'm hoping for a generic message that can send any response back to any object that invokes the NSURLConnection method. connectionDidFinishLoading is set to return (NSString *). Is it possible to have the delegate method connectionDidFinishLoading send its response back to the object that invoked the NSURLConnection request? If so, what is the proper syntax? Thanks. Brad ___ 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/bradgibbs%40mac.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Help with Messages without a matching method signature... issue
I read the Newbie Question on a method signature thread from June 4 a few times, but, either that isn't the problem I'm having, or I'm not understanding the solution... Any help would be greatly appreciated. On compile, I get the following warnings: warning: 'Class2' may not respond to '+sendMSG:toPort:' warning: (Messages without a matching method signature will be assumed to return 'id' and accept '...' as arguments. And clicking a button produces the following in the Console: 2008-07-22 11:03:06.824 OSX Interface[37304:10b] *** +[Class2 sendMSG:toPort:]: unrecognized selector sent to class 0x4080 Below is the offending code: Class 1 - This class provides IBActions, each of which calls the sendMSG: toPort: method of Class 2. The arguments for the methods in this class are used to construct NSStrings in Class 2. Class 2 - The arguments sent from a button in Class 1 provide two strings, which are used to compose a new NSString, which is sent to another device on the network. @interface Class1 : NSObject { } - (IBAction)powerOn:(id)sender; @implementation Class1 - (IBAction)powerOn:(id)sender { [Class2 sendMSG:@P1P1 toPort:@1]; @interface Class2 : NSObject { } - (NSString *)sendString:(NSString *)stringToSend; - (void)sendMSG:(NSString *)string toPort:(NSString *)port; @implementation Class2 - (NSString *)sendString:(NSString *)stringToSend { NSData *postData = [stringToSend dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *postLength = [NSString stringWithFormat:@%d, [postData length]]; NSMutableURLRequest *theRequest=[[[NSMutableURLRequest alloc] init] autorelease]; ... response = [[NSString alloc] initWithData:receivedData encoding:NSASCIIStringEncoding]; return response; } - (void)sendMSG:(NSString *)string toPort:(NSString *)port { NSString *stringToSend; stringToSend = [[NSString alloc] initWithFormat:@method=MSGSendparam1=%@param2=%@param3=200, port, string]; NSLog(@String being sent: %@, stringToSend); [self sendString:stringToSend]; } ___ 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 [EMAIL PROTECTED]
Re: Help with Messages without a matching method signature... issue
It's in the file, it's just that the warning message pushed the brace down and out of my select - copy - paste to e-mail. Sorry for the confusion. On Jul 22, 2008, at 12:35 PM, Steve Bird wrote: On Jul 22, 2008, at 3:28 PM, Brad Gibbs wrote: Below is the offending code: Class 1 - This class provides IBActions, each of which calls the sendMSG: toPort: method of Class 2. The arguments for the methods in this class are used to construct NSStrings in Class 2. Class 2 - The arguments sent from a button in Class 1 provide two strings, which are used to compose a new NSString, which is sent to another device on the network. @interface Class1 : NSObject { } - (IBAction)powerOn:(id)sender; @implementation Class1 - (IBAction)powerOn:(id)sender { [Class2 sendMSG:@P1P1 toPort:@1]; --- Where's the closing brace here? @interface Class2 : NSObject { } - (NSString *)sendString:(NSString *)stringToSend; - (void)sendMSG:(NSString *)string toPort:(NSString *)port; Steve Bird Culverson Software - Elegant software that is a pleasure to use. www.Culverson.com (toll free) 1-877-676-8175 ___ 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 [EMAIL PROTECTED]
Re: Help with Messages without a matching method signature... issue
That was it Feeling foolish, but grateful. Thanks. On Jul 22, 2008, at 12:41 PM, Charles Steinman wrote: -sendMSG:toPort: is an instance method, which should be sent to an object. You are sending it to Class2, which is a class rather than an instance of that class. Cheers, Chuck --- On Tue, 7/22/08, Brad Gibbs [EMAIL PROTECTED] wrote: From: Brad Gibbs [EMAIL PROTECTED] Subject: Help with Messages without a matching method signature... issue To: Cocoa List cocoa-dev@lists.apple.com Date: Tuesday, July 22, 2008, 12:28 PM I read the Newbie Question on a method signature thread from June 4 a few times, but, either that isn't the problem I'm having, or I'm not understanding the solution... Any help would be greatly appreciated. On compile, I get the following warnings: warning: 'Class2' may not respond to '+sendMSG:toPort:' warning: (Messages without a matching method signature will be assumed to return 'id' and accept '...' as arguments. And clicking a button produces the following in the Console: 2008-07-22 11:03:06.824 OSX Interface[37304:10b] *** +[Class2 sendMSG:toPort:]: unrecognized selector sent to class 0x4080 Below is the offending code: Class 1 - This class provides IBActions, each of which calls the sendMSG: toPort: method of Class 2. The arguments for the methods in this class are used to construct NSStrings in Class 2. Class 2 - The arguments sent from a button in Class 1 provide two strings, which are used to compose a new NSString, which is sent to another device on the network. @interface Class1 : NSObject { } - (IBAction)powerOn:(id)sender; @implementation Class1 - (IBAction)powerOn:(id)sender { [Class2 sendMSG:@P1P1 toPort:@1]; @interface Class2 : NSObject { } - (NSString *)sendString:(NSString *)stringToSend; - (void)sendMSG:(NSString *)string toPort:(NSString *)port; @implementation Class2 - (NSString *)sendString:(NSString *)stringToSend { NSData *postData = [stringToSend dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *postLength = [NSString stringWithFormat:@%d, [postData length]]; NSMutableURLRequest *theRequest=[[[NSMutableURLRequest alloc] init] autorelease]; ... response = [[NSString alloc] initWithData:receivedData encoding:NSASCIIStringEncoding]; return response; } - (void)sendMSG:(NSString *)string toPort:(NSString *)port { NSString *stringToSend; stringToSend = [[NSString alloc] initWithFormat:@method=MSGSendparam1=%@param2=%@param3=200, port, string]; NSLog(@String being sent: %@, stringToSend); [self sendString:stringToSend]; } ___ 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/acharlieblue%40yahoo.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: NSViewController and View Swapping
Thanks for the quick response and the links. NSTabView with tabs on the bottom is exactly what I'm looking for, except, I'm writing a fullscreen app with stylized NSImage buttons, rather than tabs. I'm still looking through the ViewController sample code. Given the number of single window apps out there today, it seems like swapping views should be one of those common things that is easy to accomplish with Cocoa, rather than an uncommon thing that's merely possible... On Jul 13, 2008, at 10:46 PM, Nathan Kinsinger wrote: On Jul 13, 2008, at 11:15 PM, Brad Gibbs wrote: I'm trying to create a Cocoa app with a single window with a number of views that get swapped in and out, using an NSViewController for each of the views. I have a series of buttons along the bottom of the UI in a custom view, and another custom view above the row of buttons. When button A is pressed, view A should appear in the custom view above the row of buttons, and button A should be turned on. When button B is pressed, view A should be replaced by View B, button A should turn off and button B should turn on. Ultimately, I'd like to do this with an animation (view A fades out and view B fades in). For now, I'd be happy just replacing A with B. I haven't been able to find much in the documentation about NSViewController for Cocoa. I have the Hillegass book, but the view swapping example in Chapter 29 is done with a document-based application and the views there are contained in an NSBox: ... NSView *v = [vc view]; [box setContentView:v]; ... I don't know Cocoa well enough to adapt this example for a non- document-based application without an NSBox. Could someone please point me to documentation for NSViewController, other than the NSViewController Reference, or provide me with a quick explanation or example code that will do this? I've read through the Katidev blog on XSViewController and XSWindowController, but, again, that's a document-based example, and it doesn't explicitly provide methods for replacing one view with another. Thanks in advance. Brad There is an example at: http://developer.apple.com/samplecode/ViewController/index.html Also what you are describing sounds a lot like an NSTabView with the style set to Bottom Tabs. Try creating one in IB and playing with it. Also look at: http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/TabView/TabView.html and an example with animation at: http://developer.apple.com/samplecode/Reducer/index.html --Nathan ___ 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 [EMAIL PROTECTED]
Re: NSViewController and View Swapping
OK, thanks for the tip. I think this will work well for the situation I described. But, that screen (with its tab view and all of the custom views to be made available from within the tab view) is one of several screens like it. The other tab views will contain different numbers of tabs. The user will be able to choose among the screens from a pop-up menu on a status bar at the top of the screen. So, I still need a way to swap out one set of tab views with another, without using a box, in a non-document-based application. So, I think I still need to solve the problem of how to change: [box setContentView:v] to swap out one custom tab view with another, so that when the user selects another set of tab views, the current tab view is swapped out and replaced by the newly-selected tab view. Thanks again. Brad On Jul 14, 2008, at 12:17 AM, Scott Anguish wrote: you can still do it with NSTabView use setTabViewType to one of the following NSNoTabsBezelBorder = 4, NSNoTabsLineBorder = 5, NSNoTabsNoBorder = 6 have your button actions change the visible tab using one of... - (void)selectTabViewItemAtIndex:(NSInteger)index - (void)selectTabViewItemWithIdentifier:(id)identifier - (void)selectTabViewItem:(NSTabViewItem *)tabViewItem On 14-Jul-08, at 2:04 AM, Brad Gibbs wrote: Thanks for the quick response and the links. NSTabView with tabs on the bottom is exactly what I'm looking for, except, I'm writing a fullscreen app with stylized NSImage buttons, rather than tabs. I'm still looking through the ViewController sample code. Given the number of single window apps out there today, it seems like swapping views should be one of those common things that is easy to accomplish with Cocoa, rather than an uncommon thing that's merely possible... On Jul 13, 2008, at 10:46 PM, Nathan Kinsinger wrote: On Jul 13, 2008, at 11:15 PM, Brad Gibbs wrote: I'm trying to create a Cocoa app with a single window with a number of views that get swapped in and out, using an NSViewController for each of the views. I have a series of buttons along the bottom of the UI in a custom view, and another custom view above the row of buttons. When button A is pressed, view A should appear in the custom view above the row of buttons, and button A should be turned on. When button B is pressed, view A should be replaced by View B, button A should turn off and button B should turn on. Ultimately, I'd like to do this with an animation (view A fades out and view B fades in). For now, I'd be happy just replacing A with B. I haven't been able to find much in the documentation about NSViewController for Cocoa. I have the Hillegass book, but the view swapping example in Chapter 29 is done with a document-based application and the views there are contained in an NSBox: ... NSView *v = [vc view]; [box setContentView:v]; ... I don't know Cocoa well enough to adapt this example for a non- document-based application without an NSBox. Could someone please point me to documentation for NSViewController, other than the NSViewController Reference, or provide me with a quick explanation or example code that will do this? I've read through the Katidev blog on XSViewController and XSWindowController, but, again, that's a document-based example, and it doesn't explicitly provide methods for replacing one view with another. Thanks in advance. Brad There is an example at: http://developer.apple.com/samplecode/ViewController/index.html Also what you are describing sounds a lot like an NSTabView with the style set to Bottom Tabs. Try creating one in IB and playing with it. Also look at: http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/TabView/TabView.html and an example with animation at: http://developer.apple.com/samplecode/Reducer/index.html --Nathan ___ 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/scott%40cocoadoc.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Re: Distributed Objects connection went invalid while waiting for a reply
Is Distributed Objects still the preferred method for communicating among computers on a local network? It's been hinted that DO may be deprecated in the not-so-distant future. When I asked about DO recently, I was pushed in the direction of Jens Alfke's Blip. Thanks. On Jul 9, 2008, at 2:14 AM, Mike Bellerby wrote: I use DOs on 10.3, 10.4 and 10.5. They work correctly on all versions. From your description I'm not entirely sure what you are trying to do. Could you post a code example and I try to help. Cheers Mike On 9 Jul 2008, at 01:11, Hamish Allan wrote: I'm seeing connection went invalid while waiting for a reply in a DO callback. The client passes self in a call to the server; some time later, the server calls a method on that client (proxy), the program hangs for a second or so, the connection went invalid connection appears, but the method call is successful anyway, so it would appear that the DO machinery is re-connecting everything okay. According to the debugger, the message appears as a result of an uncaught NSException from -[NSConnection sendInvocation:internal:], called from -[NSDistantObject forwardInvocation]. Server and client are both properly retained. There seem to be a lot of messages of late on Apple's forums about problems with iSync (10.5.4) and even Interface Builder (10.5.3, IB3.1beta6) in which this message is reported. Is it perhaps a bug in recent versions of the OS rather than in my code? Hamish P.S. This question has been asked before, but the OP didn't get an answer (http://www.cocoabuilder.com/archive/message/cocoa/2006/12/29/176458 ) ___ 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/mdb%40realvnc.com This email sent to [EMAIL PROTECTED] ___ 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/bradgibbs%40mac.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
IB Plugin Exchange / Apple Pro Apps Elements?
Is there an IB 3.0 plugin exchange I haven't been able to find through Google? Some place where developers could share or trade IB plugins they've built? Specifically, I'm looking for the darker look-and-feel of Apple's Pro apps, like Aperture and MainStage from Logic Studio, in particular. Thanks. Brad ___ 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 [EMAIL PROTECTED]
Newbie Question re Allocation Initialization
On pages 36-7 of Aaron Hillegass' new book, he provides sample code for a Foundation Tool called Lottery. The code is below: NSMutableArray *array; array = [[NSMutableArray alloc] init]; int i; for (i = 0; i 10; i++) { NSNumber *newNumber = [[NSNumber alloc] initWithInt:(i * 3)]; [array addObject:newNumber]; } for (i = 0; i 10; i++) { NSNumber *numberToPrint = [array objectAtIndex:i]; NSLog(@The number at index %d is %@, i, numberToPrint); } He allocates memory for and initializes the first two objects, array and newNumber. But, in the second 'for loop', numberToPrint is neither allocated nor initialized, but the program compiles and runs as expected. I replaced the second 'for loop' with the following, just to see what would happen: for (i = 0; i 10; i++) { NSNumber *numberToPrint; numberToPrint = [[NSNumber alloc] init]; numberToPrint = [array objectAtIndex:i]; NSLog(@The number at index %d is %@, i, numberToPrint); } It compiled and ran as expected, too. But, when I tried to eliminate allocation and initialization for newNumber in the first 'for loop', the app threw an exception. I don't see an explanation in the book re why numberToPrint can be, but doesn't need to be allocated or initialized. Is it because numberToPrint is simply pointing to newNumber objects in the array that have already been allocated and initialized? Could someone please explain this? Thank you. Brad ___ 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 [EMAIL PROTECTED]
Re: Newbie Question re Allocation Initialization
Thanks to all who replied. It all makes perfect sense, I just didn't know that not alloc'ing and init'ing was a fully legit move. I will add Masters of the Void to the already tall stack of reading material. On May 19, 2008, at 6:03 PM, Jack Repenning wrote: On May 19, 2008, at 5:18 PM, Brad Gibbs wrote: Is it because numberToPrint is simply pointing to newNumber objects in the array that have already been allocated and initialized? Yes, both newNumber and numberToPrint are merely pointers to some object. These objects are created in the first loop (the alloc/init sequence you noticed), and then stored into the array (the 1addObject: call). In the second loop, they already exist, but we want to grab onto one so we can print it; numberToPrint is set to point to an existing object inside the array (via -objectAtIndex:); since the object already exists, it doesn't need to be alloc'ed (allocated as sufficient blank memory to hold the object) or init'ed (fixed up to actually be such an object). -==- Jack Repenning [EMAIL PROTECTED] Project Owner SCPlugin http://scplugin.tigris.org Subversion for the rest of OS X ___ 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 [EMAIL PROTECTED]
Re: starting...
I also began learning Objective-C programming about a month ago, without any prior C experience. I've found Stephen Kochan's Programming in Objective-C to be very useful. He claims readers will be able to follow along without prior knowledge of C. That's been true for me so far (I'm about 3/4 of the way through it). I'd recommend that book first, then Apple's Objective-C 2.0 document to update what you've learned in Kochan's book, then Aaron Hillegass' book, the third edition of which is due to be available in about a month. On Apr 25, 2008, at 2:35 PM, Bertil Holmberg wrote: I´m studying objective-C around one month and have some doubts. Have you studied the Objective-C 2.0 document? It should answer your questions about Properties and the @synthesize directive as these are new additions to the language. Although handy in the long run, they do make things more difficult for the newbie, as do other abstract additions such as bindings... http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/chapter_1_section_1.html Regards, Bertil___ 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/bradgibbs%40mac.com This email sent to [EMAIL PROTECTED] ___ 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 [EMAIL PROTECTED]
Best Way to Replicate CURL in Cocoa?
Hi, I'm trying to communicate with a Linux-based device that sits on the local network from multiple Macs (also on the local network). Documentation for the Linux device claims that it provides an XML-RPC server and that it responds to SOAP requests. However, XML-RPC and SOAP AppleScripts result in repeated failure. do shell script curl, however, works every time. I suspect that the device doesn't actually respond to tree-based XML with tags, but it does respond when the full message (which consists of a method name and 0-5 parameters, depending on the method) are all posted in a single string. Given this, I'm suspecting it responds to HTTP Posts, rather than XML- RPC or SOAP requests. I've seen references to a Cocoa wrapper for curl, but they're from 2002. Looking through Apple's documentation for a more up-to-date method for sending HTTP Posts, it appears that I could make HTTP Posts from CFNetwork (CFHTTPMessage with a POST method) or through NSURLRequest. The strings I'll be sending will be less than 50 characters long. The device will also be sending response strings of approximately the same length that will need to be parsed in the Cocoa app. Again, it doesn't appear that the responses are XML (they're all in a single string, no tags). Messaging to the device will be driven by button presses in the UI. A single button press could invoke up to 5 or 6 messages at once, but the button presses will likely be infrequent. A single instance of the app could be running on multiple machines, with each machine making requests to the device simultaneously. Given this information, what would be the most efficient and robust method for sending HTTP Posts, CF Network, NSURLRequest or something completely different? Thanks in advance. Brad ___ 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 [EMAIL PROTECTED]
Re: Best Way to Replicate CURL in Cocoa?
Thanks for the reply. On Apr 1, 2008, at 8:51 AM, Jens Alfke wrote: On 1 Apr '08, at 5:39 AM, Brad Gibbs wrote: Given this, I'm suspecting it responds to HTTP Posts, rather than XML-RPC or SOAP requests. But both those protocols do use HTTP POSTs. (XML-RPC can use alternate transports, but in practice it's almost always over HTTP.) Fair point. I didn't use the correct terminology (which stems from the fact that I'm stumbling around a bit while learning this). I think it's more accurate to say that the device doesn't respond well to the tags in XML-RPC or SOAP. It does better with a single string. I've seen references to a Cocoa wrapper for curl, but they're from 2002. Looking through Apple's documentation for a more up-to-date method for sending HTTP Posts, it appears that I could make HTTP Posts from CFNetwork (CFHTTPMessage with a POST method) or through NSURLRequest. Pretty much every Cocoa app that does HTTP uses NSURLRequest. It's definitely the way to go for what you're doing. Create a mutable one, then use its HTTP-specific setters to configure the method and headers and set a body. —Jens ___ 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 [EMAIL PROTECTED]