Re: Sandboxing and file references

2011-09-20 Thread Peter N Lewis
Thanks for the various answers, here is a summary: The explicit entitlement to read a file following an open/drag exists only until the application quits (a fragile exception exists in using URLs stored into the restorable state archive, but even that won't work long term). Thus keeping

Sandboxing and file references

2011-09-19 Thread Peter N Lewis
Questions: * When the user opens/drags a file to me application, is the explicit entitlement to read that file that I'm granted permanent? Will it remain across launch/reboots? * How do I deal with files that I already have a reference to if I enable sandboxing in a future version? * What

Re: Dynamically populate a popup menu

2010-02-17 Thread Peter N Lewis
On 17/02/2010, at 15:53 , Graham Cox wrote: On 17/02/2010, at 6:49 PM, Peter N Lewis wrote: Is there any way to dynamically populate a popup menu on the fly (as it is exposed)? Look into the NSMenuDelegate protocol. It has methods to do what you want. Yes, that looks like it will do what

Dynamically populate a popup menu

2010-02-16 Thread Peter N Lewis
Is there any way to dynamically populate a popup menu on the fly (as it is exposed)? For example, a popup menu that displayed the harddisk hierarchy would need this sort of thing - you wouldn't want the entire thing populated as soon as you click the popup menu, it would take forever and the

Find in a WebKit view?

2010-02-10 Thread Peter N Lewis
Is there any way to add support for the normal Cocoa Find functionality in a WebKit view? Failing that, is there any other way to get search functionality in a WebKit view? I want to do some in-app documentation, and Apple's Help system is so bad I've finally given up on that (floating

Re: Cocoa replacement for Carbon CompositeIconRef() for Snow Leopard 64-bit apps?

2009-10-28 Thread Peter N Lewis
On 28/10/2009, at 14:00 , Graham Cox wrote: On 28/10/2009, at 4:49 PM, Peter N Lewis wrote: a) composite two images, preferably while keeping the different resolutions of the icon b) how to dim an image similarly to kTransformDisabled I'm unclear what you mean by a), but certainly

Re: Cocoa replacement for Carbon CompositeIconRef() for Snow Leopard 64-bit apps?

2009-10-27 Thread Peter N Lewis
On 27/10/2009, at 13:26 , Dalmazio Brisinda wrote: I'm working with a Snow Leopard 64-bit app that contains a Finder- like file browser that uses Carbon IconRef's. I'm trying to get the icons for the selected file with a custom overlay based on the current file selection and Icon Services.

Re: literal strings - who do they belong to?

2009-07-13 Thread Peter N Lewis
On 13/07/2009, at 13:55 , Wade Tregaskis wrote: I know you guys probably know this, but to be technically accurate, there is no guarantee the return value of stringByAppendingString returns an autoreleased string. While your point is true, it's not actually a rebuttal - you can assume

Re: literal strings - who do they belong to?

2009-07-13 Thread Peter N Lewis
On 14/07/2009, at 7:34 , Jeff Laing wrote: Thus, apparentl doing NSString *s = someobject.somevar; is essentially against the rules. You should always use NSString *s = [[someobject.somevar {retain|copy}] autorelease]; No, this is unnecessary. You do not need to do this

Re: Window Resize with Animator Proxy: Window Contents Jump Around

2009-07-13 Thread Peter N Lewis
On 13/07/2009, at 19:08 , Marc Liyanage wrote: I am trying to resize a window with an animation using the NSAnimatablePropertyContainer animator proxy mechanism. The views have the Wants CA Layer option set in IB. Its ridiculously painful isn't it? One thing that may trip you up is auto

Re: literal strings - who do they belong to?

2009-07-12 Thread Peter N Lewis
On 12/07/2009, at 23:23 , Ben Cox wrote: NSString +stringByAppendingString:(NSString*) returns an autoreleased string. If you release it explicitly, your application will crash. On 13/07/2009, at 0:02 , Bill Bumgarner wrote: After the second assignment, htmlString is no longer a literal

Re: Hide Interface Builder Object?

2009-06-25 Thread Peter N Lewis
On 25/06/2009, at 8:47 , Chunk 1978 wrote: i have a simple black NSView that is positioned the top index level of the main view, covering all other visual elements in IB. it's purpose is to fade out, so the view appears to fade in. i have to often move it out of the way, and i also set it to

Re: Ideas required on testing an application install

