MKAnnotation coordinate
Hi all, This is a quick and simple question - for some ridiculous reason I can't work out how it should be done properly and it couldn't be more frustrating. I'd be really grateful if someone could help me out. Ok so I am working with MKAnnotations on my map view and want to know the * correct* (i.e. the Apple intended) way to set up my custom annotation class so that I can set the coordinate upon initialisation but also access the coordinate attribute from outside the class e.g. in my case I wish to do something like: region.center = myAnnotation.coordinate; The above gives me an error and says the assignment is between incompatible types. I've done plenty of googling and have seen a few different solutions but none of which seemed to allow me to access the coordinate. Some people define a coordinate member variable and then @property/synthesize. Others named the member variable _coordinate and then *just* synthesized it (not @property) using @synthesize _coordinate = coordinate; - I don't fully understand what that means. Finally (in the case of the MapCallouts source) others have defined a function called coordinate that returns the coordinate. I believe the last option compiled but I get the error I mentioned above. If someone could give tell me the correct solution by means of a really simple example i.e. what should go in the .h and .m (I'm only interested in the coordinate attribute for now) and then how to correctly access the coordinate attribute from outside the class for assignment e.g. the center attribute of the region object (sorry I can't remember the exact name). Many thanks in advance, Dan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
sizeof a function
These lines: typedef char *(*my_type)(const char *, int); my_type some = index; fprintf(stderr,sizeof(index): %lu\n, sizeof(index)); fprintf(stderr,sizeof(some): %lu\n, sizeof(some)); produce: sizeof(index): 1 sizeof(some): 8 This is x86_64 so the pointer-size should be 8 bytes. But why is the size of index = 1? Kind regards, Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextFieldCell multi-line
Thanks for your respons, but I need the exacte size in points, which means drawing with the right Font etc. So here's where I am in - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row I'm calling a function which calculates the height needed for the text and that's what I'm returning: -(float)heightForStringDrawing:(NSString*)theTextField withFont:(NSFont*)myFont forWidth:(float)myWidth{ NSTextStorage *textStorage = [[[NSTextStorage alloc] initWithString:theTextField] autorelease]; NSTextContainer *textContainer = [[[NSTextContainer alloc] initWithContainerSize: NSMakeSize(myWidth, FLT_MAX)] autorelease]; NSLayoutManager *layoutManager = [[[NSLayoutManager alloc] init] autorelease]; [layoutManager addTextContainer:textContainer]; [textStorage addLayoutManager:layoutManager]; [textStorage addAttribute:NSFontAttributeName value:myFont range:NSMakeRange(0,[textStorage length])]; [textContainer setLineFragmentPadding:0.0]; [layoutManager glyphRangeForTextContainer:textContainer]; return [layoutManager usedRectForTextContainer:textContainer].size.height; } BUT, I'm getting row clippings, and the strange thing if as soon as I'm clicking on any cell, everything comes back to good order. Any help appreciated, Michael On 8 nov. 2010, at 20:32, jonat...@mugginsoft.com wrote: On 8 Nov 2010, at 08:55, Micha Fuhrmann wrote: Dear All, I'm stuck here and it seems so trivial... I'm using NSTextFieldCell in a tableview and when the text takes the whole cell, the cell size doesn't resize and add a line (which I would expect!!!). Setting the text properties in NSCell doesn't cut it either. So I've tried using - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row { But how can I compute the amount screen pixels my NSString that's going into the cell will take to return a height with the proper number of lines? I must be missing something, it's just too silly. Any help appreciated. Michael For cell text wrapping behaviour see the NSCell documentation: -setLineBreakMode, -setWraps, -setTruncatesLastVisibleLine: To get the required size try NSString -sizeWithAttributes: Regards Jonathan Mitchell Developer Mugginsoft LLP http://www.mugginsoft.com This email sent to jonat...@mugginsoft.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/michaf%40mac.com This email sent to mic...@mac.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: sizeof a function
On Mon, Nov 8, 2010 at 9:06 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: typedef char *(*my_type)(const char *, int); my_type some = index; fprintf(stderr,sizeof(index): %lu\n, sizeof(index)); fprintf(stderr,sizeof(some): %lu\n, sizeof(some)); 1. This is not a Cocoa question. 2. sizeof of an expression of function type is illegal according to constraint 1 of section 6.5.3.4 of C99: http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Populating NSPopUpbuttonCell in document-based Core Data App
Hi, In my app I have a data model with an entity called SpeakersIn with an string attribute called talkTitles. What I would like to have is a predefined item list in the table column hosting the NSPopUpButtonCell when adding a new row in the tableview. I'm thinking that I need to add the code in the - (void)awakeFromInsert method. But how do I do that? --Philip ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Calling getter on const object
I now think that what I am seeing is a minor parsing sort of issue within the compiler (gcc 4.2) when mixing idSomeProtocol with blocks. The more fundamental problem is that gcc C++ does not fully support blocks, period. Indeed, as soon as it gets a sniff of c++ near a block things start to go badly wrong, but I would have hoped that pure objC compiled with a c++ compiler would pass - and especially pure objC in a .m file (which also leads to a different error). Oh well, I'll add another blocks-related bug report. I find blocks to be an endless source of bleeding-edge torment, but I like them too much to give them up! For what it's worth, my bug has been closed with the comment Please upgrade to the LLVM Compiler when Xcode 4 is released. Hopefully it won't be too long now, and if all the blocks business is sorted that will make me very happy!___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
PDF and iPad
on some PDF files, when I call CGPDFDocumentGetPage I get the following console output: invalid page tree entry. invalid `Kids' array: missing or invalid dictionary at index 5. Is there a way to keep this from happening, or at least detect the PDF is going to cause this in the code, before it happens? I also get: Error: FT_Open_Face failed: error 2. for some files as well when I call CGContextDrawPDFPage on some PDF files. Once again, is there a way to pre-flight the PDFs to determine if they are going to fail? * Richard Collyer iseecol...@sbcglobal.net * ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: MKAnnotation coordinate
On 9 Nov 2010, at 3:31 AM, Dan Hopwood wrote: Ok so I am working with MKAnnotations on my map view and want to know the * correct* (i.e. the Apple intended) way to set up my custom annotation class so that I can set the coordinate upon initialisation but also access the coordinate attribute from outside the class e.g. in my case I wish to do something like: region.center = myAnnotation.coordinate; The above gives me an error and says the assignment is between incompatible types. We need something better than something like. Assuming region is an MKCoordinateRegion, and myAnnotation implements MKAnnotation, the above line is okay. But if region is your shorthand for someMapView.region, you have a problem. Show us the code. I've done plenty of googling and have seen a few different solutions but none of which seemed to allow me to access the coordinate. Some people define a coordinate member variable and then @property/synthesize. Others named the member variable _coordinate and then *just* synthesized it (not @property) using @synthesize _coordinate = coordinate; - I don't fully understand what that means. Finally (in the case of the MapCallouts source) others have defined a function called coordinate that returns the coordinate. MKAnnotation already declares @property coordinate, so there is no reason to re-declare it. A -coordinate method, or a @synthesize if there is a coordinate instance variable to back it, is enough. If someone could give tell me the correct solution by means of a really simple example i.e. what should go in the .h and .m (I'm only interested in the coordinate attribute for now) and then how to correctly access the coordinate attribute from outside the class for assignment e.g. the center attribute of the region object (sorry I can't remember the exact name). Don't do this by Braille from what I can tell you off the top of my head, or from cookbook examples. Read and understand for yourself the documentation on properties at http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocProperties.html. — F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: MKAnnotation coordinate
Thanks Fritz, a resource like that was what I was looking for - where I can I will always read Apple's documentation over examples/tutorials since they are often wrong or inaccurate. I will have a read tonight and see how I get on. Sorry I wasn't more specific, I couldn't remember the name of the type - in the example I gave, region is indeed of type MKCoordinateRegion and myAnnotation extends NSObject and implements the MKAnnotation protocol i.e. @interface myAnnotation : NSObjectMKAnnotation From your comments I already understand it better - I thought the instance variable was also declared, not just the property. Therefore I will declare coordinate in the header, I won't declare a property and I will synthesize in the implementation. -Dan On 9 November 2010 15:18, Fritz Anderson fri...@manoverboard.org wrote: On 9 Nov 2010, at 3:31 AM, Dan Hopwood wrote: Ok so I am working with MKAnnotations on my map view and want to know the * correct* (i.e. the Apple intended) way to set up my custom annotation class so that I can set the coordinate upon initialisation but also access the coordinate attribute from outside the class e.g. in my case I wish to do something like: region.center = myAnnotation.coordinate; The above gives me an error and says the assignment is between incompatible types. We need something better than something like. Assuming region is an MKCoordinateRegion, and myAnnotation implements MKAnnotation, the above line is okay. But if region is your shorthand for someMapView.region, you have a problem. Show us the code. I've done plenty of googling and have seen a few different solutions but none of which seemed to allow me to access the coordinate. Some people define a coordinate member variable and then @property/synthesize. Others named the member variable _coordinate and then *just* synthesized it (not @property) using @synthesize _coordinate = coordinate; - I don't fully understand what that means. Finally (in the case of the MapCallouts source) others have defined a function called coordinate that returns the coordinate. MKAnnotation already declares @property coordinate, so there is no reason to re-declare it. A -coordinate method, or a @synthesize if there is a coordinate instance variable to back it, is enough. If someone could give tell me the correct solution by means of a really simple example i.e. what should go in the .h and .m (I'm only interested in the coordinate attribute for now) and then how to correctly access the coordinate attribute from outside the class for assignment e.g. the center attribute of the region object (sorry I can't remember the exact name). Don't do this by Braille from what I can tell you off the top of my head, or from cookbook examples. Read and understand for yourself the documentation on properties at http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocProperties.html . — F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: PDF and iPad
I would recommend you Report Bugs for both of these issues. Assuming the PDF is valid, you shouldn't need to preflight them and they shouldn't cause issues. Please attach the PDF in question to whatever bugs you file. On Nov 9, 2010, at 6:54 AM, colors wrote: on some PDF files, when I call CGPDFDocumentGetPage I get the following console output: invalid page tree entry. invalid `Kids' array: missing or invalid dictionary at index 5. Is there a way to keep this from happening, or at least detect the PDF is going to cause this in the code, before it happens? I also get: Error: FT_Open_Face failed: error 2. for some files as well when I call CGContextDrawPDFPage on some PDF files. Once again, is there a way to pre-flight the PDFs to determine if they are going to fail? -- 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/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Calling getter on const object
On Tue, 9 Nov 2010 12:08:57 +, Jonny Taylor said: For what it's worth, my bug has been closed with the comment Please upgrade to the LLVM Compiler when Xcode 4 is released. Hopefully it won't be too long now, and if all the blocks business is sorted that will make me very happy! You can build and use clang yourself now: http://shapeof.com/archives/2010/01/using_the_latest_llvm_with_xcode.html -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Apply animation curve to nswindow position?
Is this even possible? It appears from the documentation that you can only apply an NSViewAnimation to an NSWindow. I'd like to apply a CABasicAnimation to animate a window's movement. Any suggestions? Michael ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: Apply animation curve to nswindow position?
On Nov 9, 2010, at 11:57 AM, Michael Hanna wrote: Is this even possible? It appears from the documentation that you can only apply an NSViewAnimation to an NSWindow. I'd like to apply a CABasicAnimation to animate a window's movement. Any suggestions? Is there some reason why the -setFrame:display:animate: method would not work here? If so, then what are you trying to accomplish? Nick Zitzmann http://www.chronosnet.com/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
using NSURLConnection to download NSArray
Hello, I'm using a simple NSArray stored on a web server as part of a version tracking system. First I download the array using arrayWithContentsOfURL: and check the version etc. The problem with this approach is that if the server is down the method appears to hang indefinitely. So I thought I'd use NSURLConnection to download the array and set a timeout value. Everything seems to be working but how can I turn the NSData* object(s) back into an NSArray that I can access as normal? Thanks, Stephen ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: Apply animation curve to nswindow position?
On Tue, 9 Nov 2010 13:57:51 -0500, Michael Hanna said: Is this even possible? It appears from the documentation that you can only apply an NSViewAnimation to an NSWindow. I'd like to apply a CABasicAnimation to animate a window's movement. Any suggestions? I don't think there's anything more than -setFrame:display:animate:, as Nick said. Carbon lets you do fancier animations, like the Genie effect (see TransitionWindow()), but those features never made it to Cocoa. -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: using NSURLConnection to download NSArray
On Nov 9, 2010, at 12:26 PM, Stephen Blinkhorn wrote: I'm using a simple NSArray stored on a web server as part of a version tracking system. First I download the array using arrayWithContentsOfURL: and check the version etc. The problem with this approach is that if the server is down the method appears to hang indefinitely. So I thought I'd use NSURLConnection to download the array and set a timeout value. Everything seems to be working but how can I turn the NSData* object(s) back into an NSArray that I can access as normal? If the data is in property list format, then you turn it into an array using the NSPropertyListSerialization class. See its documentation for details. Nick Zitzmann http://www.chronosnet.com/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: using NSURLConnection to download NSArray
On 9 Nov 2010, at 13:32, Nick Zitzmann wrote: On Nov 9, 2010, at 12:26 PM, Stephen Blinkhorn wrote: I'm using a simple NSArray stored on a web server as part of a version tracking system. First I download the array using arrayWithContentsOfURL: and check the version etc. The problem with this approach is that if the server is down the method appears to hang indefinitely. So I thought I'd use NSURLConnection to download the array and set a timeout value. Everything seems to be working but how can I turn the NSData* object(s) back into an NSArray that I can access as normal? If the data is in property list format, then you turn it into an array using the NSPropertyListSerialization class. See its documentation for details. Excellent, that works! Thanks Nick. Nick Zitzmann http://www.chronosnet.com/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTextFieldCell multi-line
On Nov 9, 2010, at 4:45 AM, Micha Fuhrmann wrote: Thanks for your respons, but I need the exacte size in points, which means drawing with the right Font etc. So here's where I am in - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row I'm calling a function which calculates the height needed for the text and that's what I'm returning: -(float)heightForStringDrawing:(NSString*)theTextField withFont:(NSFont*)myFont forWidth:(float)myWidth{ NSTextStorage *textStorage = [[[NSTextStorage alloc] initWithString:theTextField] autorelease]; NSTextContainer *textContainer = [[[NSTextContainer alloc] initWithContainerSize: NSMakeSize(myWidth, FLT_MAX)] autorelease]; NSLayoutManager *layoutManager = [[[NSLayoutManager alloc] init] autorelease]; [layoutManager addTextContainer:textContainer]; [textStorage addLayoutManager:layoutManager]; [textStorage addAttribute:NSFontAttributeName value:myFont range:NSMakeRange(0,[textStorage length])]; [textContainer setLineFragmentPadding:0.0]; [layoutManager glyphRangeForTextContainer:textContainer]; return [layoutManager usedRectForTextContainer:textContainer].size.height; } BUT, I'm getting row clippings, and the strange thing if as soon as I'm clicking on any cell, everything comes back to good order. Are you saying that the height returned from your method differs from the actual height used by the NSTextFieldCell? If so, you might need to adjust the typesetterBehavior setting. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: Apply animation curve to nswindow position?
Yes, -setFrame:display:animate would do the job but I think it'd be neat to have finer control over the duration. I would like to make a bunch of borderless windows that each contain a cloud graphic. So they would float by at different rates across the screen. I guess this sortof a silly idea now that I've typed it out. :) Michael On Tue, Nov 9, 2010 at 2:15 PM, Nick Zitzmann n...@chronosnet.com wrote: On Nov 9, 2010, at 11:57 AM, Michael Hanna wrote: Is this even possible? It appears from the documentation that you can only apply an NSViewAnimation to an NSWindow. I'd like to apply a CABasicAnimation to animate a window's movement. Any suggestions? Is there some reason why the -setFrame:display:animate: method would not work here? If so, then what are you trying to accomplish? Nick Zitzmann http://www.chronosnet.com/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Apply animation curve to nswindow position?
On Nov 9, 2010, at 2:41 PM, Michael Hanna wrote: Yes, -setFrame:display:animate would do the job but I think it'd be neat to have finer control over the duration. If you subclass NSWindow and override -animationResizeTime:, you can make the duration take any time you want. Nick Zitzmann http://www.chronosnet.com/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: sizeof a function
On Nov 9, 2010, at 2:07 AM, Kyle Sluder wrote: On Mon, Nov 8, 2010 at 9:06 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: typedef char *(*my_type)(const char *, int); my_type some = index; fprintf(stderr,sizeof(index): %lu\n, sizeof(index)); fprintf(stderr,sizeof(some): %lu\n, sizeof(some)); 1. This is not a Cocoa question. 2. sizeof of an expression of function type is illegal according to constraint 1 of section 6.5.3.4 of C99: http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf sizeof an expression of pointer-to-function-type is legal, however. Values of function type are usually automatically converted to pointer-to-function-type, but sizeof is one of the exceptions (6.3.2.1). This will print the value you expect: fprintf(stderr,sizeof(index): %zu\n, sizeof(index)); -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Calling getter on const object
I'm new at this too, so perhaps I am completely off here. My guess is that it isn't the const that is messing this up, but the non-class type. The problem I see is that frame is a pointer to an objc_object and objc_objects aren't the same as NSObjects (but, like I said, I'm new, so maybe they are interchangeable here). Does it work if you try declaring frame as a NSObjectFrameProtocol instead of an idFrameProtocol? Aaron On Nov 8, 2010, at 8:37 AM, Jonny Taylor wrote: I'm afraid I'm not sure if I understand exactly what you're asking. I would like to be able access the frame number property (which is in fact stored as a variable within the class, and is fixed soon after instantiation) in spite of the fact that I only have a 'const' pointer to the object at the time I want to access it. Semantically I don't see why it should be unsafe to attempt to find out the value of that property. Either way, hopefully the actual code helps to answer your question: -(void)analyzeFrameAsync:(idFrameProtocol)frame { int num = frame.frameNumber;// Temporary variable avoid problems with calling method on 'frame' [const] from block dispatch_async(analysisSerialQueue, ^{ [analyzer processFrame:frame]; self.latestFrameNumberProcessed = num; // I can't call frame.frameNumber from within the block (compiler error) }); } On 8 Nov 2010, at 16:29, David Duncan wrote: It might be useful to know what you expect to get from the const reference in the first place? Primarily because I highly suspect that it is not necessary to ensure the semantics that you desire. On Nov 8, 2010, at 4:59 AM, Jonny Taylor wrote: I have encountered what I presume is a common newcomer's problem, but I haven't had any luck with google (maybe I'm using the wrong search terms?). Suppose I have a const id, e.g. const idFrameProtocol frame. If I attempt to call a getter for the object I get the following compiler error: request for member 'frameNumber' in 'frame', which is of non-class type 'objc_object* const' -- 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/eeyore%40monsterworks.com This email sent to eey...@monsterworks.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Catching errors with MPMoviePlayerController
Hi guys, Is there a way of catching exceptions (particularly for network errors / no connection available) when using a MPMoviePlayerController? I have reviewed the available documentation and realise I can get a notification for moviePlayerLoadStateChanged:(NSNotification*)notification. Problem is the loadState constants available don't cater for error handling: MPMovieLoadStateUnknown MPMovieLoadStatePlayable MPMovieLoadStatePlaythroughOK MPMovieLoadStateStalled (in case you are wondering this doesn't get called during network errors for some reason?) There's a deprecated MPMoviePlayerContentPreloadDidFinishNotification that provides a userInfo dictionary with an error key but nothing for iOS 3.2 and above. Any help would be very much appreciated. Cheers, Rog ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Issues in specifying the file extensions for NSOpenPanel
Hi All, In my application I need to choose only dmg files, so I am using NSOpenPanel with the following code snippet. But the NSOpenPanel is also allowing me to choose the folders having the extension '.dmg'. Ideally NSOpenPanel should allow me to choose only dmg files not folders ? Is this behavior as designed ? -- NSOpenPanel *op = [NSOpenPanel openPanel]; [op setCanChooseFiles:YES]; [op setCanChooseDirectories:NO]; NSInteger val = [op runModalForDirectory:@/ file:nil types:[NSArray arrayWithObject:@dmg]]; if( val == NSOKButton ) { NSArray *filesToOpen = [op filenames]; NSLog(@%@, filesToOpen ); } -- Please suggest the right way to disallow the folder selection in this case such that the open button remains disable for all the folders. Thanks, Sachin ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Pause during drawing
Hello, For studying purposes (on recursion), I build a simple NSView subclass capable of drawing a Sierpiński triangle. The class has 2 helper methods to draw triangles and the fractal itself. The former is quite simple, draws triangles given start point, height and width. The latter, also simple, is called inside -drawRect and looks like: void drawFractal x,y,w,h { if (h {predefined value} || w {...}) { drawTriangle x,y,w,h; return; } drawFractal x,y,w/2,h/2 // for lower left Triangle drawFractal ... // for top drawFractal ... // for lower right } The question is: Is it possible to pause after each call to -drawTriangle say for 0.25 second and redisplay the view, so I can see each triangle being draw? Thanks in advance.___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Problem with redirecting stdout
Hello all, I am having some trouble with capturing and redirecting stdout in my Cocoa application. A little bit of background: My app has an embedded scripting language interpreter, and I would like to redirect stdout in order to display the results of executed scripts in an NSTextView. I've followed the approach described in the solution to StackOverflow question: http://stackoverflow.com/questions/2406204 To summarize, I use dup2() to bind stdout to my own NSPipe, and then add an NSNotification observer to listen for an NSFileHandleReadCompletionNotification on the NSPipe; the notification callback then reads the NSPipe. NSFileHandle readInBackgroundAndNotify is used to asynchronously read the data. This approach works, for the most part -- when executed scripts print only a small amount of data to stdout, my app redirects the output to an NSTextView successfully. However, when executed scripts print a large amount of data to stdout, the app hangs. I think the problem is that the pipe buffer is not being flushed/read when it's full; when the pipe is full, the script interpreter then is blocked because it's waiting for the pipe to empty so that it can write. I've also tried using an pseudo-tty via openpty() instead of an NSPipe, but I get the same problem: The app hangs when too much output is sent to stdout by an executing script. I'm sure that what I want to do is possible -- after all, the Xcode debugger console has no problems displaying stdout when running the same script that hangs my app. I guess my question is: How do I deal with a large amount of data that's printed to stdout in this situation? Is there some configuration I can use to change the buffering behavior (I've read elsewhere that stdout is block-buffered by default)? Is there a way to force NSFileHandle readInBackgroundAndNotify to read the pipe more frequently? Or is there something else? Thanks very much in advance, Edmond ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
ABPeoplePickerProblems
I am having a problem with the ABPeoplePickerView. I have read the Class Reference, the Address Book Programming Guide for Mac OS X, searched the web, all to no avail. I wish to double click either a name or a group have the program respond to the double click. I created an ABPeoplePickerView in IB set up selectors in applicationDidFinishLaunching method using the setGroupDoubleAction setNameDoubleAction. Double clicking a name works flawlessly but every time I try to double click the group it generates a Controller cannot be nil error. Here is the peculiar part. If I set the Allows Multiple Selection property in IB, same result if I select only 1 group. However, if I select multiple groups, it works fine!? Whether or not the Allows Multiple Selection property is set, if I click on the column titles everything works fine. I cannot understand this behavior. Nor can I understand why the error. Can anyone point me in the direction of some relevant literature or shed some light on this? I don't think it is my coding. All I want to do is double click a name or a group send it on for further processing. Oh, I am running 10.6.4 on a mac book pro. Thanks for any insights you can offer. Code looks like this: #import AbeAppDelegate.h @implementation AbeAppDelegate @synthesize window; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { [pickerView setGroupDoubleAction:@selector(doGroupDoubleAction)]; [pickerView setNameDoubleAction:@selector(doNameDoubleAction)]; [infoView insertText:@applicationDidFinishLaunching:\r\r]; } // NSApplicationDelegate Protocol Reference to make red button kill app. - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication {return YES;} - (void)doGroupDoubleAction { [infoView insertText:@\r\rGroup was double clicked!\r\r]; [infoView insertText:[[pickerView selectedGroups] description]]; [infoView insertText:@\r\r]; [infoView insertText:[[pickerView selectedRecords] description]]; [infoView insertText:@\r\r]; } - (void)doNameDoubleAction { [infoView insertText:@\r\rName was double clicked!\r\r]; [infoView insertText:[[pickerView selectedRecords] description]]; [infoView insertText:@\r\r]; [infoView insertText:[[pickerView selectedGroups] description]]; [infoView insertText:@\r\r]; } @end ronald b. kopelman___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: Pause during drawing
On 10/11/2010, at 4:23 AM, Siegfried wrote: The question is: Is it possible to pause after each call to -drawTriangle say for 0.25 second and redisplay the view, so I can see each triangle being draw? Yes, but you need to refactor your code. Just inserting a delay while drawing is a bad idea and won't work. Set up a timer that calls every 0.25 seconds. Each time the timer fires, increment an ivar that controls which level of triangle is being drawn, and mark the display as needing refresh (-setNeedsDisplay:). Then, in-drawRect:, use the 'current triangle' ivar to do the relevant part of the drawing. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Problem with redirecting stdout
On Nov 9, 2010, at 5:48 PM, Edmond Ho wrote: To summarize, I use dup2() to bind stdout to my own NSPipe, and then add an NSNotification observer to listen for an NSFileHandleReadCompletionNotification on the NSPipe; the notification callback then reads the NSPipe. NSFileHandle readInBackgroundAndNotify is used to asynchronously read the data. This approach works, for the most part -- when executed scripts print only a small amount of data to stdout, my app redirects the output to an NSTextView successfully. However, when executed scripts print a large amount of data to stdout, the app hangs. I think the problem is that the pipe buffer is not being flushed/read when it's full; when the pipe is full, the script interpreter then is blocked because it's waiting for the pipe to empty so that it can write. Yes, but do you understand why? You're using the same thread to both write to the pipe and handle the data read from the pipe, but it can only be doing one at a time. I'm sure that what I want to do is possible -- after all, the Xcode debugger console has no problems displaying stdout when running the same script that hangs my app. That's because Xcode is an independent process from the process executing the script. I guess my question is: How do I deal with a large amount of data that's printed to stdout in this situation? Is there some configuration I can use to change the buffering behavior (I've read elsewhere that stdout is block-buffered by default)? Is there a way to force NSFileHandle readInBackgroundAndNotify to read the pipe more frequently? The size of the buffer doesn't matter, in the long run. Nor does buffering behavior. And having NSFileHandle read more frequently, whatever that might mean, would only make the problem worse. Think about it. What does NSFileHandle do when it has read some data in the background? It queues up a message for the main thread (or whatever thread you did the -readInBackgroundAndNotify from) to handle the data. Until you issue another -readInBackgroundAndNotify, it doesn't read further. Now, what is your main thread doing? Well, it's writing to stdout. It is definitely not prepared to handle the notification from NSFileHandle -- that is, it's not sitting idle in the run loop. So, it has ceased asking NSFileHandle to read from the pipe. So, eventually, the script is going to fill whatever buffer there is. You have to arrange to execute the two things on independent threads of execution, or even processes. That's the only way to avoid the problem. Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: Problem with redirecting stdout
I think the problem is that the pipe buffer is not being flushed/read when it's full; when the pipe is full, the script interpreter then is blocked because it's waiting for the pipe to empty so that it can write. I don't fully understand the structure of your program, but indeed it sounds like the classic filled-buffer hang. I would solve your problem by using GCD and avoiding NSPipe/NSFileHandle altogether. To prevent the child from hanging when it attempts to write() to its stdout, you need to make sure the parent is always going to read the available data in the buffer as soon as it's available. You can accomplish this without too much trouble: == #define BUFFER_SIZE 0x1000 dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, readFD, 0, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)); dispatch_source_set_event_handler(source, ^{ void *dataBuffer = malloc(BUFFER_SIZE); assert(dataBuffer); ssize_t readResult = 0; do { errno = 0; readResult = read(readFD, dataBuffer, BUFFER_SIZE); } while (readResult == -1 errno == EINTR); assert(readResult = 0); if (readResult 0) { dispatch_async(dispatch_get_main_queue(), ^{ NSString *newDataString = [[[NSString alloc] initWithBytesNoCopy: dataBuffer length: readResult encoding: NSUTF8StringEncoding freeWhenDone: YES] autorelease]; // append newDataString to the NSTextView... }); } else free(dataBuffer); }); == Hopefully that gets the idea across – of course it needs more robust error-checking and such. I've also tried using an pseudo-tty via openpty() instead of an NSPipe, but I get the same problem: The app hangs when too much output is sent to stdout by an executing script. Using a PTY instead of an unnamed pipe wouldn't fix the problem. All using a PTY would do is cause the child's Libc buffer to be flushed after each newline rather than when the Libc buffer is filled. That behavior might be useful, though, if it's preferable that your parent reads the child's output by line rather than by some constant-sized number of bytes. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/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: Issues in specifying the file extensions for NSOpenPanel
On Nov 9, 2010, at 07:00, Sachin Porwal wrote: In my application I need to choose only dmg files, so I am using NSOpenPanel with the following code snippet. But the NSOpenPanel is also allowing me to choose the folders having the extension '.dmg'. Ideally NSOpenPanel should allow me to choose only dmg files not folders ? Is this behavior as designed ? Presumably, since this is mature API, it's behaving as designed. You can get the behavior you want by using a panel delegate to disable choosing directories. However, a better choice might be specify your desired files by UTI rather than extension. ('kUTTypeDiskImage' is the UTI for disk images.) You simply pass the UTI in place of the extension. That should work without a panel delegate. Note also that 'runModalForDirectory:...' is deprecated in 10.6. The correct way is to use 'setAllowedFileTypes:' and 'runModal:'. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Cocoaheads Lake Forest meets tomorrow, 11/10 at 7pm
CocoaHeads Lake Forest will be meeting on the second Wednesday of the month. We will be meeting at the Orange County Public Library (El Toro) community room, 24672 Raymond Way, Lake Forest, CA 92630 Please join us from 7pm to 9pm on Wednesday, 11/10. We will be having an informal discussion on Cocoa design patterns, loosely based on the new Buck and Yacktman book. I will bring my copy for inspection. As always, details and the upcoming meeting calendar can be found at the cocoaheads web site, www.cocoaheads.org. (Personal note: Google Irvine is hiring again. Ping me or drop by for details.) ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
iPad 4.2 (deploy to 3.2.2) error
When I try to run my base 4.2 iPad app on Simulator 3.2.2 or a 3.2.2 device, I get the following error during launch: Data Formatters temporarily unavailable, will re-try after 'continue'. (Not safe to call dlopen at this time.) The Base SDK is set to iOS 4.2 and the iOS Deployment Target is set to iOS 3.2.2. Any hints of what I am doing wrong? When I built with base SDK 3.2, it worked fine. * Richard Collyer iseecol...@sbcglobal.net * ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: PDF and iPad
I will go ahead and write up a bug, but I am not entirely sure the PDF is bad. It does work in Safari and Acrobat. bug report #8651074 Rich Collyer On Nov 9, 2010, at 9:19 AM, David Duncan wrote: I would recommend you Report Bugs for both of these issues. Assuming the PDF is valid, you shouldn't need to preflight them and they shouldn't cause issues. Please attach the PDF in question to whatever bugs you file. On Nov 9, 2010, at 6:54 AM, colors wrote: on some PDF files, when I call CGPDFDocumentGetPage I get the following console output: invalid page tree entry. invalid `Kids' array: missing or invalid dictionary at index 5. Is there a way to keep this from happening, or at least detect the PDF is going to cause this in the code, before it happens? I also get: Error: FT_Open_Face failed: error 2. for some files as well when I call CGContextDrawPDFPage on some PDF files. Once again, is there a way to pre-flight the PDFs to determine if they are going to fail? -- 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/archive%40mail-archive.com This email sent to arch...@mail-archive.com