Re: Store a file vs create on the fly?
On Jan 19, 2011, at 2:30 AM, Jeremy Matthews wrote: So I have a simple app which, in essence, creates a text file with some items determined by the user (kind of like an old-fashioned Mad Libs page). Most of the file does not change...I just change a few portions based upon checkbox states, textfield contents, etc. Question is: should I have that file pre-created within the app bundle, load it, make changes, and save out? Or, should I store the text in some strings within code and just write out the file when needed? I usually do the former. Strings in code are awkward to edit (escaping line breaks and breaking strings onto multiple lines), so I usually just create a text file, put in some placeholder that I can search for and replace, then load the thing into an NSMutableString, search replace, write it where it should end up. Also, if you have comments or other localizable data in the template you can take advantage of the built-in localization facilities more easily. Cheers, -- Uli Kusterer The Witnesses of TeachText are everywhere... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Sending multiple files via Bluetooth using GameKit
You can but keep in mind the following: The max packet size is 87K so for larger blocks of data, you will have to break things up. You will need a mini state machine to keep track of what was sent vs. what is left to send. And will of course need all the logic to handle error conditions, retries, etc. What is your specific goal? Perhaps using GameKit is not the correct choice. Sent from my iPhone On Jan 19, 2011, at 11:58 PM, charisse napeÿf1as cnape...@yahoo.com wrote: Hello Guys, Is there any way I can send multiple files via Bluetooth transfer using GameKit? I have already done the single file transfer but how about if I send multiple files without sacrificing speed? Can I do it synchronously? I am new to this so maybe somebody can point me to the right direction? Thanks, Charisse ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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/rsharp%40mac.com This email sent to rsh...@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
printing a different representation than what is on the screen
I'm working on a document-based application that has a couple tabs. Most of the tabs contain NSTableViews, NSTextFields, etc. I want to provide a way for the user to print the data contained in them (just text, possibly with some grid lines), but not the actual table view. I've read through (admittedly fairly quickly) the Printing Topics for Cocoa document from Apple but it is more geared towards printing what you see on the screen. I also may want to print different data depending on which tab the user is on. What is the appropriate way to do this? Do I override drawRect: for each tab such as: - (void)drawRect:(NSRect)r { if ( [NSGraphicsContext currentContextDrawingToScreen] ) { [super drawRect:r] } else { // somehow send drawing instructions for the text I want } } or do I somehow create an off screen view that I draw the text and grid lines into? A pointer in the correct direction or pointers to other documentation or examples would be appreciated. Thanks, Dave ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: printing a different representation than what is on the screen
On Thu, Jan 20, 2011 at 9:24 AM, Dave Reed davel...@mac.com wrote: I'm working on a document-based application that has a couple tabs. Most of the tabs contain NSTableViews, NSTextFields, etc. I want to provide a way for the user to print the data contained in them (just text, possibly with some grid lines), but not the actual table view. I've read through (admittedly fairly quickly) the Printing Topics for Cocoa document from Apple but it is more geared towards printing what you see on the screen. I also may want to print different data depending on which tab the user is on. What is the appropriate way to do this? Do I override drawRect: for each tab such as: - (void)drawRect:(NSRect)r { if ( [NSGraphicsContext currentContextDrawingToScreen] ) { [super drawRect:r] } else { // somehow send drawing instructions for the text I want } } or do I somehow create an off screen view that I draw the text and grid lines into? I would take the first approach if (as is mentioned in the docs this example is from) drawing the view is mostly the same for both print and screen, except for a few embellishments (crop marks, footnotes, etc.) added to the print version. In your case, it sounds like you want to print something entirely different than what appears on-screen. In that case, I would take the second approach, in one of two ways: If what you want to print can be expressed in HTML (and it sounds like that may be the case), I'd create an off screen instance of WebView, feed it some HTML, and send it a -print message. In many cases this can be easier to maintain; you can take a template-based approach where the layout information is contained in an external template, which your app loads fills in to generate the HTML it prints. That gives you the ability to tweak the layout appearance using tools that are designed for just that (such as iWeb or Dreamweaver), rather than having to modify a custom -drawRect: for each change. Alternatively, you can subclass NSView with your customized -drawRect:, create an off screen instance of your subclass, and send it a -print message. sherm-- -- Cocoa programming in Perl: http://camelbones.sourceforge.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
On Jan 19, 2011, at 8:24 PM, Eric Gorr wrote: On Jan 19, 2011, at 8:19 PM, Graham Cox wrote: On 20/01/2011, at 12:14 PM, Eric Gorr wrote: The table is also owned by the the scrolling view and therefore the window and would not be deallocated here...it will stick around long after the controller is deallocated. You're right, but since the table owns its columns, it is still the table's job to manage them, not yours. Agreed. I never liked the solution, which is one of the reasons why I posted the message to begin with. Glad you got it solved anyway, but it's nice to know that the best solution turned out to be the correct, documented and recommended one after all! Indeed. Learned stuff too...I had not fully understood the rules regarding weak references before. Hopefully this thread has helped others as well. I was wondering why this was such a surprise to me, so I went hunting through sample code, books, etc. I cannot seem to find any sample code, either in books (even Cocoa Programming for Mac OS X (3rd Edition)) or in Apple's own sample code where they follow these rules. I think that is why it has surprised me. I sure there must be some out there that do follow these rules, but the examples seem to be rare at the moment. For a specific example, check out the AnimatedTableView sample code from Apple. The ATColorTableController class is a datasource for the table, but it's dealloc looks like: - (void)dealloc { [_colorList release]; [_colorNames release]; [_window release]; [super dealloc]; } Based on my current understanding, the dealloc should be setting it's datasource and delegate to nil. Correct? If so, I will file a bug. Or, what is the reason why the code as written is correct? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
On Thu, Jan 20, 2011 at 7:22 AM, Eric Gorr mail...@ericgorr.net wrote: Based on my current understanding, the dealloc should be setting it's datasource and delegate to nil. Correct? If so, I will file a bug. No. It is the responsibility of the delegate to set the table view's backpointer to nil. The delegate usually has an owning reference to the table view. If -dealloc is being called on the table view, but the delegate still has a pointer to the table view, that means a memory management error has occurred. --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: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
On Jan 20, 2011, at 12:17 PM, Kyle Sluder wrote: On Thu, Jan 20, 2011 at 7:22 AM, Eric Gorr mail...@ericgorr.net wrote: Based on my current understanding, the dealloc should be setting it's datasource and delegate to nil. Correct? If so, I will file a bug. No. It is the responsibility of the delegate to set the table view's backpointer to nil. The delegate usually has an owning reference to the table view. If -dealloc is being called on the table view, but the delegate still has a pointer to the table view, that means a memory management error has occurred. I think you misunderstood and I didn't write that sentence as clearly as I could. For a specific example, check out the AnimatedTableView sample code from Apple. The ATColorTableController class is a datasource for the table, but it's dealloc looks like: - (void)dealloc { [_colorList release]; [_colorNames release]; [_window release]; [super dealloc]; } Based on my current understanding, the table controller's dealloc (above) should be setting the table datasource and delegate to nil. Correct? If so, I will file a bug. Or, what is the reason why the code as written is correct? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
On Jan 20, 2011, at 07:22, Eric Gorr wrote: I was wondering why this was such a surprise to me, so I went hunting through sample code, books, etc. I cannot seem to find any sample code, either in books (even Cocoa Programming for Mac OS X (3rd Edition)) or in Apple's own sample code where they follow these rules. I think that is why it has surprised me. I sure there must be some out there that do follow these rules, but the examples seem to be rare at the moment. Well, any answer to that is likely to be a bit speculative, but I think at least the following factors enter into it: 1. Apple people having been making this point for some time, but it hasn't widely been taken up by third party developers. This is one of those policies that's been more honored in the breach. 2. In many cases, failing to adhere to the policy *doesn't* lead to a crash, for unrelated reasons (the relevant objects are already owned by something else, for example). 3. As you've noted, it can be hard to keep a firm grip on which object needs to do what to whom at which time, especially when there are multiple delegate patterns in play. Sometimes it's tempting *not* to think it through, but just to do something or other, and wait to see if it fails. That's possibly what happened to the sample code. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
loop not running
I've got the following code that is almost identical to code I've got in another app. The other app works, this one doesn't. The only difference between the two is the variable names; - (IBAction)addItemsToOrder:sender;{ NSObject *order; order = [[Orders selectedObjects] objectAtIndex:0]; NSArray *newOrderProducts; newOrderProducts = [Products selectedObjects]; NSEnumerator *loop = [newOrderProducts objectEnumerator]; NSObject *product; NSLog(@Hello There!); //for each selected product: while ((product = [loop nextObject])) { NSLog(@Hello There! in while loop); //create new kitItem NSManagedObject *newOrderItem = [NSEntityDescription insertNewObjectForEntityForName:@CustomerOrderItems inManagedObjectContext:managedObjectContext]; //link new product to order [newOrderItem setValue:order forKey:@customerOrderRef]; //link new order item to product [newOrderItem setValue:product forKey:@orderItemProduct]; } } When I run this in the app, I see the first Hello There but nothing else in the log. There is definitely a Products order array in the interface, and it definitely has selected objects. I have table columns bound to the Products array so I can see they are selected. I've got the following in my header file as well; IBOutlet NSArrayController *Products; But I just can't see why it's not going into the loop? Many Thanks Amy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
Hi folks, I'm trying to figure out a clear guideline on how to handle weak references. Let's consider the following scenarios: 1- Say I have a button, and set its action/target (via a nib file) to call method on the controller. In the controller dealloc method, should the controller set the action/target of the button to nill? 2- Say I have a table view, and set its datasource/delegate (via a nib file) to the controller. In the controller dealloc method, should the controller set the datasource/delegate of the tableview to nill? What I'm interested in is what is the right thing to do here. That is, is the lack of explicit setting to nil of action/datasource/delegate to nill a bug? Thanks, Abdul ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
non-NSString values in model user info via xcode UI
Hi all, I have a Core Data model and I'd like to add some metadata about the entities/attributes/relationships. In most cases, strings are fine, but I'd also like to record arrays or even sub-dictionaries. This will reduce the amount of code in my app by a fair deal. As far as I can tell, the XCode UI only allows values added to the user info dictionary to be strings. I suppose I could use a delimted string and do [[userdict valueForKey:@key] componentsSeparatedByString:@delimiter]] wherever I access it to get an array, but since the goal is reducing the amount of code, this seems counterproductive. Any suggestions? Regards, Mikkel Eide Eriksen smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: loop not running
On Jan 20, 2011, at 11:48, Amy Heavey wrote: NSArray *newOrderProducts; newOrderProducts = [Products selectedObjects]; NSEnumerator *loop = [newOrderProducts objectEnumerator]; NSObject *product; NSLog(@Hello There!); //for each selected product: while ((product = [loop nextObject])) { NSLog(@Hello There! in while loop); //create new kitItem NSManagedObject *newOrderItem = [NSEntityDescription insertNewObjectForEntityForName:@CustomerOrderItems inManagedObjectContext:managedObjectContext]; //link new product to order [newOrderItem setValue:order forKey:@customerOrderRef]; //link new order item to product [newOrderItem setValue:product forKey:@orderItemProduct]; } The debugger is your friend here. Your code (apparently) demonstrates that [loop nextObject] is nil the first time through. That might be because the newOrderProducts array is empty. Or it could be that 'loop' is nil, which could be because 'newOrderProducts' is nil, which could be because 'Products' is nil. Your first step is to find out which of those unexpected conditions is true. Once you have the which, the why should follow. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Store a file vs create on the fly?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 1/20/11 2:21 AM, Uli Kusterer wrote: On Jan 19, 2011, at 2:30 AM, Jeremy Matthews wrote: So I have a simple app which, in essence, creates a text file with some items determined by the user (kind of like an old-fashioned Mad Libs page). Most of the file does not change...I just change a few portions based upon checkbox states, textfield contents, etc. Question is: should I have that file pre-created within the app bundle, load it, make changes, and save out? Or, should I store the text in some strings within code and just write out the file when needed? I usually do the former. Strings in code are awkward to edit (escaping line breaks and breaking strings onto multiple lines), so I usually just create a text file, put in some placeholder that I can search for and replace, then load the thing into an NSMutableString, search replace, write it where it should end up. Also, if you have comments or other localizable data in the template you can take advantage of the built-in localization facilities more easily. I fully agree. Another consideration that might not apply now but could at some point in the future is that if you ever have someone else work on the text templates, that someone else will not have to be a programmer if the templates are split out. Think along the lines of web development: we have CSS and templating to largely remove designers from touching code, which on balance probably makes both designers and developers happier. - -- Conrad Shultz Synthetiq Solutions www.synthetiqsolutions.com -BEGIN PGP SIGNATURE- Version: GnuPG/MacGPG2 v2.0.14 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk04mG0ACgkQaOlrz5+0JdWZmQCfbEw0mYqouOow9kRdvHvzBdZJ 5q4AnjYpnD/AkVKy2L2daCNsVIAxL/Gq =6B8r -END PGP SIGNATURE- ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: non-NSString values in model user info via xcode UI
On Jan 20, 2011, at 11:57, Mikkel Eide Eriksen wrote: I have a Core Data model and I'd like to add some metadata about the entities/attributes/relationships. In most cases, strings are fine, but I'd also like to record arrays or even sub-dictionaries. This will reduce the amount of code in my app by a fair deal. As far as I can tell, the XCode UI only allows values added to the user info dictionary to be strings. I suppose I could use a delimted string and do [[userdict valueForKey:@key] componentsSeparatedByString:@delimiter]] wherever I access it to get an array, but since the goal is reducing the amount of code, this seems counterproductive. Any suggestions? I don't see any way to get a non-string value into the dictionary via the data model window either, though there doesn't seem to be any inherent restriction on the user info dictionary generally. One way might be to put the information in a separate plist file, and set the entity's userInfo property programmatically. It looks like you'd have to be sure to do that before the model is actually used to access the data. Or, you might be able to use a regular attribute instead of user info, using the transformable type to get its value archived. That doesn't solve your UI problem, of course, but might be part of a solution if nothing else works. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: non-NSString values in model user info via xcode UI
Hi Quincey Thanks for the speedy reply. I'll look into having the root entity either parse from a plist or something similar. Hmm, it just occured to me that I can put json strings in the user info, and parse them back into the user info. That would enable me to put complex nested dictionaries arrays in there via the UI. Mikkel On 20/01/2011, at 21.26, Quincey Morris wrote: On Jan 20, 2011, at 11:57, Mikkel Eide Eriksen wrote: I have a Core Data model and I'd like to add some metadata about the entities/attributes/relationships. In most cases, strings are fine, but I'd also like to record arrays or even sub-dictionaries. This will reduce the amount of code in my app by a fair deal. As far as I can tell, the XCode UI only allows values added to the user info dictionary to be strings. I suppose I could use a delimted string and do [[userdict valueForKey:@key] componentsSeparatedByString:@delimiter]] wherever I access it to get an array, but since the goal is reducing the amount of code, this seems counterproductive. Any suggestions? I don't see any way to get a non-string value into the dictionary via the data model window either, though there doesn't seem to be any inherent restriction on the user info dictionary generally. One way might be to put the information in a separate plist file, and set the entity's userInfo property programmatically. It looks like you'd have to be sure to do that before the model is actually used to access the data. Or, you might be able to use a regular attribute instead of user info, using the transformable type to get its value archived. That doesn't solve your UI problem, of course, but might be part of a solution if nothing else works. smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Help on Cocoa Class references
Message: 3 Date: Wed, 19 Jan 2011 22:18:04 -0500 From: Scott Anguish sc...@cocoadoc.com Subject: Re: Help on Cocoa Class references To: Leanne Attard leanneatt...@yahoo.com Cc: cocoa-dev@lists.apple.com Message-ID: 8c659320-34f8-4b47-830d-796386224...@cocoadoc.com Content-Type: text/plain; charset=windows-1252 I‚m surprised nobody else mentioned this. The Java bridge isn‚t supported and you can no longer write Cocoa apps in Java. So you‚re much better off learning Obj-C or going fully Java. Or even Ruby Apple won‚t even be shipping Java with the OS in the future (there was an announcement about this recently). You‚ll need to get it from Oracle (who Apple transferred things to as I recall in another announcement) All Java Class References which may have existed (and only for public classes, none those were as I recall) are gone. The process for creating those docs are gone. We no longer support or generate them (I‚m in the documentation department). Sorry to be a wet noodle. Java 6 is still available and it is not deprecated. It provides the com.apple.eawt. The list of deprecated classes and methods of that package is here: http://developer.apple.com/library/mac/documentation/Java/Reference/JavaSE6_AppleExtensionsRef/api/deprecated-list.html Mac OS X port of the Open JDK 7, that has contributes from the original Apple source code, since the begin of january, also has com.apple.eawt package in its project status page. Though, I think we should concentrate on the Leanne's goal. She wants to draw over a Java AWT component using OpenGL and she wants to handle mouse events (and probably keyboard events). The only way to use OpenGL to draw over a Java AWT component is to implement a JNI based interface. Probably Java AWT components, in the Mac OS X implementation of Java, are already implemented through JNI and are probably derived from Cocoa native components (like NSView). So, probably, Leanne does not need to implement its own NSView and place it through CocoaComponent in the AWT window. What she need is to initialize a NSOpenGLPixelFormat and a NSOpenGLContext, using JNI and providing JNI functions to create, access and manipulate these objects. Furthermore she needs to implement JNI functions that wrap OpenGL interface. The rest of the operations can be done in pure Java code (included event handling). Since this is a long work and there are ready to use OpenGL Java bindings like LWJGL or JOGL, I suggest to use them. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Odd Crash when adding table columns manually
On Jan 19, 2011, at 4:51 PM, Lee Ann Rucker wrote: On Jan 19, 2011, at 3:21 PM, Corbin Dunn wrote: In general, it is good practice in your apps to set your delegate and datasource to nil. Who is to say something might cause a draw to happen, which would then message your (now dealloced) delegate? Ideally, NSTableView shouldn't message the delegate/datasource after the window is closed, but something extra setNeedsDisplay messages get thrown into it, causing it to happen, and crash. That is why your bug happened. 6728942 made an effort to reduce the display message. If I'd set them in my code I would agree, but I expect that if it's set by the nib setup code then it should cleared by the nib cleanup code. Yes, and it works in the majority of cases. It's the cases where the programmer does something extra (that causes a redisplay), and doesn't understand why it has side effects (redrawing, and subsequently delegate callbacks). There is no nib cleanup code; the nib doesn't have any way of zero-ing out references. If you do have a case where you think AppKit should be cleaning it up, then please submit it to bugreporter.apple.com -- it is possible that in some cases we may be able to make it work better. -corbin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
Hi Eric, On Jan 20, 2011, at 9:26 AM, Eric Gorr wrote: On Jan 20, 2011, at 12:17 PM, Kyle Sluder wrote: On Thu, Jan 20, 2011 at 7:22 AM, Eric Gorr mail...@ericgorr.net wrote: Based on my current understanding, the dealloc should be setting it's datasource and delegate to nil. Correct? If so, I will file a bug. No. It is the responsibility of the delegate to set the table view's backpointer to nil. The delegate usually has an owning reference to the table view. If -dealloc is being called on the table view, but the delegate still has a pointer to the table view, that means a memory management error has occurred. I think you misunderstood and I didn't write that sentence as clearly as I could. For a specific example, check out the AnimatedTableView sample code from Apple. The ATColorTableController class is a datasource for the table, but it's dealloc looks like: - (void)dealloc { [_colorList release]; [_colorNames release]; [_window release]; [super dealloc]; } Based on my current understanding, the table controller's dealloc (above) should be setting the table datasource and delegate to nil. Correct? If so, I will file a bug. I wrote that sample, and gave the WWDC talk based on it a few years ago. I also own NSTableView. Yes, please do file a bug. The sample should set the delegate/datasource to nil, as it is good practice to do so, and we can update the sample. In practice, I didn't notice any issues with the table redrawing after the delegate was freed. thanks for catching this! --corbin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
Hi Corbin, I wrote that sample, and gave the WWDC talk based on it a few years ago. I also own NSTableView. Yes, please do file a bug. The sample should set the delegate/datasource to nil, as it is good practice to do so, and we can update the sample. Thanks for the clarification, it is very helpful. So the right thing to do with delegates/datasources is to set them to nil. What about target/action on something like a button? Would you say that for every control in a nib, one has to set the delegate/datasource/action to nil? While this might seem like a silly question, most books/examples I read don't do this so I wanted to be clear on what the right thing to do is. Thanks again, Abdul ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Odd Crash when adding table columns manually
On Jan 20, 2011, at 1:24 PM, Corbin Dunn wrote: On Jan 19, 2011, at 4:51 PM, Lee Ann Rucker wrote: On Jan 19, 2011, at 3:21 PM, Corbin Dunn wrote: In general, it is good practice in your apps to set your delegate and datasource to nil. Who is to say something might cause a draw to happen, which would then message your (now dealloced) delegate? Ideally, NSTableView shouldn't message the delegate/datasource after the window is closed, but something extra setNeedsDisplay messages get thrown into it, causing it to happen, and crash. That is why your bug happened. 6728942 made an effort to reduce the display message. If I'd set them in my code I would agree, but I expect that if it's set by the nib setup code then it should cleared by the nib cleanup code. Yes, and it works in the majority of cases. It's the cases where the programmer does something extra (that causes a redisplay), and doesn't understand why it has side effects (redrawing, and subsequently delegate callbacks). There is no nib cleanup code; the nib doesn't have any way of zero-ing out references. If you do have a case where you think AppKit should be cleaning it up, then please submit it to bugreporter.apple.comhttp://bugreporter.apple.com/ -- it is possible that in some cases we may be able to make it work better. Now that I dig, it was a Snow Leopard beta bug that got fixed before it shipped, so despite the similar fix/workaround this is a different issue. I miss the real Radar, where I could actually see the bug my bug was a duplicate of :) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
On Thu, 20 Jan 2011 13:27:35 -0800, Corbin Dunn said: For a specific example, check out the AnimatedTableView sample code from Apple. The ATColorTableController class is a datasource for the table, but it's dealloc looks like: - (void)dealloc { [_colorList release]; [_colorNames release]; [_window release]; [super dealloc]; } Based on my current understanding, the table controller's dealloc (above) should be setting the table datasource and delegate to nil. Correct? If so, I will file a bug. I wrote that sample, and gave the WWDC talk based on it a few years ago. I also own NSTableView. Yes, please do file a bug. The sample should set the delegate/datasource to nil, as it is good practice to do so, and we can update the sample. In the case of garbage collected-only mode, do I assume correctly that such setting to nil is not needed? -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
best way of making a constant animation
Hello all, sorry to bother with such a question... here it goes. I need to have a rotate animation of a UIImageView, very very soft, I know using UIView class methods I can make the animation and setting the affine transform + plus the duration to something really big like 1e100f, the thing is.. that I need that same animation to happen at the same on another 3 UIImageView which are in the other 3 corners of the display.. What would be the best approach here?. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
NSTask -launch fails sheepishly when ARG_MAX exceeded
The docs for NSTask -launch state: Raises an NSInvalidArgumentException if the launch path has not been set or is invalid or if it fails to create a process. What it doesn't address is what happens if the process command line formed from the NSTask properties exceeds ARG_MAX. The path is valid, the process is created but the process subsequently becomes invalid. In this case the exec() that follows the fork() fails as ARG_MAX is the limit for exec() arguments. The child process now has no raison d'etre and expires declaring: *** NSTask: Task create for path '/some/crumbs' failed: 22, Invalid argument. Terminating temporary process. The parent process receives the above on the child's stdErr. No exception is raised in the parent. NSTask -terminationStatus returns 5. What is the best way to detect this failure so that an intelligible error can be reported to the user who instigated the task (eg the task you submitted was really just too big)? I can grep the stdErr report, but it's hardly a robust approach, or is the terminationStatus wholly distinctive or documented? Or I could estimate how close the process command line resulting from the NSTask is to ARG_MAX (256 * 1024) and take avoiding action. Regards Jonathan Mitchell Developer Mugginsoft LLP http://www.mugginsoft.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
NSBlockOperation with +[sendSynchronousRequest sendSynchronousRequest:...] or async?
With the advent of code blocks and NSBlockOperation, it's a lot tidier, and easier, to write code using NSURLConnection, particularly in the presence of multiple operations. The approach is to use an NSBlockOperation and +[NSURLConnection sendSynchronousRequest:returningResponse:error:] to synchronously request a resource (which occurs on a separate thread). The alternative is to use the asynchronous methods, and then manage all the state necessary to keep track of multiple instances of the same request. I prefer the former approach, but does Apple still recommend the async approach? Or is there no real difference between the two? I'm running on iOS 4.x, on a single-core device, but I don't think these devices will remain single-core for long, and the same question applies to multicore Macs. Thanks, Rick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: best way of making a constant animation
Hello Gustavo. This sounds like a perfect job for Core Animation. With Core Animation, you can apply the animation to the UIImageView's layer. Core Animation allows for animations to run once and stop automatically, repeat a specific number of times, or repeat indefinitely until you tell it to stop. I do something very similar in one of my projects. Here is how you set up the rotation animation (do this to each of your 4 views that you want to rotate): CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@transform.rotation]; rotationAnimation.duration = 1.0; rotationAnimation.fromValue = [NSNumber numberWithFloat:0.0]; rotationAnimation.toValue = [NSNumber numberWithFloat:2.0*M_PI]; rotationAnimation.repeatCount = HUGE_VALF; [flashImageView.layer addAnimation:rotationAnimation forKey:@RotatingFlash]; When you want the animation to stop do this: [flashImageView.layer removeAnimationForKey:@RotatingFlash]; On 2011-01-20, at 3:57 PM, Gustavo Pizano wrote: Hello all, sorry to bother with such a question... here it goes. I need to have a rotate animation of a UIImageView, very very soft, I know using UIView class methods I can make the animation and setting the affine transform + plus the duration to something really big like 1e100f, the thing is.. that I need that same animation to happen at the same on another 3 UIImageView which are in the other 3 corners of the display.. What would be the best approach here?. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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/gbeggs1%40mts.net This email sent to gbeg...@mts.net -- gbeg...@gmail.com http://www.GerrysCuppaTea.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
iOS Pass NSManagedObjectContext from my app delegate
Hi, Whats the best way to pass a NSManagedObjectContext object from an app delegate to other view controllers? Currently, my NSManagedObjectContext is retained like this in my app delegate: @property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext; @private NSManagedObjectContext *managedObjectContext_; } and in my implementation: - (NSManagedObjectContext *)managedObjectContext { if (managedObjectContext_ != nil) { return managedObjectContext_; } NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator]; if (coordinator != nil) { managedObjectContext_ = [[NSManagedObjectContext alloc] init]; [managedObjectContext_ setPersistentStoreCoordinator:coordinator]; } return managedObjectContext_; } In my view controllers, I create another NSManagedObjectContext Object and pass the reference like this: @property (nonatomic, retain) NSManagedObjectContext *context; Implementation: CameraPlanAppDelegate *appDelegate = (CameraPlanAppDelegate *)[[UIApplication sharedApplication] delegate]; context = [appDelegate managedObjectContext]; Is this correct? Do I need to release context on my view controller? If I release it, don't I release all references to it? Thanks. Phil___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iOS Pass NSManagedObjectContext from my app delegate
On Jan 20, 2011, at 5:25 PM, Philip Vallone wrote: Hi, Whats the best way to pass a NSManagedObjectContext object from an app delegate to other view controllers? Did you use the Xcode template for making a CoreData application? Currently, my NSManagedObjectContext is retained like this in my app delegate: @property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext; If you have declared the property to be read-only, then the retain keyword is not necessary. Retain and assign are only necessary if it's a read/write property, since they tell the synthesizer what to do with new values (if @synthesize is in use). @private NSManagedObjectContext *managedObjectContext_; } You generally don't need to declare instance variables as private in an application unless you know your class will be subclassed. In most cases, the default protection level is good enough. CameraPlanAppDelegate *appDelegate = (CameraPlanAppDelegate *)[[UIApplication sharedApplication] delegate]; context = [appDelegate managedObjectContext]; Is this correct? Yes. Do I need to release context on my view controller? No. Re-read the memory management rules. If I release it, don't I release all references to it? No. Re-read the memory management rules. http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html#//apple_ref/doc/uid/2994-BAJHFBGH Nick Zitzmann http://www.chronosnet.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: iOS Pass NSManagedObjectContext from my app delegate
Hi Nick, Did you use the Xcode template for making a CoreData application? Yes If you have declared the property to be read-only, then the retain keyword is not necessary. Retain and assign are only necessary if it's a read/write property, since they tell the synthesizer what to do with new values (if @synthesize is in use). This was created by xcode... so it should be: @property (nonatomic, readonly) NSManagedObjectContext *managedObjectContext; Thanks for the help Phil___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: printing a different representation than what is on the screen
On Jan 20, 2011, at 10:03 AM, Sherm Pendley wrote: On Thu, Jan 20, 2011 at 9:24 AM, Dave Reed davel...@mac.com wrote: I'm working on a document-based application that has a couple tabs. Most of the tabs contain NSTableViews, NSTextFields, etc. I want to provide a way for the user to print the data contained in them (just text, possibly with some grid lines), but not the actual table view. I've read through (admittedly fairly quickly) the Printing Topics for Cocoa document from Apple but it is more geared towards printing what you see on the screen. I also may want to print different data depending on which tab the user is on. What is the appropriate way to do this? Do I override drawRect: for each tab such as: - (void)drawRect:(NSRect)r { if ( [NSGraphicsContext currentContextDrawingToScreen] ) { [super drawRect:r] } else { // somehow send drawing instructions for the text I want } } or do I somehow create an off screen view that I draw the text and grid lines into? I would take the first approach if (as is mentioned in the docs this example is from) drawing the view is mostly the same for both print and screen, except for a few embellishments (crop marks, footnotes, etc.) added to the print version. In your case, it sounds like you want to print something entirely different than what appears on-screen. In that case, I would take the second approach, in one of two ways: If what you want to print can be expressed in HTML (and it sounds like that may be the case), I'd create an off screen instance of WebView, feed it some HTML, and send it a -print message. In many cases this can be easier to maintain; you can take a template-based approach where the layout information is contained in an external template, which your app loads fills in to generate the HTML it prints. That gives you the ability to tweak the layout appearance using tools that are designed for just that (such as iWeb or Dreamweaver), rather than having to modify a custom -drawRect: for each change. Alternatively, you can subclass NSView with your customized -drawRect:, create an off screen instance of your subclass, and send it a -print message. sherm-- -- Cocoa programming in Perl: http://camelbones.sourceforge.net Thanks for the advice. Yes, what I want to display is fairly different than what is displayed so the second approach is probably what I want. I hadn't thought of doing it via HTML, but that may be simpler than creating my own subclass of NSView. I just need to dust off my HTML skils that I haven't used in 10+ years. Thanks, Dave ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
On Jan 20, 2011, at 4:56 PM, Sean McBride wrote: On Thu, 20 Jan 2011 13:27:35 -0800, Corbin Dunn said: For a specific example, check out the AnimatedTableView sample code from Apple. The ATColorTableController class is a datasource for the table, but it's dealloc looks like: - (void)dealloc { [_colorList release]; [_colorNames release]; [_window release]; [super dealloc]; } Based on my current understanding, the table controller's dealloc (above) should be setting the table datasource and delegate to nil. Correct? If so, I will file a bug. I wrote that sample, and gave the WWDC talk based on it a few years ago. I also own NSTableView. Yes, please do file a bug. The sample should set the delegate/datasource to nil, as it is good practice to do so, and we can update the sample. In the case of garbage collected-only mode, do I assume correctly that such setting to nil is not needed? I thought this might be of interestMike Ash writes: - http://www.mikeash.com/pyblog/friday-qa-2010-07-16-zeroing-weak-references-in-objective-c.html If you're using garbage collection in Objective-C, then good news! The Objective-C garbage collector already supports zeroing weak references using the type modifier __weak. You can just declare any instance variable like so: __weak id _foo; And it's automatically a zeroing weak reference. The compiler takes care of emitting the appropriate read/write barriers so that access is always safe. - ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iOS Pass NSManagedObjectContext from my app delegate
On Jan 20, 2011, at 4:46 PM, Nick Zitzmann wrote: On Jan 20, 2011, at 5:25 PM, Philip Vallone wrote: Currently, my NSManagedObjectContext is retained like this in my app delegate: @property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext; If you have declared the property to be read-only, then the retain keyword is not necessary. Retain and assign are only necessary if it's a read/write property, since they tell the synthesizer what to do with new values (if @synthesize is in use). I'm somewhat new to all this also, so perhaps I'm off on this one. My understanding is that using (retain, readonly) in the class interface insures that if the property is ever changed to readwrite in a category, then it must be (retain, readwrite) and not (assign, readwrite) or (copy, readwrite). Whether this guarantee is important or not probably depends on the circumstances, but there is extra information the compiler can use to catch errors when you declare it as (retain, readonly) that isn't available when you declare it as (readonly). Aaron ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
On Jan 20, 2011, at 4:27 PM, Corbin Dunn wrote: Hi Eric, On Jan 20, 2011, at 9:26 AM, Eric Gorr wrote: On Jan 20, 2011, at 12:17 PM, Kyle Sluder wrote: On Thu, Jan 20, 2011 at 7:22 AM, Eric Gorr mail...@ericgorr.net wrote: Based on my current understanding, the dealloc should be setting it's datasource and delegate to nil. Correct? If so, I will file a bug. No. It is the responsibility of the delegate to set the table view's backpointer to nil. The delegate usually has an owning reference to the table view. If -dealloc is being called on the table view, but the delegate still has a pointer to the table view, that means a memory management error has occurred. I think you misunderstood and I didn't write that sentence as clearly as I could. For a specific example, check out the AnimatedTableView sample code from Apple. The ATColorTableController class is a datasource for the table, but it's dealloc looks like: - (void)dealloc { [_colorList release]; [_colorNames release]; [_window release]; [super dealloc]; } Based on my current understanding, the table controller's dealloc (above) should be setting the table datasource and delegate to nil. Correct? If so, I will file a bug. I wrote that sample, and gave the WWDC talk based on it a few years ago. I also own NSTableView. Yes, please do file a bug. The sample should set the delegate/datasource to nil, as it is good practice to do so, and we can update the sample. Bug filed: rdar://8896270 thanks for catching this! You're welcome. This has been a very interesting thread. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
On Jan 20, 2011, at 1:33 PM, Abdul Sowayan wrote: Hi Corbin, I wrote that sample, and gave the WWDC talk based on it a few years ago. I also own NSTableView. Yes, please do file a bug. The sample should set the delegate/datasource to nil, as it is good practice to do so, and we can update the sample. Thanks for the clarification, it is very helpful. So the right thing to do with delegates/datasources is to set them to nil. What about target/action on something like a button? Would you say that for every control in a nib, one has to set the delegate/datasource/action to nil? While this might seem like a silly question, most books/examples I read don't do this so I wanted to be clear on what the right thing to do is. No, I wouldn't say every control -- I would say any control that has a delegate method which responds to drawing commands. Things like NSTableView, NSOutlineView, NSBrowser, NSWindow. I mainly know from experience of debugging and looking at crash reports. Now for something like a button, it obviously won't run into this type of latent drawing issue, since they don't message the delegate every time they draw. However, if you temporarily allocated an object and set it as the target/action of a button, and then free that object while the button is still visible, then yes, that's a case where you want to reset it to nil. Most these type of crashing issues can easily be resolved by using instruments + zombies -- you quickly realize your object was deallocated, but the view object had a reference to it. corbin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
On Jan 20, 2011, at 8:51 PM, Eric Gorr wrote: On Jan 20, 2011, at 4:27 PM, Corbin Dunn wrote: [...] Yes, please do file a bug. The sample should set the delegate/datasource to nil, as it is good practice to do so, and we can update the sample. Bug filed: rdar://8896270 I just submitted rdar://8896532, referencing Eric's bug, suggesting that before nilling out the delegate and dataSource, you should check whether they are == self. Conceivably at some point the delegate and/or dataSource might have been set to some other object -- probably not in this example, but in general. Admittedly it's probably very rare that this is an issue, and I'd be surprised if anyone on this list has ever run into a bug because of it. On the other hand, if you're going to program defensively, why not go all the way? On the *other* hand, maybe this is one of those things that should be at the programmer's discretion rather than a hard and fast rule. --Andy (just now realizing I haven't been checking for == self myself) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Cleaning up weak references ( was Re: Odd Crash when adding table columns manually )
On Jan 20, 2011, at 9:39 PM, Corbin Dunn wrote: Now for something like a button, it obviously won't run into this type of latent drawing issue, since they don't message the delegate every time they draw. However, if you temporarily allocated an object and set it as the target/action of a button, and then free that object while the button is still visible, then yes, that's a case where you want to reset it to nil. I don't know why I had it in my mind that targets are retained. If they were, they'd run into the same retain cycles as delegates would if *they* were retained. I think it would be going to extremes to nil out button targets in dealloc. I think a common-sense approach is best after all, and I retracted the bug I mentioned earlier because checking delegates for == self should be up to the discretion of the programmer. Can't hurt to do it, but it almost certainly won't matter. --Andy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Help on Cocoa Class references
Thanks a lot for your help and the problem has now been solved by creating a subclass of nsview and adding as a subview to the nsview brought about from the AWT surface --- On Thu, 1/20/11, Marco Frisan johnmadst...@yahoo.it wrote: From: Marco Frisan johnmadst...@yahoo.it Subject: Re: Help on Cocoa Class references To: sc...@cocoadoc.com Cc: leanneatt...@yahoo.com, cocoa-dev@lists.apple.com Date: Thursday, January 20, 2011, 8:59 PM Message: 3 Date: Wed, 19 Jan 2011 22:18:04 -0500 From: Scott Anguish sc...@cocoadoc.com Subject: Re: Help on Cocoa Class references To: Leanne Attard leanneatt...@yahoo.com Cc: cocoa-dev@lists.apple.com Message-ID: 8c659320-34f8-4b47-830d-796386224...@cocoadoc.com Content-Type: text/plain; charset=windows-1252 I‚m surprised nobody else mentioned this. The Java bridge isn‚t supported and you can no longer write Cocoa apps in Java. So you‚re much better off learning Obj-C or going fully Java. Or even Ruby Apple won‚t even be shipping Java with the OS in the future (there was an announcement about this recently). You‚ll need to get it from Oracle (who Apple transferred things to as I recall in another announcement) All Java Class References which may have existed (and only for public classes, none those were as I recall) are gone. The process for creating those docs are gone. We no longer support or generate them (I‚m in the documentation department). Sorry to be a wet noodle. Java 6 is still available and it is not deprecated. It provides the com.apple.eawt. The list of deprecated classes and methods of that package is here: http://developer.apple.com/library/mac/documentation/Java/Reference/JavaSE6_AppleExtensionsRef/api/deprecated-list.html Mac OS X port of the Open JDK 7, that has contributes from the original Apple source code, since the begin of january, also has com.apple.eawt package in its project status page. Though, I think we should concentrate on the Leanne's goal. She wants to draw over a Java AWT component using OpenGL and she wants to handle mouse events (and probably keyboard events). The only way to use OpenGL to draw over a Java AWT component is to implement a JNI based interface.Probably Java AWT components, in the Mac OS X implementation of Java, are already implemented through JNI and are probably derived from Cocoa native components (like NSView).So, probably, Leanne does not need to implement its own NSView and place it through CocoaComponent in the AWT window.What she need is to initialize a NSOpenGLPixelFormat and a NSOpenGLContext, using JNI and providing JNI functions to create, access and manipulate these objects. Furthermore she needs to implement JNI functions that wrap OpenGL interface. The rest of the operations can be done in pure Java code (included event handling). Since this is a long work and there are ready to use OpenGL Java bindings like LWJGL or JOGL, I suggest to use them. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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
Problem with garbage collection in server application
I have an application based on the Cocoa Application template in Xcode (x86_64, currently testing on OSX 10.6.5) that listens for client messages using an NSConnection. Both client and server have been designed for garbage collection, and are compiled GC-only. The client is a simple command-line program that uses [NSConnection rootProxyForConnectionWithRegisteredName:serverName host:nil]; to send it's messages to the server. The messages direct the server to load large-ish data files (200MB) and perform processing on them. Periodically the client may direct the server to unload all of the large datasets from memory, which the server does by calling the 'removeAllObjects' method of a mutable array that holds the list of all loaded datasets. Under real conditions, we would expect to load around five of these datasets at a time, perform processing, unload, and then load another five. I have overridden the 'finalize' method of the dataset class to print a log message before calling [super finalize], and when I perform a single processing 'run' in which the client sends a message to the server directing it to load a 200MB dataset and then perform a series of processing operations which result in five datasets being open, I have noticed that - while the finalize methods are indeed called - they are called around five to ten seconds after the last processing directive is sent from the client. For five datasets the above behaviour is not a problem, but in more realistic tests where we generate five datasets, flush, then generate five more, before repeating the cycle perhaps 10 times, the finalize methods never appear to be called (or at least no log messages appear). The memory usage becomes huge, and eventually the program crashes. In these runs, a shell script repeatedly invokes the client program to send messages to the server program. The server (which has a UI) might spend all it's time in an 'inactive' state with no user input. The commands are currently run on the main thread of the server. However the memory accumulation and crash happen whether or not I click on the server window to bring it to the foreground. I'm pretty sure I'm not leaking the memory with an unintended reference, as the datasets *are* collected (albeit not very quickly) after I run a set of five operations and the server returns to be waiting for user input. I'm wondering if it could be because collection will not happen until the end of a run loop, and by bombarding the server with messages then collection is never triggered because it never senses the end of the run loop. I gather that there may be special considerations with runloops and NSConnection. Note that I *am* calling collectExhaustively right after the various stages in the server when data should be flushed, but this does not seem to help. I do the call at the end of the method in which client messages are processed - is it possible this should be run using performSelector after the current run loop? I'm at the point where I am reconsidering whether GC is really appropriate for this application, but also think I may well be doing something silly that can easily be fixed. Would be grateful for any suggestions! Rick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Help on Cocoa Class references
On Jan 19, 2011, at 9:18 PM, Scott Anguish wrote: Apple won’t even be shipping Java with the OS in the future (there was an announcement about this recently). You’ll need to get it from Oracle (who Apple transferred things to as I recall in another announcement) Announcing: OpenJDK for Mac OS X source repository, mailing list, project home http://mail.openjdk.java.net/pipermail/macosx-port-dev/2011-January/07.html Rumors of it's demise might be slightly exaggerated. However, given it's deprecated status, although I believe it will continue to ship and be supported through 10.7, the Apple java-dev or openjdk list above might be more appropriate forums for discussing it. One thing I find a little interesting is that the openjdk project is actually targeting a Java 7 first release. Who knows, OS X might become a bleeding edge java platform? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: best way of making a constant animation
Gerry thank you very much. I have used CA before, but sometimes I get complicated it with it, dunno why.. and i end up using UIView block animations. I will implement this and see how it looks G On Jan 21, 2011, at 1:01 AM, Gerry Beggs wrote: Hello Gustavo. This sounds like a perfect job for Core Animation. With Core Animation, you can apply the animation to the UIImageView's layer. Core Animation allows for animations to run once and stop automatically, repeat a specific number of times, or repeat indefinitely until you tell it to stop. I do something very similar in one of my projects. Here is how you set up the rotation animation (do this to each of your 4 views that you want to rotate): CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@transform.rotation]; rotationAnimation.duration = 1.0; rotationAnimation.fromValue = [NSNumber numberWithFloat:0.0]; rotationAnimation.toValue = [NSNumber numberWithFloat:2.0*M_PI]; rotationAnimation.repeatCount = HUGE_VALF; [flashImageView.layer addAnimation:rotationAnimation forKey:@RotatingFlash]; When you want the animation to stop do this: [flashImageView.layer removeAnimationForKey:@RotatingFlash]; On 2011-01-20, at 3:57 PM, Gustavo Pizano wrote: Hello all, sorry to bother with such a question... here it goes. I need to have a rotate animation of a UIImageView, very very soft, I know using UIView class methods I can make the animation and setting the affine transform + plus the duration to something really big like 1e100f, the thing is.. that I need that same animation to happen at the same on another 3 UIImageView which are in the other 3 corners of the display.. What would be the best approach here?. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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/gbeggs1%40mts.net This email sent to gbeg...@mts.net -- gbeg...@gmail.com http://www.GerrysCuppaTea.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: NSBlockOperation with +[sendSynchronousRequest sendSynchronousRequest:...] or async?
Always use the async API. For networking, there are *tons* of reasons to avoid your own threading (ie, CPU - battery consumption) when Apple does all that for your using their Async API (and only one global thread to manage the network) Look at the free WWDC videos from 2010, this is very well explained. Aurélien, Objective Decision Team On 20 janv. 2011, at 23:51, Rick Mann wrote: With the advent of code blocks and NSBlockOperation, it's a lot tidier, and easier, to write code using NSURLConnection, particularly in the presence of multiple operations. The approach is to use an NSBlockOperation and +[NSURLConnection sendSynchronousRequest:returningResponse:error:] to synchronously request a resource (which occurs on a separate thread). The alternative is to use the asynchronous methods, and then manage all the state necessary to keep track of multiple instances of the same request. I prefer the former approach, but does Apple still recommend the async approach? Or is there no real difference between the two? I'm running on iOS 4.x, on a single-core device, but I don't think these devices will remain single-core for long, and the same question applies to multicore Macs. Thanks, Rick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/hugele.aurelien%40objective-decision.com This email sent to hugele.aurel...@objective-decision.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