2009-06-25 Thread Peter N Lewis
On 26/06/2009, at 2:04 , Ramakrishna Vavilala wrote: I just finished converting (rewriting) a windows application to work on Mac OSX. I made a package for my application. Now I want to test it on a clean machine. In Windows I would normally create a clean Virtual Machine and install the

Re: Beginner Question Re: Memory Management

2009-06-23 Thread Peter N Lewis
On 23/06/2009, at 12:31 , WT wrote: So, after I scratched my head silly for several minutes, it suddenly came to me. If I'm going to use a property, I *must* refer to it as object.property rather than simply as property. In the specific example I had, I should not have replaced all those

Re: Opinion on managed memory and garbage collection

2009-06-22 Thread Peter N Lewis
On 22/06/2009, at 22:58 , Phil Hystad wrote: If you were writing a new Cocoa application from scratch, would garbage collection be the preferred method over the reference counting (retain/release) method. Having spent years in Java I would prefer a GC'd approach but I have also seen the

Re: Notification/callback of successful CGEventPost?

2009-06-17 Thread Peter N Lewis
On 17/06/2009, at 9:22 , Dave DeLong wrote: I have this mostly working, but it's not a satisfactory solution. My problem is with posting the CGEvents for a command-v operation. I've found that if I do everything inline (snapshot, replace, paste, restore snapshot), then the restore

Re: NSView directly drawn on screen?

2009-06-14 Thread Peter N Lewis
On 13/06/2009, at 16:51 , Michael Ash wrote: You can't. If you want to receive keyboard events then you must have focus. If you don't want to have focus, then you can't receive keyboard events. Pick one or the other, because you can't have both. Well, technically you could use an event tap or

Re: Get|SetControlProperty() equivalent

2009-06-11 Thread Peter N Lewis
On 11/06/2009, at 18:41 , Jo Meder wrote: It would be great to be able to do this for NSViews but I haven't been able to find any equivalent. Are there any ingenious ways that you might be aware of so I could bolt this on to NSView? I have yet to find a good solution to this. It would be

Re: Second frontmost app?

2009-04-28 Thread Peter N Lewis
On 28/04/2009, at 11:02 , Dave DeLong wrote: Is there a way to get the second frontmost app? For example, right now Mail.app is the frontmost, then Safari, because Safari was the active app before I switched to Mail. Is there any sort of API to that tells me that if I were to cmd-tab,

Re: Dividing NSView to subviews

2009-04-27 Thread Peter N Lewis
On 27/04/2009, at 12:16 , Naresh Kongara wrote: in the view drawing code i didn't changed any thing. After preparing the view from which i need to get the images, i just replaced the line NSImage *img = [[[NSImage alloc] initWithData:[view dataWithPDFInsideRect:sourceRect]] autorelease];

Re: ObjectAlloc and objects that should have been released

2009-04-24 Thread Peter N Lewis
On 25/04/2009, at 8:28 , Miles wrote: I just mean that I'm adding some labels and images to the view. I have quadruple checked that they are all being released, but I must be overlooking something. I doubt its your issue, but I recently had a problem like this that took me far too long to

Re: Dividing NSView to subviews

2009-04-23 Thread Peter N Lewis
On 23/04/2009, at 14:11 , Naresh Kongara wrote: I have a NSView which i want to divide into to required sub views. I implemented it using NSView's dataWithPDFInsideRect: (NSRect )aRect, i.e constructed a image view with the data i got . This process is taking long time if the view is

Re: CF autorelease?

2009-04-23 Thread Peter N Lewis
On 24/04/2009, at 9:56 , Wade Tregaskis wrote: Something I've been using as of late to make CF a little more bearable is the cleanup attribute offered by gcc, e.g.: static inline void _autoreleaseCFArray(CFArrayRef *array) { if (NULL != *array) { CFRelease(*array);

Re: New question about borken NSOperationQueue

2009-04-07 Thread Peter N Lewis
On 01/02/2009, at 5:40 , jurin...@eecs.utk.edu wrote: Previous post indicates that NSOperationQueue only seems to work with ONE queue. It is worse than that, it can crash even with a single queue - the only believed safe case is to a single core processor (ie, the iPhone). Otherwise you

Re: Why does -[NSURLConnection start] crash?

2009-03-30 Thread Peter N Lewis
On 31/03/2009, at 3:32 , Jeff Johnson wrote: Here's the sample code: http://lapcatsoftware.com/downloads/ConnectionStartCrash.m It crashes when calling this: _connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO]; [_connection start]; Google for

Re: Two view controllers in one set of files (Noob question)

