Re: how do you suppose targetViewControllerForAction:sender: works?
(typed in mail) if ([[vc class] instanceMethodForSelector: selector] != [[vc superclass] instanceMethodForSelector: selector]) { // vc's class implements an instance method that is different from it's superclass - i.e., it has overridden it } On Oct 9, 2014, at 11:56 AM, Matt Neuburg m...@tidbits.com wrote: From the WWDC 2014 video 216: targetViewControllerForAction works by looking at the View Controller and seeing if it's _overwritten_ the action method that you've passed in. From Kyle Sluder's blog: -targetViewControllerForAction:sender: ... will then determine whether the instance’s method for that selector is an override of a UIViewController implementation for the same selector. Those descriptions are correct. But then how do you suppose it does this? There's an introspective voodoo happening here that I've never seen before. `respondsToSelector:` obviously doesn't cut it: it would return YES if this class merely _inherits_ the ability to respond to this selector. How would you find out the answer to the question, does this UIViewController subclass respond to this selector _differently_ from UIViewController? Thx - m. -- matt neuburg, phd = http://www.apeth.net/matt/ pantes anthropoi tou eidenai oregontai phusei Programming iOS 7! http://shop.oreilly.com/product/0636920031017.do iOS 7 Fundamentals! http://shop.oreilly.com/product/0636920032465.do RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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/gandreas%40me.com This email sent to gandr...@me.com Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Good idea/bad idea?
That won't do any good, since if the receiver is nil, it'll return nil (since nil isn't an object like it is in Smalltalk) So the only place where it actually gets called will be the places that don't need it. On Apr 24, 2014, at 3:10 PM, Alex Zavatone z...@mac.com wrote: Could we throw a category on NSObject for that and then every class that originates with NSObject gets that lovely method? Agree on the clunky bit, but so is using the @ compiler directive to accomplish everything that couldn't be fit in in the first place. Not as if I know a better way to do it, but I agree, they do feel clunky. On Apr 24, 2014, at 3:48 PM, Lee Ann Rucker wrote: In Smalltalk, where nil is an object like everything else, and we were working with calls out to C APIs that had a lot of required parameters, we added an orIfNil: that was very useful: foo := bar orIfNil:10. Nil orIfNil:other ^other Object orIfNil:other ^self It would be useful in ObjC if there were an elegant way to do it. Macros are just clunky. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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/gandreas%40me.com This email sent to gandr...@me.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: dataWithPDFInsideRect doesn't clip images within NSView
A PDF file can reuse an image and draw the same thing multiple times in multiple places. If it saved just the clipped version, it would need multiple copies of the same image, which would actually increase the file size. So if the purpose of adding a cropImages flags was to save file space, in some case it will result in taking more space. Furthermore, if the image is a jpg image, clipping would need the image to be recompressed and end up degrading the image quality (since PDFs can embed jpg files directly), or again, potentially increase the file size. And if you draw a PDF image inside the view, those PDF instructions/objects are encoded into the resulting file - if you want to clip that, you either need to rasterize it (loosing quality) or perform clipping operations on shapes to produce new ones (which can be non-trivial). On Feb 27, 2014, at 9:57 AM, Leonardo mac.iphone@gmail.com wrote: Thank you. I have coded it. I lock the focus of the NSView, I draw and get the clipped image, then I re-draw the NSView with the clipped image + borders, rotation, shadow. Of course, since the user could choose the ppi output, I resize-resample the view before locking it. It should be useful to have an option as [view dataWithPDFInsideRect:bounds clipPaths:YES]; Regards -- Leonardo Da: Graham Cox graham@bigpond.com Data: Thu, 27 Feb 2014 22:38:42 +1100 A: Leonardo mac.iphone@gmail.com Cc: Cocoa-dev List List cocoa-dev@lists.apple.com Oggetto: Re: dataWithPDFInsideRect doesn't clip images within NSView On 27 Feb 2014, at 9:31 pm, Leonardo mac.iphone@gmail.com wrote: I draw an NSImage within an NSView scaling its size in order to fill the image within the view bounds. The image is larger than the NSView's bounds, but on the display it looks well clipped to those bounds. Since the image's NSView is a subView of the page's NSView, I create a PDF saving that page's NSView [pageView dataWithPDFInsideRect:pageRect]; and I get a pdf file. Anyway, when I inspect the pdf file with Acrobat, I clearly see that the image hasn't been cropped. As I see from the blue rectangle around the visible small image, the whole original and larger image has been embedded within the pdf document. In facts if I Control-Click-Edit the image on the pdf, I get the original whole image. So the pdf file size results bigger than what it would really be. I don't get this trouble when saving the page to a TIFF or any other raster image file (with NSBitmapImageRep - CGImage - displayRectIgnoringOpacity - CGImageDestinationFinalize). This is exactly what you'd expect. Core Graphics basically *is* a PDF. So when you draw an image into a view that is clipped, all you're doing is setting a clipping path and drawing an image. The PDF faithfully records that. When you create a different image that is clipped to the smaller area, then that's what is recorded. My question: Do you know an option, any API, to clip the image to its NSView's frame on the pdf, as it properly looks on the display? Or should I clip the image by my own code? When you know how it works, the question becomes moot. The short answer is 'no', there's no API. You have to resample/crop the image as you need, or accept the larger filesize for the convenience that you get from the simple API. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/gandreas%40me.com This email sent to gandr...@me.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Preserving undo actions on deleted targets
On Jan 29, 2014, at 4:44 PM, Graham Cox graham@bigpond.com wrote: On 30 Jan 2014, at 8:03 am, Keary Suska cocoa-...@esoteritech.com wrote: Absolutely, and I have found it invaluable to troubleshoot state issues, but unfortunately it is not App Store safe (read: basis for rejection), as it relies on a private method call for proper NSDocument change tracking... It does? I'm using it in an App Store app without it ever having come up as an issue. Have you actually had this flagged as an issue by The Keepers Of The Store™? If you're referring to: - (void) _processEndOfEventNotification:(NSNotification*) note I'm not sure that counts as using private API as such. It's just a stub for a method that NSDocument calls on its undo manager, and as you can see it's only a notification handler (containing no code). It's needed because NSDocument doesn't check whether the undo manager implements it before calling it, so it will cause an unrecognised selector exception if it's not there, but it's not actually calling any private API itself anywhere - NSDocument is. It doesn't matter if you are calling it, or if the framework is calling it - you are effectively using the private API. Method names with leading underscores are defined as private methods, reserved for Apple. From https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingMethods.html#//apple_ref/doc/uid/20001282-1003829-BCIBDJCA (emphasis mine) Private Methods In most cases, private method names generally follow the same rules as public method names. However, a common convention is to give private methods a prefix so it is easy to distinguish them from public methods. Even with this convention, the names given to private methods can cause a peculiar type of problem. When you design a subclass of a Cocoa framework class, you cannot know if your private methods unintentionally override private framework methods that are identically named. Names of most private methods in the Cocoa frameworks have an underscore prefix (for example, _fooData ) to mark them as private. From this fact follow two recommendations. • Don’t use the underscore character as a prefix for your private methods. Apple reserves this convention. (One work around would be to implement doesNotRecognizeSelector: and ignore it there, and this would also make it future safe for when new private methods are added - in the mean time, file a bug asking that NSUndoManager can be fully replaceable with publicly declared methods only). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: start in NSOperation
Turn on -Woverriding-method-mismatch $ xcrun clang --version Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) Target: x86_64-apple-darwin13.0.0 Thread model: posix $ cat return.m #import Foundation/Foundation.h @interface ClassA :NSObject - (void) foo; @end @interface ClassB : ClassA - (int) foo; @end @interface ClassC : ClassB - (NSRange) foo; @end $ xcrun clang -Woverriding-method-mismatch -fsyntax-only return.m return.m:8:1: warning: conflicting return type in declaration of 'foo': 'void' vs 'int' [-Woverriding-method-mismatch] - (int) foo; ^ ~~~ return.m:4:1: note: previous declaration is here - (void) foo; ^ return.m:12:1: warning: conflicting return type in declaration of 'foo': 'int' vs 'NSRange' (aka 'struct _NSRange') [-Woverriding-method-mismatch] - (NSRange) foo; ^ ~~~ return.m:8:1: note: previous declaration is here - (int) foo; ^ ~~~ 2 warnings generated. On Jan 6, 2014, at 10:52 AM, Kyle Sluder k...@ksluder.com wrote: On Mon, Jan 6, 2014, at 02:39 AM, Roland King wrote: since the return type isn't part of the signature of a method, overriding it with start which takes no parameters and returns an integer is allowed I found this unbelievable, but then I wrote a test and confirmed it is true. That's insane. What if the overridde's return type causes it to use a different calling convention? I'm gonna file a compiler bug. --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/gandreas%40me.com This email sent to gandr...@me.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Issues with NSTextView Attachments
When NSTextView puts rich content on a pasteboard (for copy/paste or drag/drop), it converts the text to RTF. RTF has no concept of custom text attachment cells, so they get dropped. You'll need to add your own custom data type that preserves that content (such using an archive) On Aug 22, 2013, at 1:48 PM, Gordon Apple g...@ed4u.com wrote: I¹ve successfully managed to override Paste and PerformDrag to embed images which are resizable and with specified fractional (fraction of height)baseline offsets. They also archive and unarchive properly. I¹m using a custom TextAttachmentextCell which archives the size and the fractional baseline offset, and returns the appropriate values to draw properly. Undo/redo even works. However, it¹s still not right. I cannot copy/pasts or drag/drop a text segment containing the attachment without losing the attachment. NSTextView¹s handling of images, without my enhancements, does this correctly. So what am I missing? I don¹t really understand the various ³fix² methods. When I did my own text editor (pre-OSX), which was uses in some Mayo Clinic multimedia CDs, I handled all this automatically when pasting, etc. I did put in a fixAttachmentAttributeInRange call after insertion. That didn¹t help. On 8/10/13 12:31 PM, Gordon Apple g...@ed4u.com wrote: Using NSTextView¹s native ability to embed image attachments, we have successfully implemented resizing of the image by using a resizable frame with a drag handle, and using setSize on the NSImage. Works great. Only one problem, re-archiving the NSAttributableString loses the image size change. Any way to fix this? Internally, in a CoreData auxiliary file folder, we archive NSAttributableString. Would we be better off storing it as RTFD? I also see allusions to subclasses of NSTextAttachment, but I see no way to tell NSTextView, or its associates, to use such a subclass. NSTextAttachmentCell is a protocol. But who adopts this protocol? For an image, is this really a NSImageCell adopting this protocol? Or is it the NSTextAttachment? Confusion here. Documentation on attachments is sparse. We would also like to have the ability to set the baseline when an image is inserted, and change it when the image is resized. Certain NSPDFImageReps contain baseline info in private dictionaries, which we would like to use, when available. In view of the above, should we abandon NSTextView¹s paste/drag-in capabilities for images and override all the relevant methods to do our own attachment inserts using a custom NSAttachment class? Related question about NSImage. I¹ve never understood setSize in NSImage. Does this just affect the cached image, or does it have any impact on the underlying imageRep, such as resizing and remapping a bitmap? One more: I¹ve never found a straightforward way to make a textView re-layout all or a portion of the text. The best way I¹ve found is to call textContainerChangedGeometry. Works, but seems rather obtuse. Inquiring minds need to know. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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/gandreas%40me.com This email sent to gandr...@me.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Converting to Arc → undeclared identifier
On Aug 20, 2013, at 8:43 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: On 20 Aug 2013, at 20:27, Fritz Anderson anderson.fr...@gmail.com wrote: Sure, but the whole point the OP is trying to make is that the purported error is being raised by the refactoring process that is _supposed to remove that retain_. Refactoring would be a very easy process indeed if doing the conversion yourself is a prerequisite of having Xcode do it. The use of the _ivar should work ― did work as far as the production compiler knew. Is the code the OP posted the whole context? Has he tried to convert that minimal example, and gotten the same error? Has he examined the preprocessed code (and then searched for the no-underscore name of the @property) to see if anything suggests itself? Created a new project (not document based) removed arc in build settings, modified the AppDelegate thus: What version of Xcode? I just tried this with Xcode 4.6.3 and it worked perfectly. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: iOS splash screen animation
On Apr 10, 2013, at 8:35 AM, Koen van der Drift koenvanderdr...@gmail.com wrote: Hi, When my app starts, I'd like to show a splash screen with a logo, etc, and animate it to the main screen after a short delay. http://developer.apple.com/library/ios/documentation/userexperience/conceptual/mobilehig/UEBestPractices/UEBestPractices.html#//apple_ref/doc/uid/TP40006556-CH20-SW25 Avoid displaying an About window or a splash screen. In general, try to avoid providing any type of startup experience that prevents people from using your app immediately. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: iOS splash screen animation
On Apr 10, 2013, at 9:47 AM, Koen van der Drift koenvanderdr...@gmail.com wrote: On Apr 10, 2013, at 10:39 AM, glenn andreas gandr...@me.com wrote: Avoid displaying an About window or a splash screen. In general, try to avoid providing any type of startup experience that prevents people from using your app immediately. Point well taken, thanks for the link. But then why does Xcode have a place to put 'Launch Images' in the Target - Summary section? - Koen. From http://developer.apple.com/library/ios/documentation/userexperience/conceptual/mobilehig/IconsImages/IconsImages.html#//apple_ref/doc/uid/TP40006556-CH14-SW5: Launch Images To enhance the user’s experience at app launch, you must provide at least one launch image. A launch image looks very similar to the first screen your app displays. iOS displays this image instantly when the user starts your app and until the app is fully ready to use. As soon as your app is ready for use, your app displays its first screen, replacing the launch placeholder image. Note: In general, an iPhone app should include a launch image in portrait orientation; an iPad app should include one launch image in portrait orientation and one launch image in landscape orientation. Because iOS lets you supply different launch images for different usages you give each image a name that specifies how it should be used. The format of the launch image filename includes modifiers you use to specify the device, resolution, and orientation of the image. To learn how to name launch images appropriately, see “App Launch (Default) Images” in iOS App Programming Guide. Supply a launch image to improve user experience. Avoid using your launch image as an opportunity to provide: • An “app entry experience,” such as a splash screen • An About window • Branding elements, unless they are a static part of your app’s first screen Because users are likely to switch among apps frequently, you should make every effort to cut launch time to a minimum, and you should design a launch image that downplays the experience rather than drawing attention to it. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: ARC question
On Oct 29, 2012, at 8:34 AM, Mike Abdullah cocoa...@mikeabdullah.net wrote: On 29 Oct 2012, at 11:44, Vincent Habchi vi...@macports.org wrote: Le 29 oct. 2012 à 12:34, Mike Abdullah cocoa...@mikeabdullah.net a écrit : The code is a fairly inefficient to start with, but no, it's not going to leak. Thanks. I am aware of this, but since this code is going to be part of a didactic article on writing a WMS client, I emphasize clarity over performance (this is a secondary aspect). However, I am interested in knowing how you would write such a translator yourself to make it more efficient. I had initially the idea of copying every char until a ‘’, in which case the following content would be analyzed and replaced if necessary, and so on until the end of the HTML string. That would mean one single pass instead of as many as the number of pairs in the dictionary. Well, you can ask CFXMLCreateStringByUnescapingEntities() to do this on OS X, although if I recall all the CFXML functions have now sadly been deprecated. The source code for it should still be available if you search around. But in general, I would just work my way through the string looking for occurrences of '' and see if that makes up a valid escape sequence. Much of the problem if dealing with HTML rather than XML is that there are a vast range of special sequences. e.g. micro; Given that there are also decimal (#DD;) and hexadecimal escape sequences (#x;) in HTML, trying to support those through the use of a dictionary of sequence - replacement is going to be impractical. Scanning through the string to find and test for valid escape sequences (including both the 250 or so named entities plus those numeric escape sequences) is the right way to go, since the time spent on the string is dependent on the number of escape sequences in the string, not the number of possible escape sequences. Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! Mad, Bad, and Dangerous to Know ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: iOS 6 self-update from beta?
On Sep 20, 2012, at 9:59 AM, Jim Adams jim.ad...@sas.com wrote: I had the beta. My version is newer than the OTA version: I have version 6.0 (10A5376e). That isn't newer (376 403) To make an old Macintalk reference: The 5 is silent (Apparently, the fourth digit of the version refers to some sort of engineering release) Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: stringWithFormat / Rendering Text (iOS)
On May 24, 2012, at 9:36 AM, Manfred Schwind wrote: CGContextShowTextAtPoint(contextRef, 0, 40, [textToDraw UTF8String], [textToDraw length]); One bug I see here: you're passing a wrong length parameter. CGContextShowTextAtPoint expects the length of the char array (number of bytes of the UTF-8 encoded string), but you'e passing the number of Unicode characters in the string. That's not the same; one character may be represented by multiple chars in UTF-8 encoding. E.g. use it this way: const char *myUTF8String = [textToDraw UTF8String]; CGContextShowTextAtPoint(contextRef, 0, 40, myUTF8String, strlen(myUTF8String)); Also, CGContextShowTextAtPoint is designed only to display text in MacRoman encoding (and a corresponding font that has MacRoman character data tables). If the string has anything other than ASCII text, the UTF8String won't be in MacRoman (and in general, MacRoman is a very small subset of what Unicode supports, so even if you got the string in MacRoman encoding, there is a very good chance it still won't draw correctly because somebody used a character outside of MacRoman). From the docs: If setting the font to a MacRoman text encoding is sufficient for your application, use the CGContextSelectFont function. Then, when you are ready to draw the text, you call the function CGContextShowTextAtPoint. The function CGContextSelectFont takes as parameters a graphics context, the PostScript name of the font to set, the size of the font (in user space units), and a text encoding. To set the font to a text encoding other than MacRoman, you can use the functions CGContextSetFont and CGContextSetFontSize. You must supply a CGFont object to the function CGContextSetFont. You call the function CGFontCreateWithPlatformFont to obtain a CGFont object from an ATS font. When you are ready to draw the text, you use the function CGContextShowGlyphsAtPoint rather thanCGContextShowTextAtPoint. So for general case drawing, you'll need to generate glyphs from the text, which is an extremely complicated procedure to do without some sort of type-setter support (such as found in CoreText or (not available on iOS) NSTypesetter). Basically, CGContextShowTextAtPoint is designed to show simple debugging information and very limited/controlled strings, not a general purpose drawing routine. Just use NSString's drawAtPoint:withFont: and the like... Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: iOS app launching speed
On May 15, 2012, at 3:15 PM, Alex Zavatone wrote: OK. I've got one item to discuss with you, the splash/launch screen. This is why I like it. Right after clicking on an app's icon, the splash screen/launch screen shows that the device has indeed paid attention to you and responded in the manner you expected, namely, the application has launched and is proceeding to load. I can not see how this is a bad idea. From http://developer.apple.com/library/ios/DOCUMENTATION/UserExperience/Conceptual/MobileHIG/UEBestPractices/UEBestPractices.html#//apple_ref/doc/uid/TP40006556-CH20-SW25: Display a launch image that closely resembles the first screen of the application. This practice decreases the perceived launch time of your application. Avoid displaying an About window or a splash screen. In general, try to avoid providing any type of startup experience that prevents people from using your application immediately. Also, the user doesn't click on the app's icon, they tap on it (see the section entitled Apps Respond to Gestures, Not Clicks) Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Array annotation strangeness
On May 9, 2012, at 1:09 PM, Alex Zavatone wrote: Back on iterating through a mapKit annotation array, I'm bending my brain cell on this one. All my annotations are instances of the MyLocation class I added a method to expose the properties I want to save by returning a dict to the class. After all annotations are added, and I want to walk the array and build an array of annotations, I do this: - (IBAction)saveData:(id)sender { for (NSDictionary * myAnnotation in self.mapView.annotations) { MyLocation *tempLocation = [[MyLocation alloc] init ]; // test that the methods in the MyLocation objects actually work on an empty object NSString *myString = [tempLocation name]; NSDictionary *myDict = [tempLocation returnCoordinatesInDict]; NSDictionary *myStuffDict = [tempLocation returnPropertiesInDict]; // Try it with one of the MyLocation objects in the annotation array NSDictionary *myGoodsDict = [myAnnotation returnPropertiesInDict]; Xcode will not let the last line compile with a Receiver type 'NSDictionary' for instance message does not declare a method with selector 'returnPropertiesInDict' But if I comment out that line, set a breakpoint, it clearly shows that myAnnotation is a myLocation instance just like tempLocation. Does anyone know what I am missing here? You lied to the compiler. You told it that myAnnotation was an NSDictionary: for (NSDictionary * myAnnotation in self.mapView.annotations) even though you knew it was suppose to be a MyLocation (and so it rightly protested when you tried do [myAnnotation returnPropertiesInDict] since NSDictionary doesn't implement returnPropertiesInDict. Try: for (MyLocation * myAnnotation in self.mapView.annotations) Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Device/Resolution independent positioning of GUI items on iOS
On Mar 19, 2012, at 3:22 PM, Brian Lambert wrote: Hi Alex, Regarding you having to repair code where UI elements that have been hardcoded in place with the approach of: Just define the CGRect and we're all good. I think you're seeing things as being gross when they are not. Just define the CGRect and we're all good is what IB does. A XIB file is nothing more than a set of hardcoded values stored in XML vs. being hand-coded in Objective-C. [snip] ... The programmer who hand-coded the label didn't do anything better or worse than the programmer who used IB to lay out a XIB file. In fact, in some cases, it's way easier to see UI in Objective-C vs. Interface Builder. In Objective-C an experienced UI coder can see a bunch of controls, and all their properties, on one screen vs. having to click on each one and inspect their properties in Interface Builder. Except that the runtime can easily substitute another XIB file dynamically to support different layout in iPhone vs iPad (or a different localization). If you hard code this into your code, you've got to hard code in all the differences in device layout as well as any localization specialization. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post 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: Implementing Full Screen for 10.7 but app should also run on 10.6
On Nov 16, 2011, at 3:08 AM, Stefan Werner wrote: On 14.11.2011, at 19:20, Quincey Morris wrote: Don't follow the advice to define NSWindowCollectionBehaviorFullScreenPrimary yourself. It's really, really dangerous to replicate a fragment of one SDK in a build against an earlier SDK. What if the value changes in a later 10.7.x SDK, or if the value is invalidated in some way you can't foresee? If that value changed in a later SDK, it would break binary compatibility. While I strongly suggest against replicating SDK code in your own code for the reason you're giving, it does not apply in this case. Any application compiled today will have a constant number in place of NSWindowCollectionBehaviorFullScreenPrimary. If the OS at some point changes the meaning of that number, it will break all applications compiled before that date. Not necessarily. There are a number of places where the frameworks check to see what SDK you link against to determine what behavior you get, just so that old apps (which are then linked against older SDKs) continue to work as they did, but new/fixed behavior is exhibited when linked against current SDKs. So it could happen that, when X+1 is released, anything that links against X gets the old interpretation of a flag (first implemented in version X), but if you link against X+1 you get the new one. And if you actually link against X-1 (and manually add that flag from the X SDK) who knows what you'll get. Unlikely, but I wouldn't be surprised if this sort of thing hasn't bitten somebody at some point... (though probably with things like side effects of methods, and not different interpretations of constant flags) Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: About iVars declaration and property
On Nov 15, 2011, at 9:48 AM, Torsten Curdt wrote: If you’re 64-bit only (or if you require Lion or better), there’s no real reason to explicitly declare the ivars these days. As others have pointed out, this is not true. There are practical differences between declaring and not declaring the ivar explicitly. I almost never declare the ivar explicitly, but once in a while I need it to show up in the debugger or to be available in a subclass, and then I must declare it explicitly. m. TBH what I don't get is why this cannot be changed in LLVM instead - then we would not have the 64-bit/10.7 restrictions. Of course it would not change what's happening in the runtime but I guess most of people only care what they need to type anyway. In four words: Fragile Base Class Problem. The problem is that a subclass (in 32 bit OS X) needs to know the size of the superclass so it know how to lay out its ivars. If there is no explicit ivars, there is no way for the compiler to know the size (since when it is compiling the subclass it doesn't see all the files that may potentially contain the parent's ivars). Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: UITextField and UIGestureRecognizers
On Nov 10, 2011, at 9:41 AM, Matt Neuburg wrote: On Mon, 07 Nov 2011 17:32:46 +0100, Olivier Palliere oliv...@sunprotectingfactory.com said: I have a UITextField on a view. I want the user to be able to edit it by single tapping on it, but I want to display a popover to chose from a list when the user does a long press on the UITextfield. To do this, I added a LongPressGestureRecognizer on it and implemented the delegate in my controller. Now it works fine when I start my app, and I do a long press on the UITextfield until I edit it once. When I have edited my field using a single tap, if I try to do again a long press gesture, then my recognizer is ignored, the UITextField enters edit mode and the magnifying glass is shown. But surely the real problem is that you're doing something you're not supposed to do. A text field already gives a meaning to a long press (selection), and now you're trying to disrupt that. I recommend you show a menu item instead, which the user can tap to show the list. Or some other alternate interface. *Use* the framework (by letting the framework use you) - don't fight it. m. And it's pretty easy to add a button (or any other UIView) to the UITextField, on either the left or right side, with the option to display when the field is being edited, not being edited, or all the time: @property(nonatomic,retain) UIView *leftView;// e.g. magnifying glass @property(nonatomic)UITextFieldViewMode leftViewMode;// sets when the left view shows up. default is UITextFieldViewModeNever @property(nonatomic,retain) UIView *rightView; // e.g. bookmarks button @property(nonatomic)UITextFieldViewMode rightViewMode; // sets when the right view shows up. default is UITextFieldViewModeNever Seems like putting a button in the rightView that displays when not being edited would work fit with what you described... Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Using version number in code
Or better use [[NSBundle mainBundle] objectForInfoDictionaryKey: key] since that will localize it if possible, which is important if you are presenting it to the user (unlikely that the short version will be localized, but the long one might be) On Oct 21, 2011, at 10:59 AM, Martin Hewitson wrote: Chris, You can get those values like this: NSDictionary *infodict = [[NSBundle mainBundle] infoDictionary]; NSString *bundleVersion = [dict valueForKey:@CFBundleVersion]; NSString *shortVersion = [dict valueForKey:@CFBundleShortVersionString]; CGFloat ver = [shortVersion floatValue]; Cheers, Martin On Oct 21, 2011, at 04:54 PM, Chris Paveglio wrote: In an app's Info.plist there are the 2 values for Bundle Version. Is there a way to use those directly in a class, in code? For example, I often like to put the version number of an app in the title bar or in part of the window (I mostly develop in-house for my company so UI standards can suit our needs, users can see immediately if it's the newest version). So far I've simply made a variable or set the version number directly (as a string) in my AppDelegate class, but if I could somehow use the Bundle Version or Bundle Version String Short that would be great. Any suggestions? Chris ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/martin.hewitson%40aei.mpg.de This email sent to martin.hewit...@aei.mpg.de Martin Hewitson Albert-Einstein-Institut Max-Planck-Institut fuer Gravitationsphysik und Universitaet Hannover Callinstr. 38, 30167 Hannover, Germany Tel: +49-511-762-17121, Fax: +49-511-762-5861 E-Mail: martin.hewit...@aei.mpg.de WWW: http://www.aei.mpg.de/~hewitson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/gandreas%40mac.com This email sent to gandr...@mac.com Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Arc and performSelector
On Oct 16, 2011, at 1:58 AM, Gerriet M. Denkmann wrote: I have this code: for( id aThing in someArray ) { if ( [ aThing respondsToSelector: @selector(setTitle:) ] ) { [ self replaceIn: aThing readSelector: @selector(title) writeSelector: @selector(setTitle:) withTable: tableName ]; } } - (void)replaceIn: thing readSelector: (SEL)selectorIn writeSelector: (SEL)selectorOut withTable: (NSString *)tableName; { NSString *key = [ thing performSelector: selectorIn ]; ... NSString *rep = ... [ thing performSelector: selectorOut withObject: rep ]; } Now, using Arc I am told that PerformSelector may cause a leak because its selector is unknown. What I am supposed to do about this? I really want to have code without warnings. Based on your samples, why not change this to just use KVC instead? for (id aThing in someArray) if ([aThing respondsToSelector: @selector(setTitle:)]) { // too bad there isn't a cleaner way to ask [aThing hasKey: @title] [ self replaceIn: aThing key: @title withTable: tableName ]; } } - (void) replaceIn: (id) thing key: (NSString *) ivarKey withTable: (NSString *) tableName { NSString *key = [thing valueForKey: ivarKey]; ... NSString *rep = ... ... [ thing setValue: rep forKey: ivarKey]; } Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: adding something to a setter
On Oct 6, 2011, at 6:28 AM, Torsten Curdt wrote: The property syntax is great until you need one more thing. Think of a NSView and that view displays a value. @synthesize value; Now you also want to setNeedsDisplay: when a new value is set. So one can override the setter. - (void)setValue:(NSString*)theValue { ... [self setNeedsDisplay:YES]; } but - you would have to implement the setter yourself. No big deal - but... it sucks. Is there a way to forward the setting to the originally synthesized setter? Super cannot be it. Of course one could add another selector that to the interface - (void) setValueAndUpdateDisplay:(NSString*)theValue { self.value = theValue; [self setNeedsDisplay:YES]; } ...but that sucks, too. There gotta be a better way! How do you deal with this? In your .m file, inside either the class extension or an internal use only class category, declare: @property (nonatomic, retain) NSString *sideEffectFreeValue; // or whatever property specifier were on the original property and then synthesize it to use the original ivar @synthesize sideEffectFreeValue=value; and change your setter to: - (void) setValue: (NSString *) value { self.sideEffectFreeValue = value; [self setNeedDisplay: YES]; } Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: [SOLVED] Re: Mystery of the missing symbol
On Oct 2, 2011, at 9:37 PM, Don Quixote de la Mancha wrote: No, that's not something that the deployment target affects. The whole point of specifying one version via the SDK but an earlier version via deployment target is that you can use the features of the later version corresponding to the SDK _if you detect at runtime that they're actually available_. This is a problem on the iOS, because Apple doesn't support installing earlier firmware in our devices, in an effort to defeat jailbreaking. The only way I've found to test what firmware my app is compatible with is to use jailbreaking tools. I shouldn't have to do that. So far I'm satisfied that my app is compatible with iOS 3.0 and later, but I would like to ensure that it is compatible with 2.0 and later. There's no reason it shouldn't be, but I cannot get such an earlier firmware to install. That specific case is ultimately fruitless, since you can't submit an app to the AppStore that has a minimum required OS of 2.x - it needs to be 3.0 or higher. Ultimate, if you need to support older OS versions, you need to keep older hardware around running that version (since newer hardware doesn't support running OS versions that are older than what was originally shipped with the device). Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: NSDateFormatter refuses to format dates
On Sep 27, 2011, at 9:53 AM, Gerriet M. Denkmann wrote: In general, what happens if you temporarily remove the locale and time zone settings? The time zone settings have been already removed, because setting the locale also sets the time zone. NSLocale has no idea about time zones - the two are orthogonal. NSLocale does know what NSCalendar to use (so doing setLocale: should mean that you don't need to do setCalendar:), but a given locale can have more than one time zone, and a single time zone can potentially cross multiple locales. Not that that probably has a whole lot to do with NSDateFormatter returning empty strings... Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSURLConnection: Greedy Memory Eater and Error 303
On Sep 9, 2011, at 6:06 AM, Andreas Grosam wrote: Dir Members, I'm trying to use a NSURLConnection to download a large data file (10 MB) from a web service to the iPhone. Currently, testing on iOS 4.2.1, on a device. The connection is established over WIFI. The problem I get with NSURLConnection is, that it internally uses a lot (really a lot) memory for its data buffers. It seems, the connection reads as much data as it can from the network and a tries to safe it in internal buffers, no matter what, apparently until the system cannot provide more memory. In a simple test app, NSURLConnections quite quickly consumes up to 10Mbyte for a number of its buffers - on the iPhone!, which is probably the maximum before the app will be killed. With Instruments, it can be viewed quite easily. For another datapoint, I've got an app that can (optionally) download a 12.9MB data file which uses NSURLConnection, and it works fine - no threading, just the standard asynch delegate callbacks. I need to make sure that I'm accumulating the data in a file instead of in memory (in connection:didReceiveData:), but there's no problem with crashing or other weird errors. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: nonatomic vs atomic assign/retain
On Sep 7, 2011, at 12:51 PM, Torsten Curdt wrote: So far I have never had to set an outlet itself in code myself. Do people really do this? It's not common, but the point remains, outlets are not at all immutable. AFAIK AppKit only writes to the outlets once. You may only access outlets only after a documented safe point. If one assumes that AppKit does not need synchronized access to the outlets during NIB loading the need for synchronization would depend entirely on how we as developers use the outlets. So whether they are technically immutable or not does not even matter. The question is whether synchronization is needed or not. Of course if would be nicer if outlets would be declared as read-only and only the NIB loading had write access somehow - but I guess that's not in the cards. Anyway. But I am curious - can you provide an example where you modified an outlet? On iOS, a common technique to make complex table view cells is to put them in their own nib files, have a table view controller have: @property (nonatomic, retain) IBOutlet UITableViewCell *loadedCell; and then: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: self.identifier]; if (!cell) { [[NSBundle mainBundle] loadNibNamed:@ComplexTableViewCell owner:self options:nil]; cell = [[self.loadedCell retain] autorelease]; self.loadedCell = nil; } // configure and return cell... } Not to mention that retained IB outlets also need to be nil'ed out when the view is unloaded... Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: rightMouseDown: never called in NSView subclass
The App Store approval guidelines is pretty clear that the use of non-public API is grounds for rejection. NSToolbarView is undocumented, and therefore doing anything that depends on that class or its (undocumented) behavior would seem like grounds for rejection. This would include adding a category to replace a method (which is fraught with peril regardless - categories aren't designed to replace existing methods, since you can't guarantee the loading order of categories from OS release to OS release - including minor updates), subclassing, method swizzling, or even testing to see if an object is one of those undocumented classes. And even if it gets accepted, there is no guarantee that when you need to make an emergency update to fix some critical bug that somehow slipped through or later arose that you'd get accepted that time. On Aug 25, 2011, at 11:46 PM, Indragie Karunaratne wrote: Is there any other way to do this aside from what I'm doing right now? As far as I know, I have two choices: a) Use this method and risk something breaking b) Write an NSToolbar clone I know the risks, but if I could get this to pass through Mac App Store submission then I'd rather deal with possibility of something breaking later on that than to rewrite NSToolbar. The one last thing I can think of is to use the ObjC runtime to retain the original implementation, swizzle hitTest: and check whether my view is under the cursor, and if not, just call the original implementation. However, method swizzling always feels like a dirty workaround so I'm not sure if it would be much better than this (and if it would be acceptable in the MAS). Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: +[UINib nibWithNibName:bundle:] and ~iPhone
More specifically, from the documentation: To associate a resource file with a particular device, you add a custom modifier string to its filename. The inclusion of this modifier string yields filenames with the following format: basenamedevice.filename_extension The basename string represents the original name of the resource file. It also represents the name you use when accessing the file from your code. Similarly, the filename_extension string is the standard filename extension used to identify the type of the file. The device string is a case-sensitive string that can be one of the following values: • ~ipad - The resource should be loaded on iPad devices only. • ~iphone - The resource should be loaded on iPhone or iPod touch devices only. I.e, it needs to be UserLeagueCell~iphone.xib, not UserLeagueCell~iPhone.xib. On the simulator, OS X, not being case sensitive, will load find UserLeagueCell~iPhone.xib but on the device, being case sensitive, it will only look for UserLeagueCell~iphone.xib. p.s., good luck dealing with renaming UserLeagueCell~iPhone.xib to UserLeagueCell~iphone.xib if you've got it checked into svn. The last time I made that mistake I found it was easier to just check in a brand new file with a different name all together (like UserLeagueCell2~iphone.xib) than to deal with the but it is already checked out, even though the case is wrong... On Aug 17, 2011, at 7:56 AM, Jim Adams wrote: Did you check that cases of the names involved? -Original Message- From: cocoa-dev-bounces+jim.adams=sas@lists.apple.com [mailto:cocoa-dev-bounces+jim.adams=sas@lists.apple.com] On Behalf Of Rick Mann Sent: Wednesday, August 17, 2011 12:35 AM To: Cocoa Developer Subject: +[UINib nibWithNibName:bundle:] and ~iPhone I'm seeing some weird difference between Device and Simulator for iPhone. Xcode 3.2.6 Simulator 4.3(8F190) iOS 4.3.38J2) I call UINib* nib = [UINib nibWithNibName: @UserLeagueCell bundle: nil]; on the simulator, this actually seems to return the nib named UserLeagueCell~iPhone.xib. On the device, it returns the nib named UserLeagueCell.xib. Is this a known difference in the two? 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/jim.adams%40sas.com This email sent to jim.ad...@sas.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/gandreas%40mac.com This email sent to gandr...@mac.com Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: CGContextShowTextAtPoint doesn't show text
On Aug 9, 2011, at 9:48 AM, Gabriel Zachmann wrote: Thanks a lot for your response ... I've found the Core Graphics text handling methods to be gnarly and awkward the few times I've attempted to use them, and always ended up going some other route to render text. Could you please point me to a few of them? In your case, the choice seems simple - just use CATextLayer. Why not? Can CATextLayer render text with a shadow? Like this: CGContextSetShadowWithColor( ctxt, CGSizeMake(0,0), 10, blue ); I really need the shadow to be able to discern it from a background layer, the color of which is unknown and changes fairly often. CATextLayer is a subclass of CALayer, which has a wide variety of shadowing options: /** Shadow properties. **/ /* The color of the shadow. Defaults to opaque black. Colors created * from patterns are currently NOT supported. Animatable. */ @property CGColorRef shadowColor; /* The opacity of the shadow. Defaults to 0. Specifying a value outside the * [0,1] range will give undefined results. Animatable. */ @property float shadowOpacity; /* The shadow offset. Defaults to (0, -3). Animatable. */ @property CGSize shadowOffset; /* The blur radius used to create the shadow. Defaults to 3. Animatable. */ @property CGFloat shadowRadius; /* When non-null this path defines the outline used to construct the * layer's shadow instead of using the layer's composited alpha * channel. The path is rendered using the non-zero winding rule. * Specifying the path explicitly using this property will usually * improve rendering performance, as will sharing the same path * reference across multiple layers. Defaults to null. Animatable. */ @property CGPathRef shadowPath; So not only does it have a shadow that you can change, you can even animate the shadow. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: UITableViewController, with table view not the root of its nib?
On Aug 3, 2011, at 3:49 PM, Jens Alfke wrote: I’ve got an iOS screen that incorporates a UITableView. This screen is run by a UIViewController subclass. I’d like to subclass UITableViewController instead, to get more table behaviors for free. The problem I’m running into is that the table view is not the root view of my nib. (There’s a text field above the table that’s a sibling of it.) As far as I can tell, UITableViewController only works when the table is the root of the nib. It does have a separate ‘tableView’ property, but this isn’t an IBOutlet so there’s no way to wire it up to the table view in the nib. Instead, the class assumes that the ‘view’ outlet — which must point to the nib’s root view — is the table view, and raises an assertion failure otherwise. I’m trying to figure out a way around this, but every workaround I think of makes the project more complicated, canceling out the benefit of switching to UITableViewController. Is there a clean way of doing it that I’m missing? UITableViewController, like all UIViewControllers, expect their view to be the root of the window (where root is defined as either being the only subview of the UIWindow) or the current/topmost view controller of a UINavigationController, UITabViewController, UISplitViewController, etc... UIViewControllers are not designed to have their views inside other arbitrary views (except for the previously mentioned UINavigationController, etc...). For more detail, there was a WWDC session on Implementing UIViewController Containment. To add a text field (or other arbitrary views) along side the table view, you have a couple of choices: - Put it in the table view header view. Disadvantage is that it can get scrolled off screen - Put the view in a row in its own section. Similar to previous - Put it in the first section's header view. Only works well if you have a single section, are in non-grouped mode - Put the view into the navigation controller's title view. Limits the height of your view, and assumes you've got a nav controller, and aren't already using the title You can also play games where you add the view to the tableview itself, and, since the tableview is a scrollview, adjust the content to allow that item to show, and then, upon scrolling, make sure the view is on the top of the screen (both in Y and Z coordinates, since the table view may have made a new cell that ends up layered covering your view) Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Unnecessary Boolean Warning
On Aug 3, 2011, at 8:27 PM, Graham Cox wrote: On 04/08/2011, at 11:19 AM, Greg Parker wrote: This is a classic question for coding job interviews. Incorrect. Ah well, I guess I didn't get the job :) In my defence, I saw this in a job interview but it was prior to 1999. Maybe C99 tightened up on something that was previously vague. --G. My copy of KR © 1978 says: More interesting are the logical connectives and ||. Expressions connected by or || are evaluated left to right, and evaluation stops as soon as the truth or falsehood of the result is known. These properties are critical to writing programs that work. (p 38) and later in Appendix A: C Reference Manual: Unlike , guarantees left-to-right evaluations; moreover the second operand is not evaluated if the first operand is 0 (p190, section 7.11 Logical AND operator) Unlike |, || guarantees left-to-right evaluations; moreover the second operand is not evaluated if the first operand is non-zero (p191, section 7.12 Logical OR operator) Nothing vague there. More likely the somebody that interviewed you didn't have it correct in the first place, scarring you for life... Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: UIAlertView with UITextField
And how well will that approach work with an updated release that moves things around to different locations? Hint: many apps have broken with updated OS releases when system UI objects are changed internally. Anything that hard codes in coordinate assumptions of system views is problematic - especially code like: [UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)] or: CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, 130.0); [self setTransform:translate]; The hard coding of coordinate values also can cause problems when running the OS with a non-English language (since the metrics of different languages can be different). On Jul 27, 2011, at 12:47 PM, Dan Hopwood wrote: Thanks David. And do you or does anyone else know if Apple would permit implementing something like the following, which gives a very similar result: http://iphonedevelopment.blogspot.com/2009/02/alert-view-with-prompt.html Thanks, Dan On Jul 27, 2011, at 18:14, David Duncan david.dun...@apple.com wrote: On Jul 27, 2011, at 10:02 AM, Dan Hopwood wrote: This works really well and is exactly what I am looking for however a little reading tells me Apple may reject submissions that use this private API. Yes, you will be rejected for using private API. -- David Duncan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/gandreas%40mac.com This email sent to gandr...@mac.com Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Reading old NSArchiver serialization, expecting CGRect, finding {?={?=ff}{?=ff}}
Are you decoding it from a 64 bit app? Because CGRect on 64 bits is made of doubles, while on 32 bits (where it was probably encoded) it was made of floats Also, the exact format for @encode() varies greatly between compiler version (especially with regards for things like structure names vs ?, etc...). This, in and of itself, shouldn't make it incompatible, but a structure with two structures each with two floats doesn't match with the double-based CGRect. On Jul 13, 2011, at 12:20 PM, Philip Dow wrote: I am trying to decode a 3rd party archive encoded in the old NSArchiver (not keyed) format. At a point in the decoding, I expect to find a CGRect, but when I call [coder decodeValueOfObjCType:@encode(CGRect) at:myRect] an exception is raised with the error: file inconsistency: read '{?={?=ff}{?=ff}}', expecting '{CGRect={CGPoint=dd}{CGSize=dd}}' Sure enough, if I open the file in a text editor, I see {?={?=ff}{?=ff}}. According to the docs, the curly braces indicate a structure is encoded, which I would expect for CGRect, but the ? indicates an unknown type. I'm stumped for a solution and was wondering if anyone might have an insight. ~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/gandreas%40mac.com This email sent to gandr...@mac.com Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Using a Soundex category...
On Jul 6, 2011, at 1:23 PM, Eric E. Dolecki wrote: I found a Soundex NSString category here: http://www.cocoadev.com/index.pl?NSStringSoundex However, when I tried it out I get strange results... //someString is set to different strings each time tested BOOL test = [someString soundsLikeString:@Face]; NSLog(@sounds like Face: %d,test); Place = 0 Ace = 0 Mace = 0 Fake = 1 Testing = 0 Brake = 0 It would seem something is off to get negatives on Place, Ace Mace. Any ideas or perhaps a different Soundex implementation I could try? I am already using Levenstein distance, but on it's own it's not good enough. Soundex is based on having the first character providing a unique sound, with the rest of the character mapped together. If you wanted to ignore that first character distinction, prepend your strings with a character like X that is unlikely to be a first character (since otherwise you'll get into trouble with its drop double letters step). The code appears to not care what the first character is (i.e., doesn't test for alphabetic characters), so you could probably use something like #. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: UIKeyboard (without Text filed)
On May 24, 2011, at 5:28 PM, Jeffrey Walton wrote: Hi All, Is it possible to display a keyboard and take input from (via a delegate) without using a text field? There's not much reading from Apple's doc: http://www.google.com/search?sourceid=chromeie=UTF-8q=UIKeyboard+class+reference+site%3Aapple.com Jeff You can always have the text field be way off screen (that's the easy way, and works on older systems), or you can have a view that implements the various UIKeyInput protocol methods and have it become the first responder. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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 nib weirdness...
On May 4, 2011, at 9:00 AM, Steve Christensen wrote: I'm working on an app that uses a tab bar. I created a new nib to set up a view+controller and added a new tab item to the main nib that references the controller and the controller's nib, plus I filled in some basic functionality in the view controller. Since it's relevant, the controller's IBOutlets are IBOutlet MyTableView* _resultsTable; IBOutlet UIActivityIndicatorView* _searchActivityIndicator; IBOutlet UISearchBar* _searchBar; First step: Don't prepend your ivars with underscores. From http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingBasics.html, and I quote: • Avoid the use of the underscore character as a prefix meaning private, especially in methods. Apple reserves the use of this convention. Use by third parties could result in name-space collisions; they might unwittingly override an existing private method with one of their own, with disastrous consequence. You may be seeing one of those disastrous consequences Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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 Best Practice Question
On Apr 26, 2011, at 4:36 PM, koko wrote: So we have one vote for: 3. Use a view in a layer of the current view Any other views (no pun intended) ... going once going twice Any comments against : 1. Use UIAlert - easy but seems clunky -koko Adding additional content in UIAlert is not recommended, since it requires a high degree of care and verges on something that can get an app rejected from the App Store. (you've got to do special casing for different versions of the OS and make bad assumptions about the layout of the subviews, and will quite likely break when the next OS release happens). In general, if you can avoid making a UIPickerView appear as the result of an action, you'll be better off. Make it part of the UI, always available, or use a different mechanism (for example, in a table view, just push a second table view onto the navigation controller and let the user select the element from that table view, just like Settings.app does, etc...) Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Reading RGBA pixel values from image on disk
On Mar 10, 2011, at 12:47 PM, Leonardo wrote: I forgot: if I save the TIF from Photoshop marking the check-box Save Transparency, on my App I can quite read the alpha channel, and the RGB values are not pre-multiplied. That's fine. Anyway, without the Save Transparency, on my App I get the RGB values pre-multiplied and the alpha values are all 1.0, so I can't calculate the original RGB values. The weird point is that if I re-open this TIF file with Photoshop, the half-a-transparent pixels are well visible. So the alpha information has been properly stored within the TIF file, somewhere. I would like to know where. TIFF file formats can include a wide range of tags, including private use ones that would be used by Photoshop to store whatever they want, up to, and probably including, the Ark of the Covenant (or in this case, some variation on a .psd file) But bottom line is, if you are saving the file without transparency, that is what you are getting in the publicly documented parts of the file - it would be wrong for NSImage to use those private tags to give you anything other than what the file publicly presents (i.e., attempting to reading alpha from a file that has tags declaring it to not have alpha would be non-conformant with the TIFF spec). Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Notifications and Subclassing
On Mar 8, 2011, at 9:42 AM, Gordon Apple wrote: Class A: NSObject, has methods: - (void)foo:(Notification*)notification { ... } - (void)addObservers { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(foo:) name:notificationName object:nil]; } Class B: subclass of A. This is the class used. Notification sent from elsewhere. Console: -[NSCFString foo:]: unrecognized selector sent to instance 0x69807c0 Is this due to confusion of of which class received the notification? Or is this a compiler/linker bug? I even tried declaring foo in A’s headers, to no avail. This same overall procedure is used elsewhere (without subclassing), with no problems. What am I missing? That's a classic memory management problem. Most likely, you're forgetting to unregister your observer when you are deallocating it (resulting in a notification center to have a stale pointer that is later reused by an NSString). Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: NSXMLParserDelegateAbortedParseError
On Mar 8, 2011, at 3:13 PM, Josh Caswell wrote: Hi Kevin, Thanks for your reply. Sorry, maybe my explanation is not clear enough (I may have left out too many details). It's not a network error that I am talking about, but, as you say, an API error for which the server returns valid XML. The specifics: I'm requesting weather data for a location by latitude and longitude. If I give the server a request that has, for example, a bad latitude, it will return valid XML, which parses fine, with an error element and a message describing the problem with the request: Data xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:noNamespaceSchemaLocation=http://na.unep.net/swera_ims/WS/SWERA.xsd;Error110/ErrorErrorMessageLatitude point must be between -90 and 90/ErrorMessage/Data If my parser comes upon an Error element, the delegate tells it to get the ErrorMessage contents and then aborts the parsing. Then the message (Latitude point must be between...) is used for an alert sheet as I described. I'm just wondering why, after my delegate aborts the parse, the parser changes the error code. Probably because the parser is reporting the parse aborted error? From the header: - (void)abortParsing; // called by the delegate to stop the parse. The delegate will get an error message sent to it. So you are getting an error because you aborted the parser (which knows not a thing about your concepts of Error and ErrorMessage as returned by the server): - (NSError *)parserError; // can be called after a parse is over to determine parser state. This error is the parser state, which since you explicitly aborted the parse, will be something like NSXMLParserDelegateAbortedParseError -512. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Outlets Not Connected In awakeFromNib
On Mar 2, 2011, at 3:54 AM, Andreas Grosam wrote: I have a very basic custom UIViewController with its own associated nib file. This view controller is the root view controller of a Navigation Controller which is itself embedded within a Split View Controller which is defined in another nib - say the main.nib. Within IB this root view controller has its Nib Name property specified, which means that this view controller is defined in an extern nib file. This scenario is the standard way for defining nibs and view controllers when using a Navigation Controller. To illustrate an example for the main.nib: File's Owner First Responder Window App Delegate Split View Controller Navigation Controller Navigation Bar Root View Controller- Nib Name = MyRootViewController.nib Detail View Controller My root view controller also defines some properly specified outlets - for instance a view which is embedded within the same nib file and referenced via an outlet from the class. During -awakeFromNib for the root view controller, none of these kind of outlets are connected. This is quite confusing, since the documentation explicitly says otherwise. What's going on is that awakeFromNib is called when the nib containing the object is instantiated. In this case, it is the main nib (which is where the root view controller lives). However, a view controller's nib (MyRootViewControler.nib) isn't loaded until it is actually needed, at which point the view controller gets viewLoaded message, and so, until that time, any connections between the view controller and things loaded from MyRootViewController.nib will be nil. During -awakeFromNib for the root view controller, none of these kind of outlets are connected. This is quite confusing, since the documentation explicitly says otherwise. Not exactly - when awakeFromNib is called, all the connections within that nib are connected. So if root view controller had an appDelegate outlet that was connected to the App delegate, that would be set when awakeFromNib was called. The Nib Name = MyRootViewController.nib is only an outlet in the sense that the view controller's nibName ivar will be set to MyRootViewController.nib (which it will be during awakeFromNib). The whole purpose of having separate nibs is to avoid recursively loading everything all at once - if that view is never displayed (say, on a tab bar controller tab that the user never selects), its nib will never be loaded. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Home-brewed code is 100X faster than -[NSScanner scanDecimal:] ??
On Feb 3, 2011, at 10:35 AM, Jerry Krinock wrote: -[NSScanner scanDecimal:] takes an average of 4 milliseconds to scan a short string of decimal digits, which means tens of seconds for thousands of scans, which is unacceptable for my application. Also, excessive memory allocations require a local autorelease pool around each invocation. Surprisingly, I was able to fix both problem by replacing -scanDecimal: with a rather bone-headed home-brew implementation, using -scanCharactersFromSet:intoString: instead. The home-brew implementation runs 100 to 150 times faster. How can this be? Your scanner doesn't correctly handle all valid decimals. First, you don't handle scientific notation. More importantly, you do not handle the full range of NSDecimal which is documented to be 38 _DECIMAL_ digits. This is important because scanning in 0.1 into a double will result in loss of accuracy (since 0.1 can't be expressed exactly in binary), where as NSDecimal will be able to handle it correctly. For that matter, 52 bits of mantissa on a double is only approximately 16 decimal digits (no where near as close as the 38 decimal digits of NSDecimal). Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Home-brewed code is 100X faster than -[NSScanner scanDecimal:] ??
On Feb 3, 2011, at 3:05 PM, Jerry Krinock wrote: Thanks, Glenn, and thanks, Matt, for the explanation. So I added a parameter to my method which one can use to get the performance improvement only if they are willing to compromise accuracy and parsing of numbers written in e notation. Also, I chose a name which is less likely to used by Apple. Why not just use NSScanner's scanDouble: instead of trying to scan a string that you think is valid and then convert to a double? For example, if the input string is @123.45-67.89 you'll end up scanning the entire string (which scanDecimal: or scanDouble: will only scan up through the 5). Using scanDouble: will give you back support for scientific notation and consistent handling of unexpected strings, and all the other subtleness that can occur with floating point parsing (for example, you're code also misses handling things like +123) Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to scale a TabBarItem Image
On Jan 26, 2011, at 5:10 AM, ico wrote: Hi All, I want to add a UITabBar in my UIViewController, I don't want to use UITabBarController because I need to push this view controller into a navigation controller. Don't do that. From the View Controller's Guide for iOS: Note: Although a navigation controller can be embedded inside a tab, the reverse is not true. Presenting a tab bar interface from within a navigation interface is potentially confusing for users. A navigation interface uses one or more custom view controllers to present an interface focused on one goal, which is usually the management of a specific type of data. By contrast, the tabs of a tab bar interface can reflect completely different purposes in an application and need not be related in any way. In addition, pushing a tab bar controller on a navigation stack would cause the tabs to be displayed for that screen only and not for any others. What you are attempting to do is going to be an issue that can get prevent your app from being approved in the App Store. Rethink your UI design and approach - you'll be better off in the long run... Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: execute system(some script) on behalf of root from non-root app
Executing arbitrary scripts as root is also a potentially major security hole. Your goal should be to do as little as possible as root (or other elevated privileges), and with as little flexibility as possible. Security is hard, and if you don't understand the issues, you should take a step back and learn them before attempting to work them. If you get them wrong, you've just exposed your customers to having their machine attacked. On Jan 5, 2011, at 1:49 PM, Shawn Bakhtiar wrote: Search google is not an answer, although a good suggestion. Could you please post the solution you came up with to the list. There are many ways to skin this cat, I think we would all benefit from your experience. Correct. You are NOT running them as root, but you can easily tell the script to sudo su and go from there, which in effect will make you root. Also have you looked at making the uninstaller be an apple script? Also does any one know if there is a setup program like there use to be on Windows (IE Nullsoft)? Date: Wed, 5 Jan 2011 21:40:09 +0200 From: eveningn...@gmail.com To: n...@chronosnet.com CC: cocoa-dev@lists.apple.com Subject: Re: execute system(some script) on behalf of root from non-root app Thanks Nick, i really should've googled before asking. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/shashaness%40hotmail.com This email sent to shashan...@hotmail.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/gandreas%40mac.com This email sent to gandr...@mac.com Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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 when is my app launched
On Dec 8, 2010, at 7:38 AM, Jason Bobier wrote: Hey Dave, I'm talking about the Carbon equivalent of processLaunchDate in the ProcessInfoExtendedRec. This is the actual date time that the process launched. I want to use it to give my game's splash screen a consistent amount of time on screen. Here's how: I set the Default.png to the splash screen and immediately show the same image when my app launches. I then check the launch date to determine how much time it has shown and add x number of seconds to that. Don't do that. From http://developer.apple.com/library/safari/#documentation/UserExperience/Conceptual/MobileHIG/IconsImages/IconsImages.html%23//apple_ref/doc/uid/TP40006556-CH14-SW1: Supply a launch image to improve user experience; avoid using it as an opportunity to provide: • An “application entry experience,” such as a splash screen • An About window • Branding elements, unless they are a static part of your application’s first screen Because users are likely to switch among applications frequently, you should make every effort to cut launch time to a minimum, and you should design a launch image that downplays the experience rather than drawing attention to it. So Default.png is not suppose to be a splash screen, and you're suppose to strive to make it go away as fast as possible - not figure out ways to display it for longer... Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Calculating Scale Factor touchesMoved event.
On Dec 2, 2010, at 9:37 AM, Gustavo Adolfo Pizano wrote: now in my touches moved I do the following, the first part applies a rotation, which is working properly, except that after the first move the angle is 180 from what the view has, so you see that the view turns 180 degrees!!, CGFloat a = atan2(-dx,dy); atan2's parameters are declared as: double atan2(double y, double x); Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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] setting table style for root view controller of a navigation controller
On Dec 2, 2010, at 11:47 AM, Matt Neuburg wrote: On Dec 1, 2010, at 6:58 PM, Donald Hall wrote: I have come to the conclusion that what I wanted to do is not easily done unless the table view controller has its own nib file. In IB if you don't specify that the table view controller that is the root view controller of a navigation controller has its own nib file, there is no access to the actual table view in IB, so no way there to specify the table style. (The inspector window for a table view controller has no setting to specify the style.) Hitting the disclosure triangle for the custom table view controller in the main window nib file in that case only shows the Navigation Item - it doesn't show the table view. To access the controller's table view you have to have a separate nib file for the table view controller and tell the main window nib in the Attributes Inspector to load from this other nib. This just isn't so. You say Hitting the disclosure triangle for the custom table view controller in the main window nib file in that case only shows the Navigation Item - it doesn't show the table view. It doesn't show the table view because you didn't put any table view there. If you drag a table view into the table view controller, that becomes its view and now you can hook everything up. This is in some ways not as convenient as putting the table view in its own nib file, but you can certainly do it that way. My own inclination, however, would be to go exactly the other way - no second nib, no table view in any nib, and no UITableViewController in a nib either. In fact, I probably wouldn't even use a UITableViewController at all. UITableViewController doesn't get you anything much that you can't do in code yourself. Actually, it does a number of things for you: 1) It flashes the scroll bar correctly when the view appears 2) It can automatically deselect selected rows (in 3.2 and later) 3) Most importantly, it will handle dealing with keyboards showing up and covering part of the table view (and adjust the scroll/content inset), which can be a painful mess, especially trying to support both pre 3.2, and 3.2/4.x (since not only are the keyboard notifications different, but it deals with the view being presented in the variety of different ways - sheet, full screen, etc...) Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: NSTask with unzip
On Nov 28, 2010, at 4:51 PM, Leonardo wrote: Great! Thanks for the advises. Now I have to zip and unzip a NSData (not a zip file) to a NSData. In other words, I have to zip and unzip data to data, without using any file. Some idea? -- Leonardo A quick google search turns up several Cocoa zip frameworks out there that will avoid having to use NSTask, etc... all together. While the zip file format is ugly, it is documented and you can always write your own to walk through a zip file to find the objects you want and use the standard zlib routines to do the compression/decompression. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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 location enabled?
On Nov 24, 2010, at 2:31 PM, Rainer Standke wrote: Hello, wondering if there is a way to detect whether the location services are enabled for the app. I am not after the global enabledness, but after the enabledness of my app. I imagine the OS stores this information somewhere, but can we get (read) access to that programmatically? CLAuthorizationStatus status = [CLLocationManager authorizationStatus]; Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Running JavaScript in iOS WebView.
On Nov 17, 2010, at 3:33 PM, Geoffrey Holden wrote: I've written an app for the Mac (which runs rather nicely) and now I'm trying to port it to iOS (where it won't run at all). The particular line of code which is causing a problem is this: [webView stringByEvaluatingJavaScriptFromString:cmdStr]; cmdStr contains the following: rcs.invoke(dojo.fromJson('{pw:password,type:signIn,email:geoff.hol...@45rpmsoftware.com}')); I'm using the JSON framework on Google code (http://code.google.com/p/json-framework/), which (I'm assured) is iOS compatible. It certainly builds without trouble. The error I get when this line (fails to) execute is: void SendDelegateMessage(NSInvocation*): delegate (webViewDidLayout:) failed to return after waiting 10 seconds. main run loop mode: GSEventReceiveRunLoopMode I have got webViewDidFinishLoad (that's where this code is called) - so it isn't that it's trying to run on nothing. If you have any ideas about what I could do to fix this, I'd be most interested to hear them! From the documentation http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html: JavaScript execution time is limited to 10 seconds for each top-level entry point. If your script executes for more than 10 seconds, the web view stops executing the script. This is likely to occur at a random place in your code, so unintended consequences may result. This limit is imposed because JavaScript execution may cause the main thread to block, so when scripts are running, the user is not able to interact with the webpage. So one of your routines (I'm guessing rcs.invoke) is taking a long time (more than 10 seconds - perhaps it is waiting for some networked based action to complete). So if your JavaScript code is waiting for completion, you're going to have to refactor that code to work more asynchronously and not block. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: RTFDFromRange returns different data
On Nov 11, 2010, at 8:12 AM, gMail.com wrote: RTFDFromRange returns different data even if I do not change the variables mTextMutableString nor mDocAttributes. I just call several time: NSData *textData = [mTextMutableString RTFDFromRange:textRange documentAttributes:mDocAttributes]; NSLog(@textData %@, textData); And 'every time' I get a different textData log text. Of course I compare the text starting from For example, at any call I get (this is the last changing part of the log text) 1) edecdb4c b601 2) 2aebdb4c b601 3) a6f8db4c b601 4) bef8db4c b601 Why does RTFDFromRange returns a different data, even if the variables didn't change? How to get the same data? Is it a bug? RTFDFromRange returns an archived (flattened) version of RTFD, which is undocumented but probably includes things like time stamps or unique IDs. So it is not a bug - archiving the same original data is not guaranteed to return byte-for-byte identical archived results (but will return the same thing when unarchived). Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: AM/PM letter UNICODE issues
On Oct 18, 2010, at 12:19 PM, Alex Kac wrote: I'm fairly certain my problem here is that I wasn't thinking about unicode terms here. What we are trying to do: Shorten the AM/PM to just the first character in Western Languages so that a time is shown as 1:30a. NSDateFormatter* formatter = [[NSDateFormatter alloc] init]; NSString* am = [[[formatter AMSymbol] substringToIndex:1] lowercaseString]; NSString* pm = [[[formatter PMSymbol] substringToIndex:1] lowercaseString]; This works in Western languages just fine. Not sure that this is even true - in Germany, time is displayed normally using a 24 hour notation (no AM/PM), and this true in many other locations as well. See http://en.wikipedia.org/wiki/Date_and_time_notation_by_country for all sorts of other gory details and special cases. Even for US cases, there are people who set their time format to use 24 hour time and so would expect to see 13:00 and not 1:00p. Bottom line is trying to display time in a non-standard format is going to be problematic and have support issues. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: reused tableViewCell UILabel text is deallocated but not nil ??
On Oct 7, 2010, at 11:30 AM, nicolas berloquin wrote: I turned on zombies, and I checked with the debugger, and the textLabel's _text is the deallocated instance (myName.titre is good). This may be a red herring as the state of _text should not effect the ability to assign the property value, generally speaking. Unless they compare the strings before they replace them which is what they seem to do. I have changed my code to do a copy o the string before I assign it to the label and it works. What I don't understand is why the API doesn't either retain or copy it !! It probably does (and so needs to send a release to the old value). What is likely happening is that you've got your memory management screwed up somewhere, and are over-releasing the (what will be the old) string value, which causes the text fields text ivar to point to garbage. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: UITableview scrollStyle
On Sep 24, 2010, at 1:03 PM, Eric E. Dolecki wrote: Is white and black our only options for the scroller indicator in a UITableView? I was hoping to change mine to a blue since mine is on top of black and would match the design better. UITableView is a subclass of UIScrollView, so you can just set the scrollbar type. However, like UIScrollView, you are limited to three choices - all black, all white, or black with a white border... Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Box soft shadow?
On Aug 23, 2010, at 9:02 AM, Eric E. Dolecki wrote: I was asked to provide a soft drop shadow for a custom UIView class... and basically I am looking to create a soft shadow beneath a square opaque element. I'd like to do this without using a PNG. How would I do this? I am googling, and found something for text, but not just for a simple square shape. Draw with CGContextShadow set appropriately, or set the shadow property of the CALayer of the UIView (if you are requiring iOS 3.2 or later) Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: who stole my UIView?
On Aug 12, 2010, at 6:28 PM, Matt Neuburg wrote: Here's my code, simplified (and tested in this simple form) in order to demonstrate a mystery: - (void) illuminate: (NSArray*) arr { UIView* v = [[UIView alloc] initWithFrame:self.view.bounds]; NSLog(@%@, v); CALayer* lay = [v layer]; v.tag = 111; [self.view addSubview:v]; lay.delegate = self; // -- *** Don't do that. From https://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/doc/uid/TP40006816-CH3-SW31 Warning: Since the view is the layer’s delegate, you should never set the view as a delegate of another CALayerobject. Additionally, you should never change the delegate of this layer. Basically you're break the underlying plumbing, connecting the cold water to the electrical, and wondering why your water tastes tingly... Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: NSKeyedArchiver on OSX to NSKeyedUnarchiver iOS
On Aug 11, 2010, at 3:53 PM, Sandro Noël wrote: Greetings I'm having problems unarchiving my data in the iphone. here is the workout. 1: I archive a AttributedString to my CoreData NSData property using NSKeyedarchiver 2: Transfer the database to the iphone. 3: load the data using NSKeyedUnarchiver on the iphone. NSAttributedString *as = (NSAttributedString*)[NSKeyedUnarchiver unarchiveObjectWithData:attributedStringData]; that crashes saying: -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (NSFont) I understand that the NSFont is UIFont on the iphone, or has similarities. so i implemented a Delegate method to replace the class. //-- - (Class)unarchiver:(NSKeyedUnarchiver *)unarchiver cannotDecodeObjectOfClassName:(NSString *)name originalClasses:(NSArray *)classNames{ if ([name isEqualToString:@NSFont]) return [UIFont class]; return nil; } but that never gets called because the class method does not allow for a delegate and instantiating the unarchiver class confuses me in how I should trigger the decoding once it is instantiated. Any pointers ? You're going to run into worse problems - UIFont is not NSFont, nor can you trivially substitute one for the other. In general, while you can archive an NSAttributedString on OS X and unarchive it on iOS, it's not going to work the way you want it to. Any of the interesting properties that define things like appearance of the string, are platform specific. There is no NSForegroundAttributeName, for example, on iOS, and even if you explicitly look for appropriate key, on OS X this will contain an NSColor, which, of course, does not exist on iOS (and UI color is similar, but the encoding of NSColor is undocumented, so even if you attempt to manually handle the decoding and try to make a UIColor, it would require that undocumented information - not to mention that there are parts of NSColor such as color space that don't exist at all on iOS). Similarly for font information, paragraph style (including alignment, tabs, margins), embedded images, etc... You might be able to get away with using CoreText and it's attributes (which are based on CG/CT objects like CGColor and CTFont), but obviously that's not what you're going to get from AppKits default attributed string support. So you'll probably have to give up on using AppKit's NSAttributedString extensions all together, and switch to the CoreText ones (and take advantage of the CFAttributedString/NSAttributedString toll free bridging). Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iPhone] UITableViewCell Height with UIWebView content
On Aug 10, 2010, at 2:04 PM, Sandro Noël wrote: Greetings. I've been trying to set the table view cell's height for a custom tableviewCell containing a UIWebView to display attributed content but i cant's get the height properly. [snip] since it is so tedious, Now i'm thinking this is a design flaw on my part, trying to resize a TableCellView with posibily big content. any advice? Rethink your design - putting a UIWebView inside a UITableView is usually a bad idea for a number of reasons, including: - not being able to tell the height of the view until far too late to be any good (UITableView needs to know before it is displayed, UIWebView can't know until after everything has been loaded) - views which scroll vertically inside other views which scroll vertically can cause a bad user experience (though at least as of 3.x they work - in previous OSes the results were far less useful), - UIWebView is a very heavy weight view, and UITableViewCells are designed to be light weight You should probably put the resulting UIWebView in its own view controller, and push that as a disclosure of the table cell (or detail disclosure). If your goal is just to display styled text inside a table row, you can use things like NSAttributedString/CoreText (or for pre 3.2 support, CFAttributedString custom drawing routines). Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: CGImage to NSImage, or PDFPage?
On Aug 10, 2010, at 4:45 PM, Brian Postow wrote: I'm not sure if this is rightly a Cocoa question or Quartz, so I'm posting on both lists. Sorry for the double... I have a CGImageRef, and I need to put it into a PDFPage. At the moment, the only way I see to do that is to turn it into an NSImage first. I've currently got: [snip] Is there something obvious that I'm missing? How about -[NSImage initWithCGImage:(CGImageRef)cgImage size:(NSSize)size] if you're using 10.6, or use -[NSBitmapImageRep initWithCGImage:(CGImageRef)cgImage] and add it to an NSImage if you're using 10.5? Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Unarchiving issues
On Aug 2, 2010, at 12:46 PM, James Maxwell wrote: // set the contents of the array continuations = (float*)[aDecoder decodeBytesForKey:@continuations returnedLength:size]; From the header file: - (const uint8_t *)decodeBytesForKey:(NSString *)key returnedLength:(NSUInteger *)lengthp; // returned bytes immutable, and they go away with the unarchiver, not the containing autorlease pool And from the documentation: Discussion The returned value is a pointer to a temporary buffer owned by the receiver. The buffer goes away with the unarchiver, not the containing autorelease pool. You must copy the bytes into your own buffer if you need the data to persist beyond the life of the receiver. So if your setContinuationSize: allocates memory, you should: const uint8_t *bytes = [aDecoder decodeBytesForKey:@continuations returnedLength:size]; NSAssert(size == [self continuationsSize] * sizeof(float), @Bad size of bytes returned from decoding); memcpy(continuations, bytes, size); Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: setValue:forKey: and invocation forwarding
On Jul 13, 2010, at 7:53 AM, Graham Cox wrote: It appears that calling -setValue:forKey: on an object bypasses or ignores any invocation forwarding it has set up, unless I'm missing some obvious error. I have an object that acts as a wrapper for another object, and so that the wrapper can, under some circumstances, act as the thing it is wrapping, it implements invocation forwarding using the 'classic' approach of overriding -respondsToSelector:, -methodSignatureForSelector: and -forwardInvocation: but when I call -setValue:forKey: on the wrapper (where key is implemented by the thing wrapped), it throws the 'not key-value coding compliant for key' exception. The stack trace appears to show that this failure occurs before it has even attempted to follow the forwarded path. However if I simply call the wrapped property setter directly, the forwarding works. As this needs to work on 10.5, I can't use the 10.6 solution of -forwardingTargetForSelector: (not that I've tested it to see if it exhibits the same issue or not). Is this the expected behaviour? Well, the documentation (KVC Programming Guide, Accessor Search Implementation Details) says that the pattern for setValue:forKey: • The receiver’s class is searched for an accessor method whose name matches the pattern -setKey:. So the question is what does 'searched' mean? Since that document talks about method names that match certain patterns, I'm guessing that it walks the method table (instead of calling respondsToSelector:). I'd just override valueForKey: and setValue:forKey: in your class to handle forwarding those to your wrapped object. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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 views in navigationbar (iOS 3.2)
On Jun 23, 2010, at 5:51 AM, Christian Ziegler wrote: Hi guys, I'm having a hard time with the navigation bar. What I'm trying to do is adding a custom breadcrumbs navigation to the bar. I coded two classes, a subclass of UIButton for the breadcrumbs segments and a sublcass of UIView for the whole bar. The bar has a home segment which represents the rootViewController of the navigationController and you can add additional segments when you push new viewControllers on to the navigationController's stack. You do realize that the HIG explicitly says to not do that? From http://developer.apple.com/iphone/library/documentation/userexperience/conceptual/mobilehig/SpecialViews/SpecialViews.html#//apple_ref/doc/uid/TP40006556-CH10-SW21 Using a multi-segment back button causes several problems: • The extended width of a multi-segment back button does not leave room for the title of the current screen. • There is no way to indicate the selected state of an individual segment. • The more segments there are, the smaller the hit region for each one, which makes it difficult for users to tap a specific one. • Choosing which levels to display as users navigate deeper in the hierarchy is problematic. If you think users might get lost without a multi-segment back button that displays a type of breadcrumb path, it probably means that users must go too deeply into the information hierarchy to find what they need. To address this, you should flatten your information hierarchy. So once you spend hours and hours coding and getting this working perfectly, it will probably end up being rejected by the AppStore approval process. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iPhone] Preprocessing events sent to UITableView
On Saturday, June 05, 2010, at 05:51PM, WT jrca...@gmail.com wrote: I need to hijack the set of touch events sent to a UITableView instance prior to allowing the table to process those events. I have a custom UIView, of which the table view is a subview, and I override -hitTest:withEvent: there (in the custom view) to return self, thereby preventing the table from receiving those touches. Since my custom view does not implement any of the four event-handling methods (-touchesBegan:withEvent:, etc), the view controller managing my custom view gets the touches, through the regular traversal of the responder chain. There, in the view controller event-handling methods, I determine whether or not I need to consume the events. If not, I need to send them back to the table view for it to do its normal event handling (for instance, scrolling). All of the above works fine, except... Probably not as fine as you expect - UIViews are not designed to support UIEvents forwarded to them except under very controlled conditions. From http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/EventHandling/EventHandling.html#//apple_ref/doc/uid/TP40007072-CH9-SW17: The classes of the UIKit framework are not designed to receive touches that are not bound to them; in programmatic terms, this means that the view property of the UITouch object must hold a reference to the framework object in order for the touch to be handled. If you want to conditionally forward touches to other responders in your application, all of these responders should be instances of your own subclasses of UIView. That document contains a number of suggestions on how to approach those sort of design issues... ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to specify the superview in the Interface Builder?
On Jun 4, 2010, at 11:53 AM, ico wrote: Hi all, I have created a custom view in the Interface Builder, how can I specify the superview for this custom view? For example, I want to make its superview be UIWindow rather than another custom view. Then drag a UIWindow from the library and put your view inside that. Note, however, that you probably don't want to be doing that in general (except for the main nib). From the UIWindow documentation: Although iPhone OS supports layering windows on top of each other, your application should never create more than one window. The system itself uses additional windows to display the system status bar, important alerts, and other types of messages on top of your application’s windows. If you want to display alerts on top of your content, use the alert views provided by UIKit rather than creating additional windows. So if your design requires a view living in anything other than the main window, you should probably redesign it (or be prepared for lots of debugging and testing, since the way multiple UIWindows work varies between OS release, and possibility of rejection from the AppStore when you submit it) Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: CFAttributedString and NSDATA
On Jun 3, 2010, at 12:08 PM, Chaitanya Pandit wrote: Yeah NSAttributedString is available in 3.2, but what would have been more helpful would be having the AppKit additions of NSAttributedStrings. The CFAttributedString and the NSAtttibutedString in 3.2 looks kinda half hearted effort without the AppKitAdditions AppKitAdditions require AppKit - they are specifically tied to AppKit graphics models and data structures, none of which exist on the iPhone. Nor, for that matter do any of the sophisticated AppKit based text rendering mechanisms that use the various things in AppKitAdditions. If you have specific things in mind that you need, you should file an enhancement request at bugreporter.apple.com. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Regarding MVC design pattern
On May 20, 2010, at 9:47 AM, Thomas Davie wrote: On 20 May 2010, at 15:45, Barry Skidmore wrote: If you need to have it set you should create an initWithOptionName: and call that from your standard init, or return an error stating a missing value is needed. Your init should always call down tithe most specific init. Specific examples of this are available as best practice in several cocoa and design pattern books. I think you've misunderstood what I was asking. If I use a setter (in the most specific init), then I don't need to recode (even the most specific init) if I change how the property is implemented. If I don't use the setter, I do. What I was asking was why you would want to avoid using setters in the init method... Is there some safety issue I've missed? The problem is that if you later subclass that object and override the setter in the subclass, this means that code in the subclass (the setter) is run before the subclasses init has run. This may be a problem if the subclass setter assumes that various other values in the subclass are properly initialized. So: @interface ClassA : NSObject { AnObject *ivar; } @property (nonatomic, retain) AnObject *ivar; @end // A subclass of ClassA that add some sort of logging/transcript @interface ClassB : ClassA @property (nonatomic, readonly) id uniqueId; @end @implementation ClassA @synthesize ivar; - (id) init { self = [super init]; if (self) { self.ivar = some value; // (1) } return self; } @end @interface ClassB - (id) init { self = [super init]; // (2) if (self) { self.uniqueId = [UniqueId uniqueId]; // (4) in keeping with the bad style, we call our setter here as well } return self; } - (void) setIvar: (AnObject *) obj { [[Transcript currentTranscript] setProperty: @ivar ofObject: self.uniqueId toValue: obj ]; // (3) [super setIvar: obj]; } @end So when you do: [[ClassA alloc] init]; everything is fine, but [[ClassB alloc] init]; when it gets to (2), calls the super init and at (1) ends up calling code at (3). But self.uniqueId will be nil (since the code at (4) hasn't been reached yet), and the -[Transcript setProperty:ofObject:toValue:] may not be able to deal with nil as the object parameter. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: NSCalendar date calculation anomaly
On Apr 27, 2010, at 10:45 PM, Scott Ribe wrote: I have an int representing the number of days since 1/1/2001, and wish to get an NSDate representing that date in the system's local time zone: NSDateComponents *dc = [[[NSDateComponents alloc] init] autorelease]; [dc setDay: numdays]; NSDate * cd = [[NSCalendar currentCalendar] dateByAddingComponents: dc toDate: [NSDate dateWithString: @2001-01-01] options: 0]; NSLog( @date 1: %@, [cd description] ); [dc setDay: 0]; [dc setSecond: -[[NSTimeZone systemTimeZone] secondsFromGMTForDate: cd]]; cd = [[NSCalendar currentCalendar] dateByAddingComponents: dc toDate: cd options: 0]; NSLog( @date 2: %@, [cd description] ); If for example numdays is the number of days from 1/1/2001 to 5/4/2010, then the output is this: 2010-04-27 21:33:55.803 PedCard[95387:a0f] date 1: 2010-05-03 17:00:00 -0600 2010-04-27 21:33:55.804 PedCard[95387:a0f] date 2: 2010-05-03 23:00:00 -0600 And, BTW, my current time zone is MDT, so -0600 is not correct, it should be -0700. So what's going on? I would expect those dates to be: 2010-05-03 17:00:00 -0700 2010-05-04 00:00:00 -0700 MDT is -0600 so this is correct - MST is -0700. (stupid spring forward, fall back clock resetting...) I find that dealing with dates and time zones it's best to consider NSDate to be just a scalar value, with a separate time zone (and optional calendar) being the unit. It's up to the formatter used to display that (scalar) date in the desired unit. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Toll free bridge from NSAttributedString * to CFAttributedStringRef
On Apr 8, 2010, at 7:02 AM, vincent habchi wrote: Hi there, I've been fiddling with NSAttributedString lately, and the way to display them through Core Text. In the docs, I've read that NSAttributedString and CFAttributedStringRef were supposed to be toll free bridged; I assumed that meant that one could be used in lieu of the other with (or maybe even without) a simple cast. But I found this is not true. Specifically, I was getting strange errors like CFSet[Stroke|Fill]ColorFromColor : invalid context 0x0 each time I printed my NSAttributedString by CTLineDraw(), although I had a perfectly valid context. The glyph were drawn, but always in black, while I was attempting to get another color via the NSForegroundColorAttributeName. At the end, I had to replace the pair (NSColor, NSForeground…) by a (CGColorRef, kCTForeground…), and now it works. Is that supposed to be a normal behavior, did I misunderstand the meaning of toll free, or is it a bug? NSAttributedString and CFAttributedStringRef the data structure are toll free bridged, but that just means that the objects themselves can be interchanged. The problem is that, like an NSDictionary, they can store arbitrary objects that may not be toll free bridged - in this case, NSColor and CGColorRef are not interchangeable, nor are the keys NSForegroundColor and kCTForegroundColorAttributeName documented as the same. So CTLineDraw expects to have the color specified as a CGColorRef in kCTForegroundColorAttributeName, while drawString: expects to have the color specified as an NSColor in NSForegroundColor. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: [NSMutableArray array]
On Apr 8, 2010, at 12:29 PM, Bill Bumgarner wrote: On Apr 8, 2010, at 10:21 AM, Patrick M. Rutkowski wrote: Agreed, but there's always the danger the +array method, which might actually be implemented in NSArray.m, will not properly initialize the more specific NSMutableArray object. Of course, in this specific case that's the case, but it might be the case with other class hierarchies. But, nonetheless I'm troubled that nobody in this thread has acknowledged that yet :-o Because, in practice, that doesn't generally happen. Across the system supplied frameworks, classes generally have designated initializers and those initializers are inherited properly. The convenience creation methods -- factory methods, if you will -- are dead simple stupid, generally doing the equivalent of '[[[self alloc] init*] autorelease]' where the init part calls the designated initializer. There is a problem with things that look like convenience creation methods but aren't - most notably +[NSParagraphStyle defaultParagraphStyle]. You might expect: NSMutableParagraphStyle *ps = [NSMutableParagraphStyle defaultParagraphStyle]; [ps setAlignment: NSCenterTextAlignement]; to work. It doesn't (since ps is actually an immutable NSParagraphStyle). The major clue that is isn't a convenience creation method being found in the declaration: - (NSParagraphStyle *) defaultParagraphStyle; instead of: - (id) defaultParagraphStyle; Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Wondering about that iPad page curling
That relies on undocumented private APIs, which is both off topic for this list, and, more importantly, grounds for getting your app rejected when submitted to the AppStore. On Apr 6, 2010, at 2:00 PM, Gleb Dolgich wrote: http://blog.steventroughtonsmith.com/2010/02/apples-ibooks-dynamic-page-curl.html -- Gleb Dolgich http://pixelespressoapps.com On 6 Apr 2010, at 16:56, Laurent Daudelin wrote: So, no other response from the regular crowd of resident experts on how Apple engineers did this? Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: ImageIO on iPhone
On Feb 16, 2010, at 6:55 AM, sebi wrote: Hello, I want to use ImageIO on the iPhone. However, the ApplicationServices framework does not show up in the list, when i do the Add - Existing Framework command. That's because ImageIO doesn't exist on the iPhone. When i just add the line #import ApplicationServices/ApplicationServices.h There is no ApplicationServices framework on the iPhone. I get some errors like 'CFXMLTreeRef' has not been declared (full list below). I added the CoreFoundation framework (where CFXMLTreeRef is defined), but no success. I want to use ImageIO from C++, that should be possible, shouldn't it? Not on the iPhone - file an enhancement request... Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: NSXML and gt;
The XML spec does not require '' to be escaped as 'gt;' (except in the case of ']]' when that doesn't mark the end of a cdata section). Only '' and '' must be escaped - see section 2.4 of XML 1.0 spec. Sent from my iPhone On Feb 9, 2010, at 2:19 PM, Keith Blount keithblo...@yahoo.com wrote: Hello, I'm using the NSXML classes to write out various strings, and it seems that these classes convert to lt; but not to gt;, which I find odd. For instance, consider the following code snippet: NSXMLElement*element = [[[NSXMLElementalloc] initWithName:@TeststringValue:@ ] autorelease]; NSLog (@%@, element); The output is: Testlt; amp; /Test Is this correct, or is this a bug? Or am I missing something? Do I therefore need to replace all occurrences of with gt; myself to generate better XML? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Displaying animated content in iPhone app
On Jan 28, 2010, at 8:22 AM, patrick machielse wrote: I'm working on an iPhone application and I need some advice on displaying animated content (think: cartoon like movies). Hopefully someone can point me in the right direction. Goal The application needs to display short 2 second 'clips' of animated characters in a loop. Animation can be triggered by tapping the screen. So, what are the current options for displaying movie like content in your app and have a decent control over playback and display? For simple flipbook style animation, you can load up all the frames as an array of UIImages and then use a UIImageView's animationImages to display them. Doesn't give you a whole lot of control (you basically get to set the frame rate, number of times to loop and the frames) but this approach works reasonable for handling things like animated GIFs (provided that you write the code to decode the GIF files into the frames you need). Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: iPhone: CATransition done (get the key?)
On Jan 13, 2010, at 11:18 AM, Eric E. Dolecki wrote: Is there a way to do it without retaining a reference? I could do that, but what is that key used for if not for referencing later somehow? The key is used by the layer, not the animation. Animations are just generic generators that take a time value and create a value - it's up to the layer to decide what to do with that value. You can always use CALayer's animationForKey: to find out if it the animation for a specific key: if ([theLayer animationForKey:@fadeIn] == theAnimation) { } Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! Mad, Bad, and Dangerous to Know ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Snapshotting hidden UIViews
On Jan 13, 2010, at 4:48 PM, Michael Gardner wrote: I also tried calling -drawRect: on my hidden view (after setting the context with UIGraphicsBeginImageContext()), but it doesn't seem to do anything. Many built in views do not draw anything at all (and have no useful drawRect:) - all of their rendering is handled by the view's layer. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Snapshotting hidden UIViews
On Jan 13, 2010, at 9:46 PM, Michael Gardner gardne...@gmail.com wrote: On Jan 13, 2010, at 5:07 PM, glenn andreas wrote: On Jan 13, 2010, at 4:48 PM, Michael Gardner wrote: I also tried calling -drawRect: on my hidden view (after setting the context with UIGraphicsBeginImageContext()), but it doesn't seem to do anything. Many built in views do not draw anything at all (and have no useful drawRect:) - all of their rendering is handled by the view's layer. Ah, that explains that. But I'd still very much like to know why the layer's -renderInContext: doesn't work consistently when the view is hidden. Pure speculation, but a hidden view may not have a layer associated with it, and things like subview layout aren't done for hidden views (why waste cycle laying out the subviews if nobody will see it?). There are probably other undocumented optimizations as well on hidden views, such as animations not running, pending refreshes postponed, etc... UIWebView is going to be especially problematic, since it does a whole lot of things in the background (such as loading needed images and other resources) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: NSDate without time portion
On Jan 5, 2010, at 1:48 PM, Karolis Ramanauskas wrote: By formatting the dates as MMDD and keeping them in strings you can use simple string comparison to sort, compare and filter. They are also very easy to format for display purposes. If you want to go standard then use the ISO 8601 date format. It's -MM-DD. See http://www.iso.org/iso/date_and_time_format Great, but do not forget, in this case, to store time zone information too, perhaps in a separate string. Time offset won't do because it may change for the same time zone depending on daylight savings time. If I store date as a string, I also store the associated time zone's name property. NSDate is more than a plain date. It has time zone info embedded. No it doesn't. NSCalendarDate has a timezone, NSDate does not. Just try printing the same date object on daylight savings time date and not, and you will see the date object automatically adjusts the time. So, hypothetically if you stored 2009-12-31 as a string. Then created NSDate object from that string. It may later be interpreted as 2009-12-31 00:00:00 or, let's say 2009-12-30 23:00:00 or 2009-12-31 05:00:00, if the time zone of your user computer changes. Think, what if you user saves an appointment at 12:00:00 in New York and you store it as a string with no time zone info? In Chicago, that appointment will appear at 12:00:00 also even though it is really happening at 11:00:00. NSDate conceptually store time relative to Jan 1, 2001, GMT. When it is formatted for display, it uses the current time zone (or more correctly, the NSDateFormatter uses whatever time zone has been specified, or the current system time zone). If your time zone changes (such as by daylight savings time, or changing the location), the resulting date will print differently, but timeIntervalSinceReferenceDate will be unchanged. It is ultimately the date formatter that handles time zones, daylight savings time, etc... Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! Mad, Bad, and Dangerous to Know ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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 a method name?
On Dec 22, 2009, at 12:58 PM, Matt Neuburg wrote: On Tue, 22 Dec 2009 09:56:33 +1100, Graham Cox graham@bigpond.com said: Regarding the use of different completion methods based on manipulating some common root name, I think that's a bit strange, misguided even. But when the kind of situation that calls for it arises, it might seem very natural and elegant. I'm just suggesting that we not condemn an architecture out of hand merely because we've no experience of it. m. And isn't even that uncommon - consider all the various kvc methods based on common name (as an example of manipulating a common root name for multiple purposes). And I've written menu validation code that manipulates the selector to figure out the name of the method to actually handle the validation (which is more of the completion method style thing - dynamically figure out what to call based on the SEL passed in)... Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! Mad, Bad, and Dangerous to Know ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Autorotation for a subview
On Dec 22, 2009, at 1:01 PM, Matt Neuburg wrote: On Tue, 22 Dec 2009 12:51:35 -0500, Eric E. Dolecki edole...@gmail.com said: I have a view which controls it's UI when rotated. However, if there is a subView in place, it rotates and I'd like to control it's UI too. In my subView the willAnimateRotationToInterfaceOrientation doesn't get fired. I set up the shouldAutorotateToInterfaceOrientation. Does my main view need to call something in my subView to get this to work? I'd think the subView would get the event too but it doesn't. This sounds like a good time for the view to post an NSNotification. The subview can then respond to it. m. Or just mark the subview as needing layout and then have the subview figure things out in layoutSubviews. Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! Mad, Bad, and Dangerous to Know ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Intercepting events and touches in UIPickerView subclasses? (or, WTF is going in the UIPickerView's responder chain?)
On Dec 18, 2009, at 6:00 AM, Sam Krishna wrote: Hi all, So, I'm working on a client project where he wants to have ActionOne for flicks on the UIPickerView and ActionTwo for non-flick selections. When I subclass UIPIckerView, I explicitly follow the pattern of overriding one of the standard methods for doing this kind of thing, and has worked *very well* in the past: - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event Unfortunately, this method *never fires* in the UIPickerView's responder chain (I suspect it has something to do with the highly-animated nature of UIPickerView). The only methods I can get to fire to give me anything about CGPoint information are: - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event what's interesting about these two methods is that they don't have any UITouch history with them. Sooo they are *mostly useless* also. Like a number of built in classes, UIPickerView is composed of a number of subviews which actually do the interesting stuff (not unlike the way a UIButton has a UILabel and UIImageView to actually draw a button). As a result, it doesn't do anything, and overriding its touchesXXX methods doesn't do anything useful (since there's probably a scroll view like subview that's actually handling the events). I've considered applying a UIView on top of the Picker View to intercept the touches and make gesture determinations, since that works very well. But before I go down that road, I thought I'd ask the community what your thoughts are about solving this problem. Again, all I need is for touchesEnded:withEvent: to fire in the responder chain to get what I need. Putting a view on top of a built in view works well for doing things like adding things to the appearance of the object, but can be very problematic, since in order for your approach to work, you'll need to forward the events to the real UIPickerView, and forwarding events is extremely problematic. From the documentation (iPhone Application Programming Guide Event Handling Touch Events Handling Multi-Touch Events Forwarding Touch Events): Forwarding Touch Events Event forwarding is a technique used by some applications. You forward touch events by invoking the event-handling methods of another responder object. Although this can be an effective technique, you should use it with caution. The classes of the UIKit framework are not designed to receive touches that are not bound to them; in programmatic terms, this means that the view property of the UITouch object must hold a reference to the framework object in order for the touch to be handled. If you want to conditionally forward touches to other responders in your application, all of these responders should be instances of your own subclasses of UIView. So there are two solutions: 1) Roll your own UIPickerView implementation - surprisingly, not that difficult in many cases. Basically make a UIScrollView (or your own subclass so you can examine the touch events), put a bezel image on top of it, and have each row be a subview inside the scroll view. You'll need some work to handle things like reusing the row cells (since you probably don't want to create a scrolling view with hundreds of subviews). 2) Subclass UIApplication and override sendEvent: - this can get ugly from an architecture point of view (since you no longer have a nice little reusable view - you've got to do major surgery on the application itself), and sendEvent: does a whole lot of work that you'll want to be careful not to break. Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: NSNumber stringValue
On Saturday, December 12, 2009, at 11:32AM, Ben Haller bhcocoa...@sticksoftware.com wrote: You should not compare floating point numbers for equality in most cases. This is true of any language on any platform. Indeed, some floating-point numbers (such as the one represented by the integer 0x7fc0) will compare as not equal to themselves: I think what the OP really wanted to know (and I'm interested in the answer too) is whether going out to the stringValue and back to the doubleValue is guaranteed to yield a float that is bitwise identical to the original float, or whether there is drift in the least significant bit or two due to the changes in representation. Anyway, even if that's not the OP meant, that's what I'd like to ask. :- It is absolutely not guaranteed to work - see http://docs.sun.com/source/806-3568/ncg_goldberg.html#1251. To be able to convert base 2 (the binary representation) to base 10 (the textual representation) without a loss of precision is possible (since 2 is a factor of 10), though it potentially requires at least 17 digits (quick back of the envelope calculation of how many digits are in 1/2**24, given that a float has a 24 bit mantissa), and stringValue isn't documented as providing any specific number of digits of precision. Going the other way, 0.1 (base 10) isn't possible to be represented exactly as a floating point number. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Question about touchesBegan
On Dec 9, 2009, at 4:19 PM, Jack Carbaugh wrote: So in this case, would the SUBview want to send the SUPERview the touchesbegan event ? From the documentation (iPhone Application Programming Guide Event Handling Touch Events Handling Multi-Touch Events Forwarding Touch Events): Forwarding Touch Events Event forwarding is a technique used by some applications. You forward touch events by invoking the event-handling methods of another responder object. Although this can be an effective technique, you should use it with caution. The classes of the UIKit framework are not designed to receive touches that are not bound to them; in programmatic terms, this means that the view property of the UITouch object must hold a reference to the framework object in order for the touch to be handled. If you want to conditionally forward touches to other responders in your application, all of these responders should be instances of your own subclasses of UIView. It's definitely worth reading, and re-reading, those docs - all sorts of nice explanations of how touch handling is handled can be found there... Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! Mad, Bad, and Dangerous to Know ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Button width should accomodate localized string
On Nov 29, 2009, at 9:38 AM, Symadept wrote: Hi, How can I scale my button or Label to be able to accomodate the localized string? Any clues. Regards symadept That's the whole purpose of being able to localize the nib/xib... Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! Mad, Bad, and Dangerous to Know ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Specifying latest .mom resource. Was: NSMigratePersistentStoresAutomaticallyOption...
On Nov 24, 2009, at 12:55 AM, Jerry Krinock wrote: Sorry, I'm back with this problem. Although the code I posted worked perfectly in a Debug build, when I tested a Release build, the invocation of -mergedModelFromBundles: raised this exception : Can't merge models with two different entities named 'Ixternalizer_entity' Did you do a clean all before your build? If a file is removed/renamed in Xcode, the old file will continue to exist in the build until you do a clean - adding a new version results in leaving the old version there (rather than just replacing it with the appropriate migration information). Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Transparency Help
On Nov 23, 2009, at 10:12 AM, R T wrote: I have a litho image (black white pixels only) and I want to make all the white pixels transparent. I am using Quartz 2d to display the image and I have a Quartz composition containing a single .cikernel... Any ideas? Why not just draw it using one of the transfer modes like kCGBlendModeDarken or kCGBlendModeMultiply rather than generate multiple images, tweaking all their bits, custom kernels, etc... Both modes should cause black pixels to be drawn as black, and white pixels to not change the image at all... Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: first responder being clobbered
On Oct 26, 2009, at 10:55 PM, Michael Link wrote: I have a custom UITableViewController that uses a custom cell that displays a text field. I have this method added to the table view controller to set the text field as first responder - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; MLPropertyEditingTableViewCell* __cell = (MLPropertyEditingTableViewCell*)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]]; [__cell.textField becomeFirstResponder]; } What if you do it in viewDidAppear instead of viewWillAppear? Since the view technically isn't on screen yet (only that it will be), setting a first responder shouldn't be done then. Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! JSXObjC | the easy way to unite JavaScript and Objective C ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: UITextField in UITableView covered by keyboard
On Oct 24, 2009, at 4:31 PM, Henry McGilton (Boulevardier) wrote: On Oct 23, 2009, at 10:29 AM, Bob Barnes wrote: Hi all, I posted this a yesterday, but it never appeared on the list and it's not showing up in the web archive so I thought I'd retry. I have a UITableView that contains some cells with UITextField's embedded in them. When I touch the UITextField to begin editing the keyboard pops up and obscures the the text field. I've been looking at the UICatalog sample, which has a nearly identical setup and the UITextField scrolls up to make itself visible, but I've been unable to determine what it's doing to cause that. I've read suggestions on scrolling the UITexField rect, resizing the UITableView, etc., but UICatalog doesn't do any of that, yet still works. What am I missing? You may also have to consider the scenario where the Table View Cell that contains the UITextField is so close to the end of the Table View that it can not be scrolled up out of the way. In the case, you have to temporarily move the entire Table View upwards by adjusting its frame origin . . . Not at all - just set the content inset scroll bar inset appropriately (which is what UITableViewController does). Way more easy than messing with frames (not to mention works correct - moving the frame will result in the other end of the scrolling range not being reachable). Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! Mad, Bad, and Dangerous to Know ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Opening a NSSavePanel as a Sheet, and blocking like in [panel runModal]
On Oct 22, 2009, at 8:44 AM, Motti Shneor wrote: Thanks again. Regarding the Carbon Window problem, the FrontWindow() call was just an illustration. The WindowRef I'm supplying is of a visible (usually active and front) Document window. The problems are not even consistent, and will randomly occur. The desired behavior, though, will very rarely occur. (I'd say one in a hundred times). In short --- Are there any specific implications to opening a cocoa sheet over a carbon (document) window? Is there any specific setup I need to know about? What are the limitations of Cocoa NSWindow wrappers around Carbon windows? The problem is, my Plugin is written using cocoa, but runs within a Carbon application. I need to attach my NSOpen/NSSave panels onto a given application window, which is, of course, a Carbon window. I get this bogus behavior and even worse, both running with my Host application, and with simplistic test programs like the one below. There's one fundamental problem - sheets are designed to be document modal, not application modal, which requires support from the underlying application in order to work correctly. So a sheet is not support to block the app like runModal does, but to work in conjunction with document architecture. You're basically fighting the frameworks, and the frameworks always win... Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! Mad, Bad, and Dangerous to Know ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Displaying a view modally
On Oct 21, 2009, at 7:54 PM, Saurabh Sharan wrote: Check out SFHudView by Buzz Andersen ( http://github.com/ldandersen/scifihifi-iphone/blob/master/UI/SFHFHUDView.h ) Saurabh That code runs contrary to the documentation (iPhone Application Programming Guide, Windows and Views): Although iPhone OS supports layering windows on top of each other, your application should never create more than one window. The system itself uses additional windows to display the system status bar, important alerts, and other types of messages on top of your application’s windows. If you want to display alerts on top of your content, use the alert views provided by UIKit rather than creating additional windows. Ignoring this will result in inconsistent behavior between different OS releases. You're better off making a simple blocking view that consumes all the touch events (i.e., implements everything, but does nothing), give it a translucent gray background and make it the size of the window, and add it as a subview of the window, on top of everything else. Then add your modal content view on top of that blocking view. Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! quadrium2 | build, mutate, evolve, animate | images, textures, fractals, art ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Programming Style: Method Definition with or without a semicolon.
On Oct 16, 2009, at 2:55 AM, Bill Bumgarner wrote: On Oct 16, 2009, at 12:17 AM, Sander Stoks wrote: If it's a feature, then it's definitely a new one since the original specification of Objective-C. It turned out to be surprisingly hard to find that specification, but I found a grammar description here:http://www.cilinder.be/docs/next/NeXTStep/3.3/nd/ Concepts/ObjectiveC/B_Grammar/Grammar.htmld/index.html There it says: instance-method-definition: sp.gifc2D.gif [ method-type ] method-selector [ declaration- list ] compound-statement method-selector: sp.gifunary-selector sp.gifkeyword-selector [ , ... ] sp.gifkeyword-selector [ , parameter-type-list ] The declaration-list and compound-statement are not specified further and are taken from the C spec. In other words: There's no semicolon. On the other hand, the grammar spec has been removed from Apple's documentation, and I suppose the official line is now Objective-C is whatever we ship with Xcode. I haven't booted my NS 0.8 cube in about a decade, but I'm pretty sure the semi-colon was always required in the header file and always allowed in the @implementation. 'Twas many a moon ago, but, I do distinctly remember triple-clicking method declarations from headers (with semis) to copy-paste into my implementation without deleting the semi. It always stuck with me as an über-convenience. b.bum You can (or at least could) copy the entire @interface section from the .h, paste into the .m and change @interface to @implementation and it would compile. So yes, this is legal: @implementation MyObject : NSObjectSomeProtocol { id myIvar; } - (void) doSomething; @end Not that I'd recommend or even admit to doing this (I have no idea what happens if the @implementation class details are different from the @interface ones, and, again, not that I'd ever admit to having done this, it is easy to accidentally write your implementation in your .h file and leave the pasted @interface in your .m). Glenn Andreas gandr...@gandreas.com The most merciful thing in the world ... is the inability of the human mind to correlate all its contents - HPL ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Can I make custom pasteboard type for an object reference?
On Oct 16, 2009, at 3:51 PM, Sean McBride wrote: On 10/15/09 6:34 AM, Timothy Stafford Larkin said: I messed around with this problem for some time, before I gave up trying to be clever and cast the pointer as an unsigned long. NSNumber *p = [NSNumber numberWithUnsignedLong:(unsigned long) object]; The number can be added to a pasteboard. Or if dragging more than one object, NSNumbers can be added to an NSArray, and the array written to the pasteboard. That seems quite dangerous, especially in a GC app. Creating such an NSNumber will not keep a strong reference to object, and so it risks getting prematurely collected. If you do do this, better CFRetain the object first. And that isn't enough to help if you use some sort of pasteboard/ scrapbook manager to store the dragging pasteboard, quit the app, and later relaunch it and try to drag the archived pasteboard from you pasteboard manager app. Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! quadrium2 | build, mutate, evolve, animate | images, textures, fractals, art ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Opening a NSSavePanel as a Sheet, and blocking like in [panel runModal]
On Oct 14, 2009, at 8:02 AM, Motti Shneor wrote: Hello. I'm in a strange situation, where I am implementing a plugin component that runs within a host application which I don't have access to. Within this context, The host sometimes calls my plug-in to open an NSSavePanel (or NSOpenPanel). The host expects that I'm synchronous --- i.e. I only return when the NSSavePanel is dismissed, and there's a result. However, The host also provides me with its own Window, and I need to open my NSSavePanel as a Sheet-window over the host's window. You really can't - sheets are document modal (by design), not application modal - if a window has a sheet displayed, the user needs to still be able to switch to other documents within the application and do stuff. The description of the plugin model does not sound like it supports it, so you'd use an application modal document, not a sheet. So you can probably make it look right, but you won't be able to make it work right (from the point of view of the user). Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! Mad, Bad, and Dangerous to Know ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: UIGraphicsBeginImageContext thread safety
On Oct 1, 2009, at 6:41 AM, Andrew wrote: Hi All, So clearly the UIGraphicsBeginImageContext() set of calls are not thread safe, I was attempting to use them in an NSOperation and they are causing a crash, further research has shown me that I need to drop down into the CG calls to do what I want to do. .and presumably I could have been forewarned if I had looked at the 'UI' at the front of the function, and had read that as a Sign. I am, however, very interested...for my own curiosity...in why they are not? my mental image of that call had it simply wrapping the CGBitmapContextCreate() set of calls, and they are thread safe. what is it doing that renders it not thread safe, does anyone know? At the very least, it needs to call UIGraphicsPushContext to set the current ui graphics context, which is documented as needing to be done on the main thread (which implies that there is a single, global ui graphics context variable use by all of UIKit to indicate where all UIKit based drawing should go). Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! Mad, Bad, and Dangerous to Know ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Send POST data to browser
On Sep 17, 2009, at 12:14 PM, Jens Alfke wrote: On Sep 17, 2009, at 3:26 AM, Bartosz Białecki wrote: I can launch browser with url using this code: NSURL *url = [NSURL URLWithString: @https://www.example.com/index.php ]; [[UIApplication sharedApplication] openURL: url]; but I don't know how to send post data. You can't do it — the browser will only do a GET on URLs it's told to open. I tried also another solution: send post data from my application to website and then get a response, but then I don't know how to open returned page in browser. A successful POST will return one of two different things — (1) A redirect to another page. This is a typical HTTP redirect, with a status like 302, 303 or 307 and a Location: header that specifies where to go. In this case you just read the URL from the Location: header and pass that to the browser. (2) An actual page body to display, i.e. a 200 status and a bunch of HTML. This isn't so easy to handle, since you can't give the HTML itself to the browser. The only way you could display it is to open your own UIWebView (in which case it would probably be easier to just open it before the request and use it to send the POST...) If you own the website, then you can make sure that its login page does (1), which is the more correct thing to do anyway. There's no guarantee that (1) will work, since often this case also includes setting some sort of session cookie (which goes away when the app quits, which, of course, it does when Safari is launched). Even if it sets a persistent cookie, I don't believe that cookies are shared at all between your sand-boxed app and Mobile Safari. (2) is probably the safest bet unless it's for your own website and you can convert the CGI to support GET as well as POST. Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! Mad, Bad, and Dangerous to Know ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Best way to determine what ip address are assigned to a given network interface.
On Aug 27, 2009, at 9:21 AM, Sherm Pendley wrote: On Thu, Aug 27, 2009 at 10:09 AM, Mark McCraymarksmcc...@gmail.com wrote: I've seen a bunch of methods for getting a list of ip addresses that a machine may have. But i haven't seen a Cocoa way of figuring out what ip address is attached to a given interface. NSHost give's you IPs but which network interfaces those IPs are attached to. Can this be done with the SystemConfiguration Framework? Why do I need this? We know a bunch of our machines have many IPs but we only care about ethernet ip addresses. and we typically only care about ones that are en0 or en1. We want to write an application which will give this information to us easily without the user having to go into System Preferences. If you know which interface(s) you want info about, you could run /sbin/ifconfig en0 with NSTask. Or just use getifaddrs - no need to fork off an extra task and parse the output when you can just look at the information directly... Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! m.o.t.e.s. | minute object twisted environment simulation ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: UITableView updating problem
On Aug 12, 2009, at 9:15 PM, DKJ wrote: I've got a UITableView where the colour of the row text can change depending on its place in the table. For example, a row may change colour if it's moved from the bottom to the top of the table; and sometimes its colour may change if another row is deleted or inserted. The problem is that the text colour is not updated until the table reloads its data. So (e.g.) if I move a row from the bottom to the top, its colour doesn't change immediately. I'd like the text colours to be updated when the table leaves edit mode. But according to the docs, I can't call reloadData in the tableview controller's commitEditingStyle or moveRowAtIndexPath methods. (I tried doing it anyway, and got into trouble.) Is there any way I can get the table to update as soon as the user presses the Done button? Or even better, as soon as the row deletion or move is completed? You're using a sledge hammer (reloadData) when you need a small screwdriver. When you are told of the row moving, you can access the cell used to draw that row (cellForIndexPath:) and then just adjust the color accordingly. If you need to adjust other cells in that section, you can just loop through them, calling cellForIndexPath: for each one you want to adjust - if it is offscreen, it will return nil, so you can skip it. This is also a good way to handle things like having a check mark selection... (change the accessoryType of the selected row, go through and remove the check mark from the previous one). Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! quadrium2 | build, mutate, evolve, animate | images, textures, fractals, art ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: UITableView updating problem
On Aug 13, 2009, at 8:44 AM, Brian Slick wrote: On Aug 13, 2009, at 8:31 AM, glenn andreas wrote: You're using a sledge hammer (reloadData) when you need a small screwdriver. From UITableView.h: - (void)reloadData; // reloads everything from scratch. redisplays visible rows. -- because we only keep info about visible rows, this is cheap.-- will adjust offset if table shrinks Watch this year's WWDC session on UITableViews - that's where the sledgehammer comment actually comes from. reloadData is cheap, but it is still a sledgehammer approach (since it tears everything down and rebuilds everything). Tweaking a setting of an existing view is far more surgical. Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! Mad, Bad, and Dangerous to Know ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: NSURLCache
On Aug 10, 2009, at 1:38 PM, Mike Manzano wrote: Has anyone been able to successfully get the URL loading system on iPhone to pay attention to custom versions of NSURLCache? It seems to me that it's being ignored. More info here: http://stackoverflow.com/questions/1246420/need-content-in-uiwebview-to-display-quickly (See the second answer on that page). Just need some sort of clue if I'm doing something wrong or if my code's just being ignored. Yes, I've had it work - it just requires making your own cache instance and explicitly setting the shared cache to that new instance. But it absolutely did work - once implemented, my set the table view cell's image to an image from the net works nicely (and without it scrolling was painful at best). Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! Mad, Bad, and Dangerous to Know ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iPhone] Webview stringByEvaluatingJavaScriptFromString
On Aug 5, 2009, at 2:08 PM, Development wrote: I'm trying to get a value for a specific variable to tell if a transaction is complete on iphone. In the didFinishLoading delegate method I have placed this code: NSString * aString =[theWebView stringByEvaluatingJavaScriptFromString :@document.getElementsByName(\encrypted\).value]; NSLog(@AString: %@,aString); The string is empty. I get nothing although I clearly have a field variable named encrypted in the html source of the page it is loading, and that field has a value because I have assigned it the value Success! So I am concerned... What am I doing wrong? Set a break point in the debugger at that point. Use gdb to make sure that things are actually like you expect them to be, using a series of po commands calling [theWebView stringByEvaluatingJavaScriptFromString:] with various queries. Since stringByEvaluatingJavaScriptFromString doesn't do any attempt at stringification of objects (and will return an empty string instead something like [DOMElement]), you'll probably want to do it manually, such as: po [theWebView stringByEvaluatingJavaScriptFromString @'' + document.getElementByName('encrypted')] That will show you if there really is something there like you expect. Most likely, you're calling it at the wrong time, before the content has been fully loaded/rendered... Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! Mad, Bad, and Dangerous to Know ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: [iPhone] networking
On Aug 4, 2009, at 4:42 PM, Shawn Erickson wrote: On Tue, Aug 4, 2009 at 11:13 AM, Luke the Hiestermanluket...@apple.com wrote: On Aug 4, 2009, at 11:10 AM, James Lin wrote: Bonjour is for local area network, right? No, Bonjour is applicable to any networking, local or wide area. Here's some sample code. http://developer.apple.com/iphone/library/samplecode/BonjourWeb/index.html Well ad-hoc discovery only works on the local sub-net or across bridged sub-nets. To do service discovery across sub-nets would require a known DNS server publishing the existence of services and how to contact them via public IP addresses. Of course, in the context of the original question (re: iPhone networking), the iPhone is almost never going to have a public IP address (being hidden behind WiFi or cell phone NATs). Glenn Andreas gandr...@gandreas.com http://www.gandreas.com/ wicked fun! Mad, Bad, and Dangerous to Know ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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