Re: analysing image to find blobs
No I know there's nothing like the code which will find things on an image, but cocoa does have the primitive bits I think I need like converting to a bitmap I can search. The best for me actually would probably be converting to a bitmap with alpha channel only, then I can search it byte by byte for things with alpha threshold and that will be enough. What I was looking for were the best and fastest ways to get a PNG into such a bitmap .. or any other suggestions for looking at the image pixel by pixel and determining which bits of it are coloured .. after a fashion. On Nov 29, 2008, at 12:48 PM, Andrew Farmer wrote: On 28 Nov 08, at 20:18, Roland King wrote: I have an image, it's PNG in this case although GIF/JPG are possible. It's got a transparent background and a few well-spaced coloured circles on it. Most of the image is blank. I want to search the image and find the locations of the circles. There's nothing really like this in Cocoa, but OpenCV has all sorts of computer-vision functionality, including blob detection (and even more interesting things, like face detection). Enjoy. http://opencv.willowgarage.com/wiki/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Text blurred in application
Make sure the PDF is not larger than the button and that it does not contain bitmaps. On 28 Nov 2008, at 23:44:41, Richard Somers wrote: On Nov 28, 2008, at 3:06AM, Adil Saleem wrote: But the static text is not readable when application is launched. It is too blurred. I have been using pdf files for NSButton images. Sometimes the images will be blurred. I have not figured it out yet. Richard ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
displaying huge log files
Hi Guys, I'm developing an application that generates logs (FTP transcript) that could grow really big. I want to display this log in simple textview so that the user can examine it. My question : Is it possible to to display a memory mapped file in an NSTextView and in such way that if the file grows the NSTextView updates. If not, could you recommend some technology I should consider. thanks, Mudi ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Text blurred in application
The pdf canvas size is 25 points x 25 points and displayed full size in the button. It contains only vector graphics. I thought pdf would be the best thing for the simple graphics but it is hard to get it pixel perfect. Many of the paths have pixel exact boundaries within the graphics application. But when these are used in Interface Builder for a NSButton image the pdf output is inconsistent. It seems to have a mind of its own. On Nov 29, 2008, at 4:32AM, Benjamin Dobson wrote: Make sure the PDF is not larger than the button and that it does not contain bitmaps. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Keystrokes for non-ascii letters
Hey everyone, I'm working on a client/server application. The client sends tiny Event objects to the server that can contain an NSString of a letter or short sequence of letters (up to about 4). What I'm trying to do is figure out how the server can perform the keypress(es) to get that letter (or sequence). I know that I could use CGEventCreateKeyboardEvent, but that requires me to know the precise keycode for the letter. If I were limited to just ASCII 0-127, that wouldn't be so bad. But I could also be getting things like é or £ and so on. I'd rather not hard code in every keystroke combination. =) Alternatively, I could try using AppleScript. But in playing around with it, I found that if I do: Tell app System Events to keystroke é, then all it does is type a. Other tests have shown that the keystroke command only accepts basic ASCII characters. Of course I could use the using command down to get the non-ascii letters, but again, that would require me to hard code in every keystroke combination. My last idea is to put it on the clipboard and paste it in by simulating a command-v keystroke. The only problem with this is that command-v doesn't mean paste on all keyboards. Do any of you have any ideas on how I can type arbitrary UTF8 characters programmatically? Thanks, Dave___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Text blurred in application
I just discovered part of my problem. The pdf image was being scaled down slightly even though there was plenty of room for it inside the NSButton. The default scaling is Proportionally Down. Change this to None and the image now is always sharp, at least for a User Interface Resolution of 1.0. Change the User Interface Resolution to 1.25 or 1.5 and the pdf image is ok but not great. This is apparently because A shape is scan- converted by painting any pixel whose square region intersects the shape, no matter how small the intersection is. according to the Scan Conversion Rules in the pdf standard. I think this is why it looks less sharp at these resolutions. Note that fonts get special treatment and will render more precisely because they are hinted. Anyway, perhaps this is why the final image used for many Apple widgets are bitmapped tiff files and not vector pdf. You can tweak each and every pixel in a tiff file if you want to. For me I just wanted to make single vector image and be done with it. On Nov 29, 2008, at 7:33AM, Richard Somers wrote: The pdf canvas size is 25 points x 25 points and displayed full size in the button. It contains only vector graphics. I thought pdf would be the best thing for the simple graphics but it is hard to get it pixel perfect. Many of the paths have pixel exact boundaries within the graphics application. But when these are used in Interface Builder for a NSButton image the pdf output is inconsistent. It seems to have a mind of its own. On Nov 29, 2008, at 4:32AM, Benjamin Dobson wrote: Make sure the PDF is not larger than the button and that it does not contain bitmaps. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Keystrokes for non-ascii letters
On Nov 29, 2008, at 8:26 AM, Dave DeLong wrote: Hey everyone, I'm working on a client/server application. The client sends tiny Event objects to the server that can contain an NSString of a letter or short sequence of letters (up to about 4). What I'm trying to do is figure out how the server can perform the keypress(es) to get that letter (or sequence). I know that I could use CGEventCreateKeyboardEvent, but that requires me to know the precise keycode for the letter. If I were limited to just ASCII 0-127, that wouldn't be so bad. But I could also be getting things like é or £ and so on. I'd rather not hard code in every keystroke combination. =) In general, this is difficult, because keyboard translation occurs via a semi-programmable state machine (the 'uchr' resource). So effectively you either need to run the state machine backwards, or start with each possible input keycode and modifiers combination, run the state machine forwards to produce the output character and use that to generate a table of what inputs produce what outputs. My last idea is to put it on the clipboard and paste it in by simulating a command-v keystroke. The only problem with this is that command-v doesn't mean paste on all keyboards. Do any of you have any ideas on how I can type arbitrary UTF8 characters programmatically? You might look at CGKeyboardEventSetUnicodeString, although that won't help you to simulate command key sequences, because you can't set modifiers using that API. You might also look at using the Accessibility API to explicit select the Paste menu item, rather than trying to simulate a keypress that would invoke the Paste menu item. -eric ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: CALayer containing a view
Wow, your email just made me realize that all I needed was this: [myLayer addSublayer:[gameScreenView layer]]; I never thought it would be this easy! Thanks for the enlightenment. :) I thought that this would only work to add CA content of a CA-backed view, and not subviews, but it seems I was wrong. -Ken --- Kenneth Ballenegger www.seoxys.com kenneth.ballenegger.com [EMAIL PROTECTED] Azure Talon Software www.azuretalon.com [EMAIL PROTECTED] On 29 Nov 2008, at 5:53 PM, David Duncan wrote: It sounds like you just want to set that your root view wants to be layer backed. You shouldn't have to do anything special for that, just call -setWantsLayer:YES in the view at the root of the hierarchy. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Text blurred in application
On Nov 29, 2008, at 10:57 AM, Richard Somers wrote: I just discovered part of my problem. The pdf image was being scaled down slightly even though there was plenty of room for it inside the NSButton. The default scaling is Proportionally Down. Change this to None and the image now is always sharp, at least for a User Interface Resolution of 1.0. Change the User Interface Resolution to 1.25 or 1.5 and the pdf image is ok but not great. This is apparently because A shape is scan-converted by painting any pixel whose square region intersects the shape, no matter how small the intersection is. according to the Scan Conversion Rules in the pdf standard. I think this is why it looks less sharp at these resolutions. Note that fonts get special treatment and will render more precisely because they are hinted. Anyway, perhaps this is why the final image used for many Apple widgets are bitmapped tiff files and not vector pdf. You can tweak each and every pixel in a tiff file if you want to. For me I just wanted to make single vector image and be done with it. YMMV, but over 99% of my apps images are all vector-based PDF. They scale beautifully at any scaling factor between 0.5 and 3.0 (to include the non-integral ones). Artwork is anything from very simple to very complex (to include vectorized versions of original artwork from Poser). I created a class to manage drawing of such images. When drawing, you must normalize the destination rect such that it will always fall on integral boundaries: + (void)makeIntegralRectForScaling_II:(NSRect*)aRect { if (scalingFactor_II != 1.0) { aRect-origin.x *= scalingFactor_II; aRect-origin.y *= scalingFactor_II; aRect-size.width *= scalingFactor_II; aRect-size.height *= scalingFactor_II; *aRect = NSIntegralRect (*aRect); aRect-origin.x /= scalingFactor_II; aRect-origin.y /= scalingFactor_II; aRect-size.width /= scalingFactor_II; aRect-size.height /= scalingFactor_II; } } ___ Ricky A. Sharp mailto:[EMAIL PROTECTED] Instant Interactive(tm) http://www.instantinteractive.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 [EMAIL PROTECTED]
Sorting an NSTableView
I have an NSTableView, filled by an NSArrayController. A column has Creates Sort Descriptor selected in InterfaceBuilder. And right: when I click on this column, an NSSortDescriptor gets created with the selector compare:. Works fine; only compare: is quite unusable; the documentation quite rightly says: If you are comparing strings to present to the end- user, you should typically use localizedCompare: Is it possible to specify in InterfaceBuilder which selector to use for sorting? 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 [EMAIL PROTECTED]
QuartzCore and CIContext
I've included QuartzCore.framework in my project frameworks. This is my header file: #import UIKit/UIKit.h #import QuartzCore/QuartzCore.h @interface MyImageView : UIImageView {} @end I have this in MyImageView.m: CGContextRef cgref = UIGraphicsGetCurrentContext(); CIContext *c = [CIContext contextWithCGContext:cgref options:nil]; And I get the error CIContext undeclared. I'm stumped. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Keystrokes for non-ascii letters
On Nov 29, 2008, at 10:26 AM, Dave DeLong wrote: I'm working on a client/server application. The client sends tiny Event objects to the server that can contain an NSString of a letter or short sequence of letters (up to about 4). What I'm trying to do is figure out how the server can perform the keypress(es) to get that letter (or sequence). I know that I could use CGEventCreateKeyboardEvent, but that requires me to know the precise keycode for the letter. If I were limited to just ASCII 0-127, that wouldn't be so bad. But I could also be getting things like é or £ and so on. I'd rather not hard code in every keystroke combination. =) Alternatively, I could try using AppleScript. But in playing around with it, I found that if I do: Tell app System Events to keystroke é, then all it does is type a. Other tests have shown that the keystroke command only accepts basic ASCII characters. Of course I could use the using command down to get the non-ascii letters, but again, that would require me to hard code in every keystroke combination. My last idea is to put it on the clipboard and paste it in by simulating a command-v keystroke. The only problem with this is that command-v doesn't mean paste on all keyboards. Do any of you have any ideas on how I can type arbitrary UTF8 characters programmatically? As part of an automated testing framework, I generate individual Unicode keyboard events like this: - (void)postUnicodeKeyboardEvent_II:(unichar)aUnicodeCharacter { unichar theCharacters[1]; theCharacters[0] = aUnicodeCharacter; NSString* theString = [[NSString alloc] initWithCharacters:theCharacters length:1]; int theWindowNumber = [[applicationController_II contentWindow_II] windowNumber]; NSEvent*theKeyboardEvent = [NSEvent keyEventWithType:NSKeyDown location:NSMakePoint (0, 0) modifierFlags:0 timestamp:0 windowNumber:theWindowNumber context:nil characters:theString charactersIgnoringModifiers:nil isARepeat:NO keyCode:0]; [NSApp postEvent:theKeyboardEvent atStart:NO]; } In my case, I never needed to set the modifier flags, but you can easily pass in whatever you need to above. And, depending on what modifiers you're working with, make sure to properly set the charactersIgnoringModifiers: param as well. ___ Ricky A. Sharp mailto:[EMAIL PROTECTED] Instant Interactive(tm) http://www.instantinteractive.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 [EMAIL PROTECTED]
Re: Checking One Array Against Another
The only problem with running that is that I get a error in the log and it doesn't seem to be working: -[NSCFSet minusSet:]: mutating method sent to immutable object My slightly modified code is below: NSMutableSet *openApplicationsSet = [NSSet setWithArray:openApplications]; NSSet *allowedApplicationsSet = [NSSet setWithArray:applicationsAllowedMutableArray]; NSSet *badApplicationsSet = [openApplicationsSet minusSet:allowedApplicationsSet]; NSLog(badApplicationsSet); Sincerely, Pierce F. On 11/28/08 10:51 PM, Graff [EMAIL PROTECTED] wrote: On Nov 28, 2008, at 9:59 PM, Pierce Freeman wrote: Would there be some way using the NSSet method to output a list of the applications that the user needs to close in order for the current applications to be in the good list? You can use the NSMutableSet method minusSet: NSSet *allowedSet = [NSSet setWithObjects:@one,@two,@three,nil]; NSMutableSet *openSet = [NSMutableSet setWithObjects:@one,@four,@five,nil]; if([openSet isSubsetOfSet:allowedSet]) NSLog(@The user has only the okay applications open); else { NSLog(@The user has these not okay applications open:); [openSet minusSet:allowedSet]; for(id anItem in openSet) NSLog(anItem); } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Keystrokes for non-ascii letters
An off-list reply pointed this one out to me as well, and I've been playing with it. But I have some more roadblocks: My server app is an agent application (it only runs from the menubar). My preliminary tests show that posting keyboard events this way to another application only result in a system beep. Of course, that beep might be because I have the windowNumber hard set to 0. When it's my own application that receives the event (I have a textfield that's first responder), then it works perfectly. So my questions are: Can this be used for posting events that would get picked up by other applications? If it can, what should I do for the windowNumber? Thanks a bunch, Dave On 29 Nov, 2008, at 10:41 AM, Ricky Sharp wrote: As part of an automated testing framework, I generate individual Unicode keyboard events like this: - (void)postUnicodeKeyboardEvent_II:(unichar)aUnicodeCharacter { unichar theCharacters[1]; theCharacters[0] = aUnicodeCharacter; NSString* theString = [[NSString alloc] initWithCharacters:theCharacters length:1]; int theWindowNumber = [[applicationController_II contentWindow_II] windowNumber]; NSEvent*theKeyboardEvent = [NSEvent keyEventWithType:NSKeyDown location:NSMakePoint (0, 0) modifierFlags:0 timestamp:0 windowNumber:theWindowNumber context:nil characters:theString charactersIgnoringModifiers:nil isARepeat:NO keyCode:0]; [NSApp postEvent:theKeyboardEvent atStart:NO]; } In my case, I never needed to set the modifier flags, but you can easily pass in whatever you need to above. And, depending on what modifiers you're working with, make sure to properly set the charactersIgnoringModifiers: param as well. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Checking One Array Against Another
Klaus: For whatever reason, Xcode is telling me that error: void value not ignored as it ought to be when I try to make badApplicationsSet a mutable set. Sincerely, Pierce F. On 11/29/08 10:22 AM, Klaus Backert [EMAIL PROTECTED] wrote: On 29.11.2008, at 19:00, Pierce Freeman wrote: The only problem with running that is that I get a error in the log and it doesn't seem to be working: -[NSCFSet minusSet:]: mutating method sent to immutable object My slightly modified code is below: NSMutableSet *openApplicationsSet = [NSSet setWithArray:openApplications]; NSSet *allowedApplicationsSet = [NSSet setWithArray:applicationsAllowedMutableArray]; NSSet *badApplicationsSet = [openApplicationsSet minusSet:allowedApplicationsSet]; badApplicationsSet is as NSSet * NOT mutable here, but you want to mutate it just as the compiler told you: mutating method sent to immutable object. NSMutableSet * badApplicationsSet = ... NSLog(badApplicationsSet); Better, to avoid more crashs, would be: NSLog(@badApplicationsSet: %@, badApplicationsSet); Klaus ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Keystrokes for non-ascii letters
On Nov 29, 2008, at 10:00 AM, Dave DeLong wrote: Can this be used for posting events that would get picked up by other applications? Nope. To be honest, I don't know how you post such events to another application -- specifically targeted to another application. In general, Mac OS X maintains a notion of a active application. The [there can only be one] active application is the one to which all keyboard events are directed, save for system hot-key type key events. While, certainly, mouse events can be directed to other applications, any kind of a click event is generally also going to cause the active application to change. You have mentioned server application. Do you have a specific client application you are targeting? Or are you trying to generically send key events to various apps on the system? b.bum ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Font binding
Hi all, I want some fonts in my views to be customizable. Notably, for a table view. I added a font in the user defaults and this part works fine. I did some test on a label and it doesn't work. I want to change the label's font and display the font name. Here's what I've done: I placed 3 buttons (show font, save font and test font) and a label in a view and bound the Font (in IB) like this: Controller key: values, Model Key Path: userFonts.smallFontForList, Value Transformer: NSKeyedUnarchiveFromData Here's the code: - (IBAction)showFontPanel:(id)sender { NSFontPanel *fontPanel = [NSFontPanel sharedFontPanel]; [fontPanel orderFront:sender]; } -(IBAction)saveFont:(id)sender { //get the saved font NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults]; NSMutableDictionary *fontDict = [NSMutableDictionary dictionaryWithDictionary:[userDefault objectForKey:@userFonts]]; NSData *oldFontAsData = [fontDict objectForKey:@smallFontForList]; NSFont *oldFont = [NSKeyedUnarchiver unarchiveObjectWithData:oldFontAsData]; //change it NSFontPanel *fontPanel = [NSFontPanel sharedFontPanel]; NSFont *newFont = [fontPanel panelConvertFont:oldFont]; //save it NSData *newFontAsData = [NSKeyedArchiver archivedDataWithRootObject:newFont]; [fontDict setObject:newFontAsData forKey:@smallFontForList]; [userDefault setObject:fontDict forKey:@userFonts]; } - (IBAction)testFont:(id)sender { NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults]; NSMutableDictionary *fontDict = [userDefault objectForKey:@userFonts]; NSData *data = [fontDict objectForKey:@smallFontForList]; NSFont *tf = [NSKeyedUnarchiver unarchiveObjectWithData:data]; [test setStringValue:[tf fontName]]; } The label changes its value but not its font. Must be some silly thing I overlook... Any hints? Thanks, Andre Masse ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Checking One Array Against Another
--- On Sat, 11/29/08, Pierce Freeman [EMAIL PROTECTED] wrote: For whatever reason, Xcode is telling me that error: void value not ignored as it ought to be when I try to make badApplicationsSet a mutable set. Take a look at the documentation for -[NSMutableSet minusSet:]. Specifically, take a look at what it returns. Cheers, Chuck ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Checking One Array Against Another
On 29.11.2008, at 19:30, Pierce Freeman wrote: Klaus: For whatever reason, Xcode is telling me that error: void value not ignored as it ought to be when I try to make badApplicationsSet a mutable set. Please. Show. Your. Code. Klaus ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
reading a PDF
Hey folks, I am a little stuck here. I am trying to extract (and later modify) text and images in a PDF. First I turned to PDFkit but that seems to be way to high level for these things. Now I am trying with Quartz. While I get to the CGPDFPageRef int pages = CGPDFDocumentGetNumberOfPages(doc); for(int p = 1; p=pages; p++) { CGPDFPageRef page = CGPDFDocumentGetPage(doc, p); I just assume that the actual content is hidden inside the page's content stream(s). Currently I am going through the VoyeurNode example but I still can't seem to find where to get hold of the actual content. There is a CGPDFScannerScan but that doesn't look right either. I've looked at http://developer.apple.com/documentation/GraphicsImaging/Conceptual/PDFKitGuide/PDFKit_Prog_Intro/chapter_1_section_1.html http://developer.apple.com/documentation/graphicsimaging/reference/CGPDFContentStream/Reference/reference.html#//apple_ref/doc/uid/TP40001407-CH1g-SW3 and in particular at http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_pdf_scan/chapter_15_section_3.html Any other pointers? cheers -- Torsten ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: UIViewController memory warnings | didReceiveMemoryWarning | setView | releasing outlets | releasing properties
On Nov 29, 2008, at 9:45 AM, Glenn Bloom wrote: Ashley, Can't thank you enough. I just posted the following, hoping to pre- empt other folks from wasting time correcting me on various points you addressed - and I hope, refocusing things on my major questions. I have of course been through the memory management documentation you referred me to, and much else on the subject, but clearly need to work through it all alot more. Will do so feverishly beginning now, but again, thought it best to fix what I could quickly in a revised post, to avoid wasting lots of folks time... Also I didn't see your response to me posted in the mailing list - so wasn't sure if/how I should give credit for your help? Hmmm... I'm pretty sure that I cc'ed the list on that first email. I believe that if the list sees that a message already went to you it won't send it to you again though so that may explain why you didn't see it there. Oh well, no bother. Unfortunately I still saw a couple of things that I don't think I made myself clear on earlier. NSString* string00Local = [[NSString alloc] initWithString:@00]; //Note: String constants, like @abc, are specially generated by the compiler as static objects; release and retain have no effect on them. So there will be no need to release string00Local myStringA = [[NSString alloc] initWithString:@A];// Note that myStringA is an instance variable but not a property, so can't call self.myStringA. Will need to be released in dealloc If your assignment statement were simply: NSString *string00Local = @00; then yes you wouldn't have to release it. What you're doing though is creating a new object based on the static string @00. Any object created through an -init... type method is owned by you and would need to be released. A @something constant is an object on its' own standing. You do not have to use it as a constant in creating an object. You'd probably only use it in an initWithString: message if you were creating a mutable string from it. I'd probably prefer [@something mutableCopy] though since it's more readable IMO. self.myStringB = [NSString stringWithFormat:@B]; // instance variable - must be released in dealloc. And note that not using self, alternatively setting 'myStringB = ...' would be wrong - it would bypass your @synthesized accessors. In every method except for -init and -dealloc, accessing your properties via self.propertyName. This isn't wrong from a memory management standpoint since the object returned from stringWithFormat: is then retained by the property. But it looks odd. I'd have simply set self.myStringB = @B directly like the others. myStringC = [NSString stringWithFormat:@C];// myStringC is an instance variable but not a property (so can't call self.myStringC).Will need to be released in dealloc This would also need to be retained since you want the value to stay around. You're probably not seeing crashes on any of these because of how NSString conservatively creates objects. I'm relatively certain that if you were to create two objects, objectA = @C and objectB = [NSString stringWithFormat:@C] and compared their pointer value that they'd be equivalent. Really though that is an implementation detail and you should be simply assigning myStringC = @C; I'm not sure if you intended to but you're creating two UILabel objects here. // See previous comment - same reasoning applies (use a temporary variable here as well). UILabel *labelTemp = [[UILabel alloc]init]; self.labelA = labelTemp;// instance variable - will be released in dealloc [labelTemp release]; The first one was created in that stanza. CGRect rectA = CGRectMake(0,0, 320,50);// CGRect is a scalar structure that's local to the scope it's defined in. It has no concept of retain/release/autorelease, the same as NSInteger, NSUInteger, BOOL and CGFloat self.labelA = [[UILabel alloc] initWithFrame:rectA]; Then you created another object here. // Method setView: // Overrides setter for UIViewController property view. - (void)setView:(UIView *)theView; { if (theView == nil){ // release views and label when the argument is nil // As long as this UIViewController subclass retains its top level view then all of the view's subviews will also be retained. However, they should all be released when the UIViewController releases its view... And we can't release them in method didReceiveMemoryWarning because... 1. MUST CONFIRM: we have declared them as properties, with retain, and we can't determine accurately within didReceiveMemoryWarning when the view controller's view is in fact released (except by calling setView), so we can't conditionally release them within the didReceiveMemoryWarning method (except by actually setting the controller's view). self.labelA = nil;
Re: Keystrokes for non-ascii letters
The client application is running on an iPhone/iPod touch and is sending events to the server, which runs (as I mentioned) as an agent application on the desktop. I'm writing both. The purpose of the server application is to dispatch events to the system. These can be many different kinds of events, and right now I'm working on getting the key events to dispatch properly. If I have a keycode, I can successfully use CGEventCreateKeyboardEvent to create and dispatch hard coded keystrokes. My goal now is to accept arbitrary strings and post the keyboard events for them. For ASCII characters, I can easily dispatch a CGEventRef. However, I want to be able to send non-ascii characters as well. Basically, any character that's valid on the iPhone I want to be able to mimic on the desktop. So this includes things like £, but also Asian characters that are inputted via the drawing keyboard. Any ideas how I could go about this? Thanks, Dave On 29 Nov, 2008, at 11:34 AM, Bill Bumgarner wrote: On Nov 29, 2008, at 10:00 AM, Dave DeLong wrote: Can this be used for posting events that would get picked up by other applications? Nope. To be honest, I don't know how you post such events to another application -- specifically targeted to another application. In general, Mac OS X maintains a notion of a active application. The [there can only be one] active application is the one to which all keyboard events are directed, save for system hot-key type key events. While, certainly, mouse events can be directed to other applications, any kind of a click event is generally also going to cause the active application to change. You have mentioned server application. Do you have a specific client application you are targeting? Or are you trying to generically send key events to various apps on the system? b.bum ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Checking One Array Against Another
I may be totally wrong about this, but I think it said that it takes something away from the Mutable Array, and that it doesn't necessarily return anything... As I said, I may be totally wrong about this though. ;) Sincerely, Pierce F. On 11/29/08 10:37 AM, Charles Steinman [EMAIL PROTECTED] wrote: --- On Sat, 11/29/08, Pierce Freeman [EMAIL PROTECTED] wrote: For whatever reason, Xcode is telling me that error: void value not ignored as it ought to be when I try to make badApplicationsSet a mutable set. Take a look at the documentation for -[NSMutableSet minusSet:]. Specifically, take a look at what it returns. Cheers, Chuck ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Keystrokes for non-ascii letters
Le 29 nov. 08 à 19:34, Bill Bumgarner a écrit : On Nov 29, 2008, at 10:00 AM, Dave DeLong wrote: Can this be used for posting events that would get picked up by other applications? Nope. To be honest, I don't know how you post such events to another application -- specifically targeted to another application. CGEventPostToPSN() ? OK, it does not works with NSEvent, but it allows you to specify the target application of a CGEvent. In general, Mac OS X maintains a notion of a active application. The [there can only be one] active application is the one to which all keyboard events are directed, save for system hot-key type key events. While, certainly, mouse events can be directed to other applications, any kind of a click event is generally also going to cause the active application to change. You have mentioned server application. Do you have a specific client application you are targeting? Or are you trying to generically send key events to various apps on the system? b.bum ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Checking One Array Against Another
On Nov 29, 2008, at 12:47 PM, Pierce Freeman wrote: NSMutableSet *openApplicationsSet = [NSSet setWithArray:openApplications]; While openApplicationsSet is declared to be an NSMutableSet you are not creating one. Your assignment should be [NSMutableSet setWithArray:...] NSSet *allowedApplicationsSet = [NSSet setWithArray:applicationsAllowedMutableArray]; NSMutableSet *badApplicationsSet = [openApplicationsSet minusSet:allowedApplicationsSet]; The minusSet: method doesn't return a new object. It mutates the receiver, in this case openApplicationsSet, by removing items it shares in common with the passed in set, allowedApplicationsSet. NSAlert * askToContinue = [NSAlert alertWithMessageText:@Warning! defaultButton:@Continue alternateButton:@Quit otherButton:nil informativeTextWithFormat:@Quit [EMAIL PROTECTED], badApplicationsSet]; Ashley ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Checking One Array Against Another
Okay... That makes sense. :) Thanks for your (and everyone else's) help. Sincerely, Pierce F On 11/29/08 10:58 AM, Ashley Clark [EMAIL PROTECTED] wrote: On Nov 29, 2008, at 12:47 PM, Pierce Freeman wrote: NSMutableSet *openApplicationsSet = [NSSet setWithArray:openApplications]; While openApplicationsSet is declared to be an NSMutableSet you are not creating one. Your assignment should be [NSMutableSet setWithArray:...] NSSet *allowedApplicationsSet = [NSSet setWithArray:applicationsAllowedMutableArray]; NSMutableSet *badApplicationsSet = [openApplicationsSet minusSet:allowedApplicationsSet]; The minusSet: method doesn't return a new object. It mutates the receiver, in this case openApplicationsSet, by removing items it shares in common with the passed in set, allowedApplicationsSet. NSAlert * askToContinue = [NSAlert alertWithMessageText:@Warning! defaultButton:@Continue alternateButton:@Quit otherButton:nil informativeTextWithFormat:@Quit [EMAIL PROTECTED], badApplicationsSet]; Ashley ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Checking One Array Against Another
On Nov 29, 2008, at 1:00 PM, Pierce Freeman wrote: The only problem with running that is that I get a error in the log and it doesn't seem to be working: -[NSCFSet minusSet:]: mutating method sent to immutable object My slightly modified code is below: NSMutableSet *openApplicationsSet = [NSSet setWithArray:openApplications]; NSSet *allowedApplicationsSet = [NSSet setWithArray:applicationsAllowedMutableArray]; NSSet *badApplicationsSet = [openApplicationsSet minusSet:allowedApplicationsSet]; NSLog(badApplicationsSet); The method minusSet: is an NSMutableSet method but you are constructing an NSSet and assigning it to a NSMutableSet pointer: NSMutableSet *openApplicationsSet = [NSSet setWithArray:openApplications]; That's why you get the error mutating method sent to immutable object. You should instead do the following: NSMutableSet *openApplicationsSet = [NSMutableSet setWithArray:openApplications]; Since NSMutableSet inherits from NSSet you can still use the setWithArray: method to create the set. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
RE: UIViewController memory warnings | didReceiveMemoryWarning |
In response to an excellent first reply, below is a revision to my original post that corrects various points, and that also incorporates some changes to better focus my remaining questions - please disregard my original post in favor of the following: In the course of trying to understand UIViewController memory warnings on the iPhone, I've found various useful threads online, and in particular, was very glad to follow the numerous recent posts in this forum with the subject 'Outlets / IBOutlet declarations'. In response, I've written a test app to confirm what I think I understand. Below is an interface and implementation that modify the iPhone View-Based Application template to display a UILabel and a UIImage within a couple of nested views. I define and work with different instance variables and (local variables as well), for the point of trying to compare what gets released/deallocated where and how.., I am specifically trying to understand how to override didReceiveMemoryWarning, setView and dealloc. Each point I am most uncertain about is labelled with MUST CONFIRM. // // Test00ViewController.h // Test00 // #import UIKit/UIKit.h @interface Test00ViewController : UIViewController { NSString *myStringA; // Will NOT be a property NSString *myStringB; NSString *myStringC; // Will NOT be a property UIView *primaryViewA; UIView *subViewA; UILabel *labelA; UIImageView *imageViewA; } @property (nonatomic, retain) NSString *myStringB; // Note: For the iPhone, unless encountering a compelling reason not to do so, generally make outlets properties, and retain them. //Note: Typically, an IBOutlet specifies an instance variable that references some object that is defined in your NIB file. However, just as an academic exercise, in this example, primaryViewA will be created programmatically, even though declared as an outlet. // Preferred syntax is to use the IBOutlet tag on the @property line, rather than in the interface declaration above @property (nonatomic, retain) IBOutlet UIView *primaryViewA; @property (nonatomic, retain) UIView *subViewA; @property (nonatomic, retain) UILabel *labelA; @property (nonatomic, retain) UIImageView *imageViewA; @end // // Test00ViewController.m // Test00 // #import Test00ViewController.h @implementation Test00ViewController @synthesize myStringB; @synthesize primaryViewA; @synthesize subViewA; @synthesize labelA; @synthesize imageViewA; // Implement loadView if you want to create a view hierarchy programmatically - (void)loadView { NSString* string00Local = [[NSString alloc] initWithString:@00]; //Note: String constants, like @abc, are specially generated by the compiler as static objects; release and retain have no effect on them. So there will be no need to release string00Local myStringA = [[NSString alloc] initWithString:@A];// Note that myStringA is an instance variable but not a property, so can't call self.myStringA. Will need to be released in dealloc self.myStringB = [NSString stringWithFormat:@B]; // instance variable - must be released in dealloc. And note that not using self, alternatively setting 'myStringB = ...' would be wrong - it would bypass your @synthesized accessors. In every method except for -init and -dealloc, accessing your properties via self.propertyName. myStringC = [NSString stringWithFormat:@C];// myStringC is an instance variable but not a property (so can't call self.myStringC).Will need to be released in dealloc NSMutableString * stringCompleteMutable = [NSMutableString stringWithString:string00Local]; // local variable set with a constructor that handles release, so there will be no need to release it [stringCompleteMutable appendString: @, ]; [stringCompleteMutable appendString: myStringA]; [stringCompleteMutable appendString: @, ]; [stringCompleteMutable appendString: self.myStringB]; [stringCompleteMutable appendString: @, ]; [stringCompleteMutable appendString: myStringC]; // The property primaryViewA already has a retain count of 1, and if you were to set it using [UIView alloc] init...] you would increase its retain count to 2. Instead, allocate it to a temporary variable, assign that to the @property and then release your temporary variable. UIView *viewTempA = [[UIView alloc]initWithFrame:[[UIScreen mainScreen] applicationFrame]]; self.primaryViewA = viewTempA; [viewTempA release]; self.primaryViewA.backgroundColor = [UIColor redColor]; // See previous comment - same reasoning applies UIView *viewTempB = [[UIView alloc]initWithFrame:[[UIScreen mainScreen] applicationFrame]]; self.subViewA = viewTempB; [viewTempB release]; self.subViewA.backgroundColor = [UIColor greenColor]; // See previous comment - same reasoning applies (use a temporary variable here as well). UILabel *labelTemp = [[UILabel alloc]init]; self.labelA = labelTemp;// instance variable - will be released in dealloc [labelTemp release]; CGRect rectA = CGRectMake(0,0, 320,50);// CGRect is a scalar structure that's local
Re: Checking One Array Against Another
On Nov 29, 2008, at 1:00 PM, Pierce Freeman wrote: The only problem with running that is that I get a error in the log and it doesn't seem to be working: -[NSCFSet minusSet:]: mutating method sent to immutable object My slightly modified code is below: NSMutableSet *openApplicationsSet = [NSSet setWithArray:openApplications]; NSSet *allowedApplicationsSet = [NSSet setWithArray:applicationsAllowedMutableArray]; NSSet *badApplicationsSet = [openApplicationsSet minusSet:allowedApplicationsSet]; NSLog(badApplicationsSet); Also, because minusSet: actually modifies the set it is being called on there is no need to create a new pointer to hold the resulting set. You can just do something like the following: NSSet *allowedApplicationsSet = [NSSet setWithArray:applicationsAllowedMutableArray]; NSMutableSet *badApplicationsSet = [NSMutableSet setWithArray:openApplications]; [badApplicationsSet minusSet:allowedApplicationsSet]; NSLog([NSString stringWithFormat:@badApplicationsSet: %@, badApplicationsSet]); ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Right language
Hello List, I'm pretty new to Cocoa and just started with Cocoa Programming for Mac OS X (3rd ed) of Aaron Hillegass. I've got an idea for a app that uses a lot of shell commands to get certain information. But I also want to use Interface builder to provide the users the right interface. I'm wondering if Cocoa is right language to build this application. I've thought about AppleScript Studio. But I want to be able to use something like eSellarate as well. What are your opinions about this? Should I build the application using Cocoa or look into perhaps Ruby or some other language? Hope you can help. --- Met vriendelijke groet, Kind regards, Arnold Nefkens Nefkens Advies Enk 26 4214 DD Vuren +31183 634730 +31183 690113 +31650 660459 [EMAIL PROTECTED] Apple Certified Systems Administrator Apple Certified Technical Coördinator Apple Certified Support Professional Apple Certified Macintosh Technician vcard: http://www.nefkensadvies.nl/vcard/anefkens.vcf website:http://www.nefkensadvies.nl/ iChat: [EMAIL PROTECTED] Jabber/GoogleTalk: [EMAIL PROTECTED] Confidentiality Warning This e-mail message contains confidential information which is intended for the use of the person to whom it is addressed. If you received it in error,please notify the sender and delete the material from any computer. Any disclosure, re-transmission, dissemination or any other use of this information is strictly prohibited. --- Arnold Nefkens Nefkens Advies [EMAIL PROTECTED] Apple Certified Systems Administrator Apple Certified Technical Coördinator Apple Certified Support Professional Apple Certified Macintosh Technician ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: reading a PDF
I just assume that the actual content is hidden inside the page's content stream(s). Raw content, mostly, sometimes. But the draw commands are what put it all together. For instance, you might have a paragraph of text where there is one draw command per line, or you might have a paragraph of text where is one draw command per character. For an image that fills the page, you might have one content stream and one draw command, or you might have multiple image slices with one content stream and one draw command for each slice. IOW, what you want is not so simple. -- Scott Ribe [EMAIL PROTECTED] http://www.killerbytes.com/ (303) 722-0567 voice ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Keystrokes for non-ascii letters
On Nov 29, 2008, at 10:48 AM, Dave DeLong wrote: My goal now is to accept arbitrary strings and post the keyboard events for them. For ASCII characters, I can easily dispatch a CGEventRef. However, I want to be able to send non-ascii characters as well. Basically, any character that's valid on the iPhone I want to be able to mimic on the desktop. So this includes things like £, but also Asian characters that are inputted via the drawing keyboard. Eric Schlegel already suggested CGEventKeyboardSetUnicodeString, although he misspelled it. As long as you can require 10.5.5 or later, that should do the trick. smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Rollover on custom Cells
Hello, I know this was already asked, but I couldn't find any reply which will help me in the list. I have a Custom View, that view has a layer, and that layer has many sub-layers which are squares, so at the end what I have is a grid of 10 x 10, the book Im reading (Hillegass) says that to do rollovers, you should avoid using the mouseMoved: instead override the mouseEntered: and mouseExited: and define a tracking area. So I did it whit all the Cells that the Custom view has, I defined the tracking area for each cell in the grid and add them, then I overrode the methods mouseEntered: and moseExited, and when I ran the app and pass the mouse over the view ,KABOOM!! debugger launched. I then start reading and found no info, maybe I looked bad or something. So I decided to just define set only one tracking area, the area of the custom view, which has a big layer (which contains all the cells). I tried again and KABOOM!! debugger launched when entering the mouse on the view. So I checked my code again, and I realize i didn't have the methods to accept and become the firstResponde, I add them, tried and KABOOM!!, and then I got disappointed and now im writing asking for help. Can somebody please give me and advise of what Im might be doing wrong?, or any efficient method to achieve this purpose ? Thanks a lot Gustavo ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Keystrokes for non-ascii letters
More questions! (wh =) ) I've abandoned the NSEvent approach, although it would've been nice if it had worked, and am now trying CGEventKeyboardSetUnicodeString. Here's my code: CGEventSourceRef eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState); CGEventRef keyEventDown = CGEventCreateKeyboardEvent(eventSource, 0, true); UniChar buffer = '£'; //that's a pound (the currency) sign for all you without unicode support in your email CGEventKeyboardSetUnicodeString(keyEventDown, 1, buffer); CGEventPost(kCGHIDEventTap, keyEventDown); CFRelease(keyEventDown); First off, when building it, I get a warning on the buffer = '£'; line, that it's a multi-character character constant. What does that mean? Then, when I actually run it, I don't get the pound sign, but get some Asian character that looks like a cross between a camping stove and a two-story house. Lastly, I'm not sure how I can convert my NSString into a UniChar array (which is what the function wants). I've been all over Google and the various list archives for more information on CGEventKeyboardSetUnicodeString, but have found nothing helpful. Can anyone point me in the right direction? Thanks for all your help! Dave On 29 Nov, 2008, at 1:27 PM, James W. Walker wrote: Eric Schlegel already suggested CGEventKeyboardSetUnicodeString, although he misspelled it. As long as you can require 10.5.5 or later, that should do the trick. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: reading a PDF
I just assume that the actual content is hidden inside the page's content stream(s). Raw content, mostly, sometimes. But the draw commands are what put it all together. For instance, you might have a paragraph of text where there is one draw command per line, or you might have a paragraph of text where is one draw command per character. Getting to the individual draw commands for the text/characters would be a first step ...and maybe even enough for what I am after. Is this what the CGPDFOperatorTableSetCallback() is for? For an image that fills the page, you might have one content stream and one draw command, or you might have multiple image slices with one content stream and one draw command for each slice. Would a PDF writer really slice the images up? IOW, what you want is not so simple. I see. Well, I probably don't really need the image extraction Just getting the text draw commands might suffice. cheers -- Torsten ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: reading a PDF
On Nov 29, 2008, at 3:16 PM, Torsten Curdt wrote: I just assume that the actual content is hidden inside the page's content stream(s). Raw content, mostly, sometimes. But the draw commands are what put it all together. For instance, you might have a paragraph of text where there is one draw command per line, or you might have a paragraph of text where is one draw command per character. Getting to the individual draw commands for the text/characters would be a first step ...and maybe even enough for what I am after. Is this what the CGPDFOperatorTableSetCallback() is for? For an image that fills the page, you might have one content stream and one draw command, or you might have multiple image slices with one content stream and one draw command for each slice. Would a PDF writer really slice the images up? IOW, what you want is not so simple. I see. Well, I probably don't really need the image extraction Just getting the text draw commands might suffice. At my day job, we use pdfbox (see www.pdfbox.org) in automated tests. It basically grabs raw textual data and spits out two-dimensional arrays of strings. While it's java based, it may shed a light on how text extraction can be done. I do not, however, know if their licensing model will fit your needs (i.e. if you base your code on theirs, is that even allowed). There's some links on their site (http://www.pdfbox.org/ references.html) which shows how someone wrote a Cocoa app and used the Java bridge to interface with pdfbox. ___ Ricky A. Sharp mailto:[EMAIL PROTECTED] Instant Interactive(tm) http://www.instantinteractive.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 [EMAIL PROTECTED]
Re: Keystrokes for non-ascii letters
On Nov 29, 2008, at 1:03 PM, Dave DeLong wrote: More questions! (wh =) ) I've abandoned the NSEvent approach, although it would've been nice if it had worked, and am now trying CGEventKeyboardSetUnicodeString. Here's my code: CGEventSourceRef eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState); CGEventRef keyEventDown = CGEventCreateKeyboardEvent(eventSource, 0, true); UniChar buffer = '£'; //that's a pound (the currency) sign for all you without unicode support in your email CGEventKeyboardSetUnicodeString(keyEventDown, 1, buffer); CGEventPost(kCGHIDEventTap, keyEventDown); CFRelease(keyEventDown); First off, when building it, I get a warning on the buffer = '£'; line, that it's a multi-character character constant. What does that mean? Then, when I actually run it, I don't get the pound sign, but get some Asian character that looks like a cross between a camping stove and a two-story house. Your source file is probably encoded as UTF-8, so the pound character is getting interpreted as 2 bytes of UTF-8, not a single UTF-16 character. Don't try to enter Unicode directly in your source. Lastly, I'm not sure how I can convert my NSString into a UniChar array (which is what the function wants). See the getCharacters: method. I've been all over Google and the various list archives for more information on CGEventKeyboardSetUnicodeString, but have found nothing helpful. It didn't actually work for both Cocoa and Carbon apps until some recent update of Leopard, so probably nobody has been using it. On 29 Nov, 2008, at 1:27 PM, James W. Walker wrote: Eric Schlegel already suggested CGEventKeyboardSetUnicodeString, although he misspelled it. As long as you can require 10.5.5 or later, that should do the trick. smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Text blurred in application
Hi, My scenario is a little different than what you have described. I don't have images on buttons. I have my custom window (which is a black colored image) and on it are the static texts. These texts are displaying blurred. Although i have not been able to figure out why is this happening, but i got a work around by using a different color shade of window image. So my problem is solved, but if anyone could explain the reason for that, it would be nice. It would come in handy for future use. Thank you --- On Sat, 11/29/08, Richard Somers [EMAIL PROTECTED] wrote: From: Richard Somers [EMAIL PROTECTED] Subject: Re: Text blurred in application To: cocoa-dev@lists.apple.com Date: Saturday, November 29, 2008, 8:57 AM I just discovered part of my problem. The pdf image was being scaled down slightly even though there was plenty of room for it inside the NSButton. The default scaling is Proportionally Down. Change this to None and the image now is always sharp, at least for a User Interface Resolution of 1.0. Change the User Interface Resolution to 1.25 or 1.5 and the pdf image is ok but not great. This is apparently because A shape is scan-converted by painting any pixel whose square region intersects the shape, no matter how small the intersection is. according to the Scan Conversion Rules in the pdf standard. I think this is why it looks less sharp at these resolutions. Note that fonts get special treatment and will render more precisely because they are hinted. Anyway, perhaps this is why the final image used for many Apple widgets are bitmapped tiff files and not vector pdf. You can tweak each and every pixel in a tiff file if you want to. For me I just wanted to make single vector image and be done with it. On Nov 29, 2008, at 7:33AM, Richard Somers wrote: The pdf canvas size is 25 points x 25 points and displayed full size in the button. It contains only vector graphics. I thought pdf would be the best thing for the simple graphics but it is hard to get it pixel perfect. Many of the paths have pixel exact boundaries within the graphics application. But when these are used in Interface Builder for a NSButton image the pdf output is inconsistent. It seems to have a mind of its own. On Nov 29, 2008, at 4:32AM, Benjamin Dobson wrote: Make sure the PDF is not larger than the button and that it does not contain bitmaps. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/adilsaleem01%40yahoo.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: QuartzCore and CIContext
I found out what's wrong: Core Image isn't available for the iPhone OS. dkj ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Authorized Copy/Erase (NSFileManager)
So, I'm creating a copy/erase tool for an app, and I need to be able to authorize the user so I can copy and delete files that need Admin permissions. I have looked thoroughly through the Security.framework, but could not find anything. I do not want to do a shell script, so I would rather not use the authorized execute command. Is there a way to do this? And if there is, what is the best way to only have the user type their password once (using the Security framework), and never have to again the next time the app launches? Thanks Joe Turner NiceMac LLC programmer ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: reading a PDF
At my day job, we use pdfbox (see www.pdfbox.org) in automated tests. It basically grabs raw textual data and spits out two-dimensional arrays of strings. While it's java based, it may shed a light on how text extraction can be done. I do not, however, know if their licensing model will fit your needs (i.e. if you base your code on theirs, is that even allowed). Yes, already had a look at that. But I was hoping I don't have to spend the time to translate that to Objective-C myself. It's BSD licensed - so license-wise that would be fine. There's some links on their site (http://www.pdfbox.org/references.html) which shows how someone wrote a Cocoa app and used the Java bridge to interface with pdfbox. Uh ...interesting. Was hoping for something native though. Thanks for the pointer! cheers -- Torsten ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: reading a PDF
Hi Torsten, I haven't looked extensively into the latest Apple documentation on this subject and wouldn't be surprised if it has been rolled in recently, but David Gelphman's Programming with Quartz does go into this in some detail. Chapter 14, Creating and Examining PDF Documents, contains a listing (Listing 14.11) of fairly extensive code showing how to count and categorize the images used on each page of a PDF document. Also, the quartz-dev mailing list would be another good place to discuss your topic. Best Wishes for Technical Success! Joel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Fwd: MVC question
I've included Klaus' response for the benefit of anyone who may be interested: On 29.11.2008, at 08:38, Michael A. Crawford wrote: When implementing the MVC pattern, is it inappropriate or bad-form for views and layers to have direct read-only access to the model? The Cocoa Fundamentals Guide discusses this topic, see Reference Library Guides Cocoa Design Guidelines Cocoa Fundamentals Guide Cocoa Design Patterns The Model-View-Controller Design Pattern MVC as a Compound Design Pattern. In figure 4-4 you can see, that in the traditional version of MVC models notify views and views get model states directly. In figure 4-5 you can see, that in the Cocoa version models and views communicate through mediating controllers only. So: is it inappropriate or bad-form ... ? – generally no and Cocoa- wise yes, I think. Klaus Begin forwarded message: From: Michael A. Crawford [EMAIL PROTECTED] Date: November 28, 2008 11:38:12 PM PST To: cocoa-dev@lists.apple.com Subject: MVC question When implementing the MVC pattern, is it inappropriate or bad-form for views and layers to have direct read-only access to the model? Currently I'm using KVO to have the different views and layers get notification of state changes in the model. Since the drawing of the views and layers is asynchronous to the processing of the KVO notifications, I'm cacheing local copies of the model's state in order to draw specific content based on said state. It seems that it would be more efficient to only handle the KVO notification as a trigger to redraw the view or layer using [layer setNeedsDisplay] and allow the individual layers to query the model directly. When the [layer drawInContext] method executes, if I have const or read-only access to the model, I don't need to have cached state information, instead I simply read the model state in question at the point of drawing and draw the appropriate content. What do the more experienced MVC/NSView/CALayer coder's think of this approach? More detail . . . In order to implement it, I need to change my layer hosting view so that instead of the view being the only one with a pointer to the model, I provide each layer and associated sub-layers with their own pointer to the model so that, upon observation of model state changes, the individual layers can query the model and draw. Currently, in the view's awakeFromNib method, I add all of my observers, passing the appropriate keys, contexts, and layers, and then allow the layers to handle the observation call-backs, caching the data associated with the keys being observed and calling their own drawInContext methods via [self setNeedsDisplay]. This requires duplication of model data. Is it worth duplicating this data in order to reduce coupling between the view and the model? I suspect not since the view is always going to be dependent on the model and any changes to the model will require changes to the view. -Michael -- There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. -- C.A.R. Hoare ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/michaelacrawford%40mac.com This email sent to [EMAIL PROTECTED] -Michael -- The difference between genius and stupidity... ...is that genius has its limits. -- Albert Einstein smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Checking One Array Against Another?
On Nov 28, 2008, at 9:53 PM, Pierce Freeman wrote: for (int arraySort = 0; arraySort [arrayInfo count]; arraySort++) { for (int arrayNewSort = 0; arrayNewSort [arrayNewInfo count]; arrayNewSort++) { if ([ arrayInfo objectAtIndex:arraySort] == [arrayNewInfo objectAtIndex:arrayNewSort]) The above conditional checks for the same object being in both arrays. It doesn't check for two different but equivalent objects being in the two arrays. With strings, you probably want to use isEqualToString: or one of the compare:... methods, instead of the == operator. 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 [EMAIL PROTECTED]
Re: Keystrokes for non-ascii letters (SOLVED)
Fantastic! I've gotten it to work, and it works beautifully! Thank you, James (and everyone else) for helping me with this. For archival purposes, here's my code: CGEventSourceRef eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState); CGEventRef keyEventDown = CGEventCreateKeyboardEvent(eventSource, 0, true); NSString * characters = ;//some UTF16 string acquired from somewhere. in my case, an NSData object UniChar buffer; for (int i = 0; i [characters length]; i++) { [characters getCharacters:buffer range:NSMakeRange(i, 1)]; keyEventDown = CGEventCreateKeyboardEvent(eventSource, 1, true); CGEventKeyboardSetUnicodeString(keyEventDown, 1, buffer); CGEventPost(kCGHIDEventTap, keyEventDown); CFRelease(keyEventDown); } CFRelease(eventSource); Thanks again for all your help! Dave On 29 Nov, 2008, at 3:10 PM, James W. Walker wrote: Your source file is probably encoded as UTF-8, so the pound character is getting interpreted as 2 bytes of UTF-8, not a single UTF-16 character. Don't try to enter Unicode directly in your source. Lastly, I'm not sure how I can convert my NSString into a UniChar array (which is what the function wants). See the getCharacters: method. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
RE: Simple Core Animation Problem
Thanks for your replyMy plan is to have a one big view covering the whole window, and then put a one big layer covering all that view. That way the rest of the user interface could just be many sublayers within the big layers.The rounded rectangle I mentioned would be one of those sublayers. However, I would want the text field would be a part of that particular sublayer.So, are you saying that when the user double-clicks the rounded rectangle layer and animates to expand, I should (with code) on the spot make a text field in there to display my wanted (editable) text? By doing that, don't I run into the risk of the text not appearing until the animation is over? I would rather want the text field to gradually show as the animation is occurring.Can I somehow back a text field with a layer to control how the text field looks? Will that still make the text field editable? If I can somehow do this, I guess I could use masksToBounds=YES on the rounded rectangle so that the text field will be there inside but can remain hidden. That way I might be able to put (with code) the layer backed text field there before the animation takes place, even though the text field will not be fully visible until the animation is over.What do you think? CC: cocoa-dev@lists.apple.com From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: Simple Core Animation Problem Date: Sat, 29 Nov 2008 00:08:44 -0700 - Layers can have rounded rects by setting the layer's cornerRadius property. BTW, you can't create layers in a NIB. The *must* be created in code. - Layers do not inherit from NSResponder so clicks (and double-clicks) must be registered through a backing layer - You can easily hide a view such as an NSTextField. When your height animation completes, you will get an -animationDidStop notification at which point you can show your NSTextField (look at setHidden in NSView). You said simple. I'm not so sure that's true. I suggest you write some code and post specific questions. Best Regards, -Matt On Nov 28, 2008, at 7:26 PM, Ulai Beekam wrote: I want to create this user interface element: A rounded rectangle somewhere on the window (it should be able to be created through code, not inside the NIB). If I double click it, it should increase its height using animation. But here is the catch: When the heigh is increased, a text field is revealed! In other words, there is a text field that is a part of that box, and is only revealed when the box height is increased. How can I attach a textfield to a layer like that? Thank you. U. _ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.aspxmkt=en-us___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
RE: Simple Core Animation Problem
Sorry, the last email got posted as rich text and became garbled. Allow me to try again. Thanks for your reply My plan is to have a one big view covering the whole window, and then put a one big layer covering all that view. That way the rest of the user interface could just be many sublayers within the big layers. The rounded rectangle I mentioned would be one of those sublayers. However, I would want the text field would be a part of that particular sublayer. So, are you saying that when the user double-clicks the rounded rectangle layer and animates to expand, I should (with code) on the spot make a text field in there to display my wanted (editable) text? By doing that, don't I run into the risk of the text not appearing until the animation is over? I would rather want the text field to gradually show as the animation is occurring. Can I somehow back a text field with a layer to control how the text field looks? Will that still make the text field editable? If I can somehow do this, I guess I could use masksToBounds=YES on the rounded rectangle so that the text field will be there inside but can remain hidden. That way I might be able to put (with code) the layer backed text field there before the animation takes place, even though the text field will not be fully visible until the animation is over. What do you think? CC: cocoa-dev@lists.apple.com From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: Simple Core Animation Problem Date: Sat, 29 Nov 2008 00:08:44 -0700 - Layers can have rounded rects by setting the layer's cornerRadius property. BTW, you can't create layers in a NIB. The *must* be created in code. - Layers do not inherit from NSResponder so clicks (and double-clicks) must be registered through a backing layer - You can easily hide a view such as an NSTextField. When your height animation completes, you will get an -animationDidStop notification at which point you can show your NSTextField (look at setHidden in NSView). You said simple. I'm not so sure that's true. I suggest you write some code and post specific questions. Best Regards, -Matt On Nov 28, 2008, at 7:26 PM, Ulai Beekam wrote: I want to create this user interface element: A rounded rectangle somewhere on the window (it should be able to be created through code, not inside the NIB). If I double click it, it should increase its height using animation. But here is the catch: When the heigh is increased, a text field is revealed! In other words, there is a text field that is a part of that box, and is only revealed when the box height is increased. How can I attach a textfield to a layer like that? Thank you. U. _ Discover the new Windows Vista http://search.msn.com/results.aspx?q=windows+vistamkt=en-USform=QBRE___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
(no subject)
Hi I know I can put an image into a layer by doing theLayer.contents = cgTheGreatImage. But that will just put a single image on the layer. My question is, how can I use that image to have a repeating pattern on that layer of that single image? Can you give me short example code snippet? Could be useful for things like having small texture images to form a background pattern on the layer. Thanks, U _ Discover the new Windows Vista http://search.msn.com/results.aspx?q=windows+vistamkt=en-USform=QBRE___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: UIViewController memory warnings | didReceiveMemoryWarning | setView | releasing outlets | releasing properties
On Nov 29, 2008, at 2:58 PM, Glenn Bloom wrote: // Implement loadView if you want to create a view hierarchy programmatically - (void)loadView { /* snip */ NSMutableString * stringCompleteMutable = [NSMutableString stringWithString:string00Local]; // local variable set with a constructor that handles release, so there will be no need to release it [stringCompleteMutable appendString: @, ]; [stringCompleteMutable appendString: myStringA]; [stringCompleteMutable appendString: @, ]; [stringCompleteMutable appendString: self.myStringB]; This is fine and there's nothing wrong with it but it might be more readable to create your string with a format string: NSString *stringComplete = [NSString stringWithFormat:@%@, %@, %@, string00Local, myStringA, self.myStringB]; That's really a stylistic point though, it's not like this code will be running in a loop generating hundreds of strings where you'd want to send as few messages as possible. self.labelA.text = stringCompleteMutable; [self.labelA setText:stringCompleteMutable]; These two lines are equivalent but I think it's just remnants of some copy and pasting though. As I understand it, all instances of UIViewController will receive the didReceiveMemoryWarning message when the OS warns the app. At that point you should clear out any caches. Since they all receive this message, even if they're visible, you can't know at that point whether the view will be released or not. Currently the only way to know that your view is going away is when you receive a setView:nil message. It's at that point, when your view is being released, that you should also release and nil out any references you may have to objects that are part of that view. // Method setView: // Overrides setter for UIViewController property view. - (void)setView:(UIView *)theView; { if (theView == nil){ // release views and label when the argument is nil // As long as this UIViewController subclass retains its top level view then all of the view's subviews will also be retained. However, they should all be released when the UIViewController releases its view... And we can't release them in method didReceiveMemoryWarning because... 1. MUST CONFIRM: we have declared them as properties, with retain, and we can't determine accurately within didReceiveMemoryWarning when the view controller's view is in fact released (except by calling setView), so we can't conditionally release them within the didReceiveMemoryWarning method (except by actually setting the controller's view). self.labelA = nil; self.imageViewA = nil; self.subViewA = nil; self.primaryViewA = nil; // We also release this here, not in didReceiveMemoryWarning, despite the fact that the controller's view is set to this rather than it be added to the controller's view as a subview. Since the view is going away here you need to remove all references to it, and in fact, must remove this reference specifically as it won't be dealloc'ed until you do since you've retained it. } [super setView:theView]; }// End Method setView: - (void)didReceiveMemoryWarning { // Release anything that's not essential, such as cached data (meaning instance variables, and what else...?) // Obviously can't access local variables such as defined in method loadView, so can't release them here // We can set some instance variables as nil, rather than call the release method on them, if we have defined setters that retain nil and release their old values (such as through use of @synthesize). This can be a better approach than using the release method, because this prevents a variable from pointing to random remnant data. Note in contrast, that setting a variable directly (using = and not using the setter), would result in a memory leak. self.myStringB = nil; // Even though no setters were defined for this object, still set it to nil after releasing it for precisely the same reason that you set properties to nil. // Note that because myStringA was only set to point to a static string, it doesn't really need to be released here, but pedantically this is correct - this is good form, anticipating for instance, a modification by which this string ends up being later created through some other class in some other manner [myStringA release], myStringA = nil; // Releases the view if it doesn't have a superview [super didReceiveMemoryWarning]; } - (void)dealloc { // In contrast to how you deallocated in didReceiveMemoryWarning, in dealloc you don't want to employ setters. As a general rule, you don't want to employ setters in either init methods or in dealloc. Conceptually, generic
Re: Right language
On Sat, Nov 29, 2008 at 5:30 AM, Arnold Nefkens [EMAIL PROTECTED] wrote: Hello List, I'm pretty new to Cocoa and just started with Cocoa Programming for Mac OS X (3rd ed) of Aaron Hillegass. I've got an idea for a app that uses a lot of shell commands to get certain information. But I also want to use Interface builder to provide the users the right interface. I'm wondering if Cocoa is right language to build this application. I've thought about AppleScript Studio. But I want to be able to use something like eSellarate as well. What are your opinions about this? Should I build the application using Cocoa or look into perhaps Ruby or some other language? As to AppleScript, I'm of the opinion that for essentially any task which cannot be accomplished in 5 lines or less, AppleScript is never the right language. Note that Cocoa is not a language. Cocoa is a set of libraries. They can be accessed from many different languages. The primary language is Objective-C, but Cocoa can also be used from Ruby, Python, and many others. If by Cocoa you mean Objective-C, I see no reason why it would be unsuitable for this task. But try it out and see for yourself. On another note, it's generally a bad idea to invoke shell tools. Sometimes you have no choice, but you should look for ways to access the information you need directly in code instead. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Bindings help in many-to-many case
Namaste! After having done many hours of investigating, head-scratching, trial/ error, and more searching, I've gotten stuck. I created a simple scenario to work out how to accomplish a many-to- many situation. I created two entities: Person and Hat. They are defined thus: Person: personName: string relHats: to-many relationship to Hat Hat: hatName: string relPersons: to-many relationship to Person The relationships are inverses. I dragged three Array Controllers to the MainMenu.NIB: Persons, Hats, and Persons_Hat. Persons and Hats are bound to their respective entities. Persons_Hats is bound thus: contentSet: Persons.selection.relHats contentArrayForMultipleSelection: Persons.selection.relHats I dragged a tableview onto the window to support add/remove of Persons. One column, value bound to Persons.arrangedObjects.personName. I dragged two buttons, bound them to add/remove of Persons respectively. I dragged another tableview onto the window to support add/remove of Persons_Hats. One column, containing a popup. The column is bound thus: Content: Hat.arrangedObjects ContentValues: Hat.arrangedObjects.hatName SelectedValue: Persons_Hats.arrangedObjects.relHats I dragged two more buttons on to support add/remove of Persons_Hats. Bound appropriately. I dragged one more button to support Add for Hat. Bound appropriately. Running the application generates the following error: 2008-11-29 11:29:34.876 TestManyToMany2[2820:10b] Unacceptable type of value in to-many relationship: property = relHats; problem = {( NSManagedObject: 0x1b4ea0 (entity: Person; id: 0x18ac80 x-coredata:///Person/tFF2FA03C-6F69-49C3-9190-FB99E9DC1DCC4 ; data: { personName = New Person; relHats = ( ); }) )}; desired type = NSManagedObject_Hat_; given type = NSCFSet; value = NSManagedObject: 0x1b4ea0 (entity: Person; id: 0x18ac80 x-coredata:///Person/tFF2FA03C-6F69-49C3-9190-FB99E9DC1DCC4 ; data: { personName = New Person; relHats = ( ); }). I don't know what to do with that. I compared what I have with the sample application, Event Manager, and what I have appears to correspond with the way that application is set up. The main difference being that EventParticipant (which corresponds with Persons.relHats in my sample) is a separate table. I did try this as a flatter relationship (a key table between), but I was getting the same result. Something I know is not quite right as the EventManager app works just fine. I haven't been able to resolve this problem, which is very key to getting my actual (I'm porting an existing Windows VB .NET/WPF app over) application to work. Theoretically, from my vantage, this should function. Anyone care to help out on this one? If this simply can't be done, just tell me so I don't waste any more time on it and I'll go another route. Yes, I've read the dox, read the Hillegass book, and spent many hours trolling through post after post. I'm sure it is something really stupid, but I just don't see it. Thanks! Peace, Love, and Light, /s/ Jon C. Munson II ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
about Preferences Toolbar
Hi all, I am writting the mac component of a mac-iphone application. I saw most of the applications(Finder, MSN, iChat...) on Mac are all using the same style preferences toolbar. However, I didn't find it in IB's Libirary. Could anyone tell me what's it or where can I find it? Thanks. _ 新版手机MSN,新功能,新体验!满足您的多彩需求! http://mobile.msn.com.cn ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: about Preferences Toolbar
Check out Brandon's fantastic BWToolkit: http://www.brandonwalkin.com/blog/2008/11/13/introducing-bwtoolkit/ HTH, Dave On 29 Nov, 2008, at 9:55 PM, BirdSong wrote: Hi all, I am writting the mac component of a mac-iphone application. I saw most of the applications(Finder, MSN, iChat...) on Mac are all using the same style preferences toolbar. However, I didn't find it in IB's Libirary. Could anyone tell me what's it or where can I find it? Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: about Preferences Toolbar
On Sat, Nov 29, 2008 at 11:55 PM, BirdSong [EMAIL PROTECTED] wrote: Could anyone tell me what's it or where can I find it? It's just a standard toolbar. The buttons are selection buttons, though, which means that you have to notify the toolbar that they are selectable using the -toolbarSelectableItemIdentifiers: delegate method. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Authorized Copy/Erase (NSFileManager)
On Sat, Nov 29, 2008 at 5:54 PM, Joe Turner [EMAIL PROTECTED] wrote: So, I'm creating a copy/erase tool for an app, and I need to be able to authorize the user so I can copy and delete files that need Admin permissions. I have looked thoroughly through the Security.framework, but could not find anything. I do not want to do a shell script, so I would rather not use the authorized execute command. Is there a way to do this? Nope. You *must* use a subtool of some kind. It's a fundamental of the UNIX security model that a process's privileges can only decrease, not increase. If your process can't touch the file now, nothing it does can suddenly allow it to. The only thing you can do is execute a subtask with elevated privileges. It doesn't have to be a shell script of course, but it has to be some separate process. And if there is, what is the best way to only have the user type their password once (using the Security framework), and never have to again the next time the app launches? Check out Apple's BetterAuthorizationSample which, while being an impressively horrible piece of code (entirely due to the constraints it's working under, not to criticize the authors of this sample code in any way), it shows exactly how to do this sort of thing and you can pretty much plug it in to your own application. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSTrackingArea strange requirement
Hi, I dunno if this is the right way to do it, but what if you Override mouseMoved: for the main view that contains all the subviews, and use a hitTest: to find the view over which the cursor is hovering and simply use [[NSCursor whateverCursor] set]; to change the cursor depending on the view. You obviously need to call setAcceptsMouseMovedEvennts on the view's window during initialization so that u'll get called with mouseMoved:. Just a wild guess, Chaitanya On 28-Nov-08, at 11:22 PM, Quincey Morris wrote: On Nov 28, 2008, at 01:57, rajesh wrote: On 27/11/2008, at 10:22 PM, rajesh wrote: but I see a kind of problem with above approach as well. Since we are updating the TrackingAreas in updateTrackingAreas (removing and adding track areas) , my cursor (which is set to resizeUpDownCursor mouseEntered: ) seems to flicker when ever try updating/resizing my view due to the fact that trackAreas are changed every time. You shouldn't be using -mouseEntered: to set the cursor. You should init the tracking area with the NSTrackingCursorUpdate option and then implement the -cursorUpdate: method. Sorry my mistake :( . I corrected it. but the cursor still flickers and I think I am missing some great deal in implementing the tracking. Given your requirements, there's probably no really easy way for you to handle the cursor, but I still think you're making it harder for yourself than it needs to be. IIRC, you have a parent custom view, which contains subviews that are instances of NSBox, each of which contains other views, some of which may set the cursor on their own (like text fields -- let's pretend they're all text fields for the sake of the discussion). -- When the mouse is over the parent view, but not over any of the boxes, you want a resize cursor. -- When the mouse is over a text field, you don't want to interfere. -- When the mouse is over a box subview, but not over one of the text fields, you want to .. what? Let the cursor be whatever it was *before it entered the parent view*? Set the cursor to an arrow? I suspect you're trying to do the former (let the cursor revert to whatever it was before you changed to a resize cursor), but I think the correct answer is the latter (set the cursor to an arrow). One reason I think it's correct is that it's doable, while the other choice may not be, or not without driving you insane. So, again, I think you just need one tracking area for the parent view, and one tracking area for each box view. -- When the mouse enters a resize region, either by entering it from the outside or by exiting one of the box subviews, your custom view gets a cursorUpdate event. You should check the mouse location, and set the appropriate resize cursor. -- When the mouse enters a text field, it changes to whatever the text field wants it to be. -- When the mouse enters a box region, the cursorUpdate event will attempt to go to the view under the mouse -- the box view or one of its subviews. If that view implements cursorUpdate, that's fine -- the cursor is handled. If not (the usual case, I suspect), the event goes up the responder chain till some responder handles it. In this case, that would be your custom view. So, your custom view should check the mouse location, and set the arrow cursor if the mouse is over one of its subviews. That is, your custom view's cursorUpdate: method is going to be setting the cursor appropriately for *all* of the tracking area events, *except* where a sub-subview handles the cursor on its own. That means it needs to check the mouse location and determine the appropriate cursor. Having said all that, I'll add: -- If you re-define tracking areas (delete the old ones and create new ones), there's a temporary loss of mouse synchronization -- whether the mouse is outside or inside becomes unknown until at least the mouse moves, maybe longer. That means you could fail to get expected cursorUpdate events, possibly until the next time the mouse enters or exits a tracking area. To minimize the effects of this defect, make sure you use the NSTrackingAssumeInside option for the tracking areas. That option is mis-documented, and in most cases it's better to use it than to not use it. (The correct documentation is in the Leopard developer release notes.) -- Although it may not apply here, there's one cause of cursor flickering that's easy to overlook. When the mouse is inside a scroll view or any of its subviews, the scroll view itself may sometimes set the cursor, especially when scrolling. If your custom view is inside a scroll view, you should invoke -[NSScrollView setDocumentCursor:] whenever you change the cursor, so that the cursor it uses matches the cursor you're trying to use. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or