2009-03-25 Thread Peter N Lewis
At 12:57 -0400 25/3/09, I. Savant wrote: You can certainly have more than one class declared and implemented in the same .h/.m files. You can also have multiple controllers within the same XIB. Wherever your classes are declared/implemented, they show up as available in Interface Builder as

Re: Fast dictionary with integer keys?

2009-03-15 Thread Peter N Lewis
At 20:33 +0200 15/3/09, Oleg Krupnov wrote: I need to use a dictionary inside a long, time-consuming operation. The keys of the dictionary are integers, the values are NSObjects. I could use NSDictionary, but I don't like the overhead of creating NSNumbers for the keys and then comparing them,

Re: Logical and - second operator evaluated?

2009-03-03 Thread Peter N Lewis
At 21:06 +0100 1/3/09, Martijn van Exel wrote: I can't seem to get away with if(timer!=nil [timer isValid]) [timer invalidate]; Aside from whatever is actually causing your problems (which is nothing to do with the short circuited and in this line, these three lines are all

Re: Simple text encryption

2009-02-28 Thread Peter N Lewis
At 15:03 -0800 25/2/09, Erg Consultant wrote: Are there any classes in Cocoa for simple text file or plist file encryption? I just need something I can point at a file on disk and do simple encryption without a password or key and then decode it later. Doesn't have to be fancy or even all that

Re: Where or when do I release this object from this action.

2009-02-27 Thread Peter N Lewis
At 15:43 -0600 27/2/09, James Cicenia wrote: Here is my code: - (void)monthFruitAction:(id)sender{ MonthPickerViewController *mpvc = [[MonthPickerViewController alloc]initWithNibName:@MonthPicker bundle:nil]; [mpvc setMyParentController:self]; mpvc.view.frame

Re: noobie mem management problem

2009-02-26 Thread Peter N Lewis
At 6:50 -0600 26/2/09, James Cicenia wrote: In .h : NSMutableArray *currentStates; @property (nonatomic, copy) NSMutableArray *currentStates; Now in my appdelegate I have: @synthesize currentStates; then in a method: while (sqlite3_step(statement) == SQLITE_ROW) { char *str =

Re: noobie mem management problem

2009-02-26 Thread Peter N Lewis
At 8:04 -0800 26/2/09, mmalc Crawford wrote: On Feb 26, 2009, at 6:10 AM, Peter N Lewis wrote: The next issue (and this is almost certainly where your problem is) is that your @property is set to copy, so: [self.currentStates addObject:@hello]; is equivalent: [[self currentStates] addObject

Re: noobie mem management problem

2009-02-26 Thread Peter N Lewis
, Peter. Thanks James On Feb 26, 2009, at 8:10 AM, Peter N Lewis wrote: At 6:50 -0600 26/2/09, James Cicenia wrote: In .h : NSMutableArray *currentStates; @property (nonatomic, copy) NSMutableArray *currentStates; Now in my appdelegate I have: @synthesize currentStates; then in a method

Re: do i need to create autorelease pool?

2009-02-25 Thread Peter N Lewis
At 11:44 -0500 25/2/09, Michael Ash wrote: On Wed, Feb 25, 2009 at 12:00 AM, Peter N Lewis pe...@stairways.com.au wrote: The Application Kit creates an autorelease pool on the main thread at the beginning of every cycle of the event loop, and drains it at the end, thereby releasing any

Re: Simple way to traverse 2D array?

2009-02-24 Thread Peter N Lewis
At 18:36 -0600 23/2/09, Ashley Perrien wrote: This is relatively easy if I know how many arrays I'm working with (3 in this case) to simply nest the for loops but if I don't know how many arrays the primary array has, I can't think of a way to nest the loops if I don't know how deeply to nest

Re: do i need to create autorelease pool?

2009-02-24 Thread Peter N Lewis
I know what autorelease pools are and how they work so my question isn't about that. In my iPhone app I create a NSTimer to run at 60fps, in it I update a bunch of stuff and draw opengl. Currently I have: -(void) timerLoop { // create autorelease pool in case anything needs it

Re: Needed : set class for Cocoa

2009-02-05 Thread Peter N Lewis
At 0:29 +0100 6/2/09, Tommy Nordgren wrote: Do anyone know of a set container class for Cocoa objects, that use pointer semantics. You could always just use the C++ std::setNSMutableString* http://www.cppreference.com/wiki/stl/set/start Not Cocoa, as such, but has the semantics you desire.

Re: Objective C++ from Objective C

2009-02-02 Thread Peter N Lewis
At 2:08 +0100 3/2/09, James Trankelson wrote: For the majority of my OS X programming life, I've been using Objective C exclusively. However, I now have a reason to want to use some C++ standard template libraries, and have started looking into Objective C++. I've found the documentation on

Re: Serial IO seems to be starving UI

2009-02-01 Thread Peter N Lewis
At 0:21 -0500 31/1/09, Michael Ash wrote: And even there, a continuous sequence of 0-delay performs should not lock the user out of your program. Seems to me that most non-user events should be interleaved in with user events based on when they occur, or at the very least given equal time. It's

Re: maximum theoretical speedup with dual quad processors

2009-02-01 Thread Peter N Lewis
At 16:27 -0500 1/2/09, Michael Ash wrote: It crashes reliably on my Mac Pro. Note that it uses only one queue. Note that it only enqueues operations from the main thread. Note that it uses a very simple custom NSOperation subclass, and doesn't use NSInvocationOperation at all. Note that it does

Re: How to draw text with fade out effect?

2009-01-29 Thread Peter N Lewis
At 17:38 +0200 28/1/09, Oleg Krupnov wrote: I want to produce the effect of a text string fading out when it's too long to be displayed in a rect. This kind of effect is used in many apps. One option is to draw the end of the string character by character with varying alphas. Ie, instead of

Re: Encryption and Security

2009-01-08 Thread Peter N Lewis
At 17:54 + 8/1/09, Matt Keyes wrote: I am working on an iPhone app that communicates with a .NET SOAP web service. I have the SOAP client down, but now I need to think about the security. The .NET web service ultimately will be validating the Windows login as part of the communication

Re: Using the security framework

2009-01-07 Thread Peter N Lewis
At 18:50 -0600 3/1/09, Joe Turner wrote: I am making a hard drive cloner/backuper, and to do some deleting and copying, I need to use the security framework. What I need to be able to do is have the user type in their password one time, and then it would give me system.privilege.admin rights

Re: how to pass arguments by reference

2008-12-10 Thread Peter N Lewis
But the error when compiling is parse error before token. Is passing by reference not allowed or is there any other syntax that I should follow? References are a C++ feature. Objective C++ works just fine, but you need to compile as Objective C++ by using an extension of .mm. Since this

Re: Getting a substring

2008-12-05 Thread Peter N Lewis
At 20:03 -0200 5/12/08, Ariel Rodriguez wrote: My question is simple, at least that is what i think :) I need to extract something like this: 01816560 from something like this: http://www..com/diario/2008/12/05/um/m-01816560.htm My first idea was to use - (NSArray

Re: How to draw rounded Images

2008-12-03 Thread Peter N Lewis
How to draw rounded images (like application icons) for iPhone. The normal way is to create a rounded NSBezierPath, set the clipping, and then do your drawing. I believe rounded rect NSBezierPath was added in 10.5. I use the following category code for 10.4. NSBezierPath*

Re: about Preferences Toolbar

2008-11-30 Thread Peter N Lewis
At 4:55 + 30/11/08, BirdSong wrote: 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

Re: Need some advice on multithreading

2008-11-26 Thread Peter N Lewis
At 9:00 -0800 26/11/08, David Phillip Oster wrote: However, if instead of using 10 NSOperationQueues, you use a single global NSOperationQueue, the program stops crashing and becomes reliable. If you want serialization, then use -[NSOperation addDependency:] that is what addDependency: is

Re: NSOperationQueue broken?

2008-11-25 Thread Peter N Lewis
[Reposted by request on this thread for the archives] At 13:40 -0400 30/10/08, Michael Ash wrote: I hate to blame an OS bug but I see no other explanation, so here we go. I have a program which uses NSOperationQueue heavily. It uses lots of different queues each of which has a max concurrent

Re: Need some advice on multithreading

2008-11-24 Thread Peter N Lewis
At 13:38 -0500 24/11/08, Michael Ash wrote: No, it's not a general consensus. It's something I discovered on my own, and posted about it here. I haven't received any overall confirmation that it's broken, but my simple test project was able to reliably crash on perhaps half a dozen different

Re: release and reference counting query

2008-11-18 Thread Peter N Lewis
At 19:33 +0100 18/11/08, Marc Stibane wrote: what's the reason for defining a local variable aViewController to receive the UIViewController pointer, then copying that to the instance variable with a setter method which increases the retain count, then decrease the retain count again - instead

Re: How to implement float min(float x, ...) ?

2008-11-17 Thread Peter N Lewis
I apologize, this is plain old C, not Cocoa-specific question, but the fastest way to get the answer. I want to create a function that finds the minimum out of a variable-length list of simple float arguments. In other words, I want this function: float min(float x, ...); Can anyone suggest

Re: How can I use NSTextField like a button?

2008-11-12 Thread Peter N Lewis
I want to use some kind of URL text in a dialog, which the users can click on and which should then open the browser with a specific URL. Here is an example of how it should look like: http://man.icalamus.net/fr/img/menu/about_unregistered.gif I used an NSTextField with blue text and connected

Re: overt and covert retain-release question (instigated by UIViewController on iPhone)

2008-11-12 Thread Peter N Lewis
- (void) loadVew { contentView = [[UIImageView alloc] initWithFrame]; ... self.view = contentView; [contentView release]; ... } As Luke said, you need to read the Objective C 2.0 language section on properties. First off, you should understand

Re: When and how often do you mix C++ with Objective C in your project?

2008-10-30 Thread Peter N Lewis
AI am a newbie to the cocoa world (PC - Mac switcher). I have a fair amount of experience coding in C and C++ and I am just getting into Obj C now. Right now I am trying to learn the language idioms and patterns in the Obj C world, specifically, when do you find yourself mixing C++ code with

Re: what do you use to make icons and similar?

2008-10-20 Thread Peter N Lewis
I need a make a few icons and other graphics for my app, simple stuff like a small yellow triangle with an invisible background. I'm totally and completely graphically challenged which never helps. I can't find a simple (preferably free!) drawing program which will let me make stuff like this.

Re: BOOL array

2008-09-11 Thread Peter N Lewis
At 14:22 +0100 11/9/08, dreamcat7 wrote: On 11 Sep 2008, at 13:08, Jean-Daniel Dupas wrote: And it probably does it better as it will not waste 7 bits for each option. No, in a CFBitVector there is 4-bytes for each bit. CFBit A binary value of either 0 or 1. typedef UInt32 CFBit; The

Re: While we're on the subject of DMG's for software distribution...

2008-09-08 Thread Peter N Lewis
At 20:31 -0700 8/9/08, Chris Markle wrote: In the application folder I am referring to is the application bundle, some PDFs (doc) and a Plugins folder with one plugin bundle in it. I think the application expects the plugins to be in this specific place i.e., the Plugins folder in the

Re: Posting Keyboard Events

2008-09-06 Thread Peter N Lewis
At 20:15 -0600 5/9/08, Dave DeLong wrote: How on earth can I post system keyboard events (without getting a beep)? As Ken mentioned, first off make sure the key has somewhere to go. After that, this is roughly the code I use in Keyboard Maestro (extracted bits and pieces, so it wont compile

Re: Should I retain a variable returned from this accessor?

2008-08-12 Thread Peter N Lewis
Clearly, there is a lot more going on in the code in this question than in typical Cocoa code. That said, if you want to avoid bugs, it would seem that the following is good advice: * Always use autorelease. * Use an Auto Release Pool if necessary (in loops, or with large memory

Re: Should I retain a variable returned from this accessor?

2008-08-11 Thread Peter N Lewis
At 4:48 PM -0400 11/8/08, Kyle Sluder wrote: On Mon, Aug 11, 2008 at 3:12 PM, Sean DeNigris [EMAIL PROTECTED] wrote: Hi, how do I handle memory management for todoUid below? Do I have to retain or autorelease it? [...snip...] // Get uid to return NSString* todoUid =

Re: autorelease CGImageRef?

2008-08-07 Thread Peter N Lewis
At 8:24 AM -0700 7/8/08, Chris Hanson wrote: If you build with the Mac OS X 10.5 SDK, you should be able to use NSMakeCollectable since it's declared as an inline function. The earliest release of Mac OS X you're targeting is a function of the Mac OS X Deployment Target build setting, not the

autorelease CGImageRef?

2008-08-06 Thread Peter N Lewis
Given a CGImageRef, how can I autorelease it? Perhaps this is obvious, or perhaps its impossible, but googling hasn't found me the answer yet except for a tantalizing comment in the docs for NSBitmapImageRep: - (CGImageRef)CGImage (added in 10.5) Returns an autoreleased CGImage object (an

Re: private methods and variables

2008-07-30 Thread Peter N Lewis
At 11:02 PM +0200 29/7/08, Torsten Curdt wrote: Especially for a framework I don't want to expose implementation details to the interface. Others have pointed out that you cannot add ivars in the implementation. However, if you can control the creation of your objects via a factory function