Re: Memory management question in Objective-C 2.0 @property notation

2009-02-05 Thread Devraj Mukherjee
Thanks again both of you.

assuming that I do self.name = [NSString string] and since it the
NSString helper message, I shouldn't have to release that in my
dealloc implementation.

Or am I understanding this incorrectly.

On Thu, Feb 5, 2009 at 5:01 PM, Kiel Gillard kiel.gill...@gmail.com wrote:
 On 05/02/2009, at 4:20 PM, Chris Suter wrote:

 On Thu, Feb 5, 2009 at 4:10 PM, Kiel Gillard kiel.gill...@gmail.com wrote:

 However, doing this will yield a memory leak:

 self.name = [[NSString alloc] init];

 ...because the property definition tells the compiler the methods it

 synthesizes should retain the value.

 You're right that it will leak in that case but you've given the wrong
 reason as to why. Memory management rules are covered by Apple's
 documentation.

 Regards,

 Chris

 Thanks for your reply, Chris.
 I suggest that the code quoted above will yield a memory leak because the
 NSString instance allocated will have a retain count of two after the
 setName: message has be sent to self. To correct this error, I suggest that
 the code should read:
 self.name = [[[NSString alloc] init] autorelease];
 Under the heading of Setter Semantics
 of 
 http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_5_section_3.html#//apple_ref/doc/uid/TP30001163-CH17-SW2,
 I can see that Apple's documentation clearly states that the implementation
 of a property declared with a retain attribute will send a retain message to
 the value given in the right hand side of the assignment.
 I'm confused as to why else the memory would be leaking? Can you please
 identify my error?
 Thanks,
 Kiel




-- 
The secret impresses no-one, the trick you use it for is everything
- Alfred Borden (The Prestiege)
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Open OtherApp just behind MyApp

2009-02-05 Thread Yang Meyer

Ken,

I want to open another application (say, Safari) in the layer  
just behind my application.


Solution 2:
[ws launchApplication:@Safari]; // opens Safari in front
	[NSApp activateIgnoringOtherApps:YES]; // pushes my app in front,  
effectively right above Safari


Problem with solution 2: I must be doing it wrong, because my own  
application's window doesn't ever get its focus back and the GUI  
seems to hang.


I think that -activateIgnoringOtherApps: is being done too soon.   
The NSApplicationDeactivatedEventType event is pending and hasn't  
had a chance to be processed, yet. (…) So, you have to implement a  
simple trampoline method.


Thanks for pointing out the potential cause. I read up on Obj-C  
trampoline methods/objects (pretty cool, actually!) and understand the  
basic idea, but honestly I'm not seeing the connection to my problem.  
Why and how would such a trampoline object help in delaying the call  
to -activateIgnoringOtherApps:? Could you maybe sketch out how the  
trampoline might look?


Thanks,
Yang___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Memory management question in Objective-C 2.0 @property notation

2009-02-05 Thread mmalc Crawford


On Feb 5, 2009, at 12:21 AM, Devraj Mukherjee wrote:


assuming that I do self.name = [NSString string] and since it the
NSString helper message, I shouldn't have to release that in my
dealloc implementation.
Or am I understanding this incorrectly.

http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_5_section_4.html#//apple_ref/doc/uid/TP30001163-CH17-SW21 

http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html 



mmalc

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Memory management question in Objective-C 2.0 @property notation

2009-02-05 Thread mmalc Crawford


On Feb 4, 2009, at 10:01 PM, Kiel Gillard wrote:

I'm confused as to why else the memory would be leaking? Can you  
please identify my error?



The error is in your explanation.


However, doing this will yield a memory leak:
self.name = [[NSString alloc] init];
...because the property definition tells the compiler the methods it  
synthesizes should retain the value.


This is not a memory leak because the property definition tells the  
compiler the methods it synthesizes should retain the value; it is a  
leak because you're not abiding by the memory management rules.   
You're creating an object you own (alloc), and not relinquishing  
ownership.
(See http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html 
 for full details.)


There are several ways to remedy the problem; the overall best  
practice approach is:


NSString *aString = [[NSString alloc] init];
self.name = aString;
[aString release];


I suggest that the code quoted above will yield a memory leak  
because the NSString instance allocated will have a retain count of  
two


Explaining memory management at this level in terms of retain counts  
is a leap down the wrong path.


mmalc

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Bug in QCRenderer ...?

2009-02-05 Thread Anshul jain

I am trying to Render a Composition in CAOpenGLLayer using QCRenderer.


This is how i create QCRenderer

- (CGLContextObj)copyCGLContextForPixelFormat: 
(CGLPixelFormatObj)pixelFormat

{
	CGLContextObj object =  [super  
copyCGLContextForPixelFormat:pixelFormat];
	NSString *path = [[NSBundle mainBundle] pathForResource:@Blob  
ofType:@qtz];

QCComposition *aComposition = [QCComposition compositionWithFile:path];
	CGColorSpaceRef colorRef =   
CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
	qcRenderer = [[QCRenderer alloc] initWithCGLContext:object  
pixelFormat:pixelFormat colorSpace:colorRef composition:aComposition];

return object;
}


And this is how i display it...

- (BOOL)canDrawInCGLContext:(CGLContextObj)glContext pixelFormat: 
(CGLPixelFormatObj)pixelFormat forLayerTime: 
(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp

{
CGLSetCurrentContext(glContext);
_startTime = _startTime + (1.0f / 25.0f);
	BOOL success = [qcRenderer renderAtTime:_startTime arguments: 
[NSDictionary dictionary]];

if (texture)
CVOpenGLBufferRelease(texture);
texture = [qcRenderer createSnapshotImageOfType:@CVOpenGLBuffer];
if (success) {
if (texture)
return YES;
}
return NO;
}

then i display the texture in drawInCGLContext method.

But nothing get displays on the View.

I have debugged the Application and found out that   
createSnapshotImageOfType: returns NULL.
but renderAtTime: return true.  Is this the Bug or i am going some  
where wrong.


Thanks!
Anshul
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Anyone using IKImageView/any alternatives ?

2009-02-05 Thread Christian Graus
I am googling for example of IKImageView, and all I am finding is posts like
this one:
http://espresso-served-here.com/category/scribbler/

In short, lots of people are reporting that IKImageView plain does not work
as advertised.  Does anyone have any positive experience with this control ?
All I need to do is zoom and pan an image, does the NSImageView support
that, or is there somewhere else I should be looking ?

Thanks as always

Christian
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


another NSCFDictionary and GC problem?

2009-02-05 Thread Markus Guhe

Hi all,

I get the following elusive crash (about once in 20 app launches). It  
happens while decoding a dictionary using an NSKeyedUnarchiver from a  
saved file when my application starts. The value of the dictionary  
that causes this problem is an attributed string, and the crash only  
occurs if the string that's being decoded contains a non-text  
attachment (if it is an RTFD string).


The problem only occurs if GC is turned on (and only on slower  
machines or when starting it with the standard Development profile  
from Xcode). It always occurs at this point in NSCFDictionary.


I saw the recent discussion on NSCFDictionary and GC thread on this  
list. Could this be related?


I've been banging my head over this for some time now; so any help or  
hint is greatly appreciated! If this is a problem in the library: is  
there a workaround?


Markus


Process: SlipBox [3177]
Path:/Applications/SlipBox.app/Contents/MacOS/SlipBox
Identifier:  net.markusguhe.slipbox
Version: 0.9-b1 (213)
Code Type:   PPC (Native)
Parent Process:  launchd [76]

Date/Time:   2009-02-01 13:21:16.478 +0100
OS Version:  Mac OS X 10.5.6 (9G55)
Report Version:  6

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0028
Crashed Thread:  0

Application Specific Information:
objc[3177]: garbage collection is ON

Thread 0 Crashed:
0   libobjc.A.dylib 0xfffeff18 objc_msgSend_rtp + 24
1   com.apple.Foundation  	0x92fc4564 -[NSCFDictionary  
setObject:forKey:] + 288
2   com.apple.AppKit  	0x90287afc -[NSRTFD  
setObject:forKey:] + 340
3   com.apple.AppKit  	0x90343f44 -[NSAKDeserializer  
deserializePList:] + 596
4   com.apple.AppKit  	0x90343cc0 -[NSDocumentDeserializer  
deserializeNewPList] + 88
5   com.apple.AppKit  	0x90343a5c - 
[NSRTFD(NSSerializationSupport) initWithPasteboardDataRepresentation:]  
+ 196
6   com.apple.AppKit  	0x90343484 -[NSFileWrapper  
initWithSerializedRepresentation:] + 104

7   com.apple.Foundation0x92fd21e8 _decodeObjectBinary + 2376
8   com.apple.Foundation0x92fd17d8 _decodeObject + 168
9   com.apple.AppKit  	0x905553ac -[NSTextAttachment  
initWithCoder:] + 216

10  com.apple.Foundation0x92fd21e8 _decodeObjectBinary + 2376
11  com.apple.Foundation  	0x92fd3148 -[NSKeyedUnarchiver  
_decodeArrayOfObjectsForKey:] + 916
12  com.apple.Foundation  	0x92ff0330 - 
[NSDictionary(NSDictionary) initWithCoder:] + 804

13  com.apple.Foundation0x92fd21e8 _decodeObjectBinary + 2376
14  com.apple.Foundation  	0x92fd3148 -[NSKeyedUnarchiver  
_decodeArrayOfObjectsForKey:] + 916
15  com.apple.Foundation  	0x92fd370c -[NSArray(NSArray)  
initWithCoder:] + 572

16  com.apple.Foundation0x92fd21e8 _decodeObjectBinary + 2376
17  com.apple.Foundation0x92fd17d8 _decodeObject + 168
18  com.apple.Foundation  	0x92ff097c  
_NSReadMutableAttributedStringWithCoder + 580
19  com.apple.Foundation  	0x92ff05ac -[NSAttributedString  
initWithCoder:] + 76

20  com.apple.Foundation0x92fd21e8 _decodeObjectBinary + 2376
21  com.apple.Foundation0x92fd17d8 _decodeObject + 168
22  net.markusguhe.slipbox   	0x3088 -[Slip initWithCoder:] +  
116

23  com.apple.Foundation0x92fd21e8 _decodeObjectBinary + 2376
24  com.apple.Foundation  	0x92fd3148 -[NSKeyedUnarchiver  
_decodeArrayOfObjectsForKey:] + 916
25  com.apple.Foundation  	0x92ff0330 - 
[NSDictionary(NSDictionary) initWithCoder:] + 804

26  com.apple.Foundation0x92fd21e8 _decodeObjectBinary + 2376
27  com.apple.Foundation0x92fd17d8 _decodeObject + 168
28  net.markusguhe.slipbox	0x0001582c -[Box  
readFromData:ofType:error:] + 364
29  com.apple.AppKit  	0x9041af1c -[NSDocument  
readFromURL:ofType:error:] + 684
30  net.markusguhe.slipbox	0x000156ac -[Box  
readFromURL:ofType:error:] + 40
31  com.apple.AppKit  	0x90303e04 -[NSDocument  
initWithContentsOfURL:ofType:error:] + 260
32  com.apple.AppKit  	0x902d7860 -[NSDocumentController  
makeDocumentWithContentsOfURL:ofType:error:] + 328
33  com.apple.AppKit  	0x902d6f4c -[NSDocumentController  
openDocumentWithContentsOfURL:display:error:] + 340
34  net.markusguhe.slipbox	0xcb90 -[SlipBoxController  
openDocumentWithContentsOfURL:display:error:] + 1080
35  net.markusguhe.slipbox	0xd1dc -[SlipBoxController  
openDefaultDocIfNothingYetOpen] + 616
36  net.markusguhe.slipbox	0xa500 -[SlipBoxApplication  
applicationWillFinishLaunching:] + 80

37  com.apple.Foundation0x92fc8064 _nsnote_callback + 196
38  com.apple.CoreFoundation  	0x935927c8  
_CFXNotificationPostNotification + 920
39  

best way to do precise timing on iphone?

2009-02-05 Thread Memo Akten
Hi ALl, i'm aware that on desktop using mach_absolute_time() is the  
way to go for precise timing of code (http://developer.apple.com/qa/qa2004/qa1398.html 
) but I was wondering what is the alternative for iphone? not sure if  
this is the right place to post, but Id gladly repost if someone  
could point me to the right place. I'm guessing NSDate isn't going to  
be that accurate for this kind of stuff...

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: best way to do precise timing on iphone?

2009-02-05 Thread Phil
On Fri, Feb 6, 2009 at 1:06 AM, Memo Akten m...@memo.tv wrote:
 Hi ALl, i'm aware that on desktop using mach_absolute_time() is the way to
 go for precise timing of code
 (http://developer.apple.com/qa/qa2004/qa1398.html) but I was wondering what
 is the alternative for iphone? not sure if this is the right place to post,
 but Id gladly repost if someone could point me to the right place. I'm
 guessing NSDate isn't going to be that accurate for this kind of stuff...

You can use mach_absolute_time() on the iPhone.

Future questions about iPhone development should be directed to the
developer forums though:
https://devforums.apple.com/

Phil
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: best way to do precise timing on iphone?

2009-02-05 Thread Memo Akten
Thanks, I just couldn't find the framework for  
AbsoluteToNanoseconds(), but found the code below which seems to work  
fine.

http://shiftedbits.org/2008/10/01/mach_absolute_time-on-the-iphone/

thx bout the devforums btw...


On 5 Feb 2009, at 12:14, Phil wrote:


On Fri, Feb 6, 2009 at 1:06 AM, Memo Akten m...@memo.tv wrote:
Hi ALl, i'm aware that on desktop using mach_absolute_time() is the  
way to

go for precise timing of code
(http://developer.apple.com/qa/qa2004/qa1398.html) but I was  
wondering what
is the alternative for iphone? not sure if this is the right place  
to post,
but Id gladly repost if someone could point me to the right place.  
I'm
guessing NSDate isn't going to be that accurate for this kind of  
stuff...


You can use mach_absolute_time() on the iPhone.

Future questions about iPhone development should be directed to the
developer forums though:
https://devforums.apple.com/

Phil


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


System Activity shortly after booting

2009-02-05 Thread Trygve Inda
Immediately after OS X boots and gets logged in, there is quite a lot of
disk activity. I'd like to be able to detect this and delay the start of
processing for a background app.

Basically it needs to wait the 30-60 seconds or so until the OS is doing
less and has settled down. Is there a good way to do this from Cocoa?

Thanks,

Trygve


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Saving application data in ~/Library/Application Support/

2009-02-05 Thread Mike Abdullah
Please, please, please do not store preferences in ~/Library/ 
Application Support/

They should go in ~/Library/Preferences
Everything else is fine to go in app support.

Apple provides both NSUserDefaults and CFPreferences APIs for storing  
your prefs, although you could do it manually if you really wish.


On 5 Feb 2009, at 02:05, Josh de Lioncourt wrote:


Hi,

I have some products under development written in C++.  I am not  
using Cocoa for the most part, as these are cross-platform projects.


The apps themselves need to save, store, and access information,  
such as registration keys, user preferences, etc.  It seems to me  
that the logical place to do this is in the ~/Library/Application  
Support/ directory.


Is it safe/recommended to access this directory using the above  
format, or is there a more accepted shortcut designation for that  
particular dir?



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSService - I need a headslap (A Solution)

2009-02-05 Thread Steve Cronin

Peter;

Turns out my issue was not related to the Info.plist at all.
The confusion about 'default' label on the 'Services' menu has to do  
with how Finder handles dropping a .plist into .txt field...


My service 'MyService' does indeed need to subclass NSApplication.
I just quit fighting against the tide and added an empty nib. -- Presto!

So now my working stand alone service provider consists of merely 6  
small items:

1) an .icns file
2) an empty IB generated nib file - completely unmodified  (v2 NIB in  
my case [Tiger compatible])
	(adding a NIB allows me to just use the standard main.m  'return  
NSApplicationMain(argc,  (const char **) argv);'

3) main.m  - the usual Cocoa version  (however see question below)
3) an Info.plist (Principal class set to 'MyService' and the standard  
'Services' specification.

4) a MyService.h file which sublclasses NSApplication
5) the MyService.m file for the file above.  This does 3 things:
- in init [NSApp setDelegate:self];
- in 'AppDidFinishLaunch' [NSApp setServiceProvider:self];
- provides the required method(s) for providing a service:
	   - (void) seviceName:(NSPasteboard *)pboard userData:(NSString  
*)userData error:(NSString **)error


*** 2 Questions
-- I am operating on the presumption that this standalone service  
should terminate after providing its service but I can see an argument  
for not doing so.
It's pretty lightweight (one class (~100 lines of ObjC) and an empty  
nib).

Do you have any guidance to offer here.
Since there is no interface to this service, what is the standard UI  
support for termination?


-- In the past, I have used the following main.m to log data to  
specific files:

int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
	freopen([[NSHomeDirectory() stringByAppendingPathComponent:@Library/ 
Logs/com.mycompany.myapp.log] fileSystemRepresentation], w, stderr);	

[pool release];
return NSApplicationMain(argc,  (const char **) argv);
}

But here my log statements are ending up in the console log.
Is there a way I can easily route log statements in MyService to a  
specific file?


Hope to get some feedback on these questions and that this posting  
eventually proves useful to someone else.


Steve


On Feb 4, 2009, at 5:10 PM, Peter Ammon wrote:



On Feb 4, 2009, at 1:23 PM, Steve Cronin wrote:


keyNSMenuItem/key
dict
keyMenu item title/key
stringMyService/string
/dict


The key here needs to be default instead of Menu item title.

This is a dictionary because it used to be keyed by localization,  
with default the value for an unknown loc.  Now we use the  
ServicesMenu.strings file for localization, but the dictionary  
remains.


-Peter



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Saving application data in ~/Library/Application Support/

2009-02-05 Thread Gregory Weston

Shawn Erickson wrote:


On Wed, Feb 4, 2009 at 6:05 PM, Josh de Lioncourt
overl...@lioncourt.com wrote:

Hi,

I have some products under development written in C++.  I am not  
using Cocoa

for the most part, as these are cross-platform projects.


Review...

http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/LowLevelFileMgmt/Tasks/LocatingDirectories.html


Also of value are

http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/Articles/WhereToPutFiles.html 



and (linked from that page)

http://developer.apple.com/documentation/MacOSX/Conceptual/BPFileSystem/Articles/LibraryDirectory.html 



I note the OP was considering, for example, putting preferences in the  
Application Support directory. But there's already a place for those,  
and users know where to look for them. Putting your prefs elsewhere  
will just make users angry.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CoreData migration and file change

2009-02-05 Thread Dan Grassi


I am doing the migration in
readFromURL:ofType:error:
I call: migrationManager with
	 
migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error 
:


Thus I get a new file on the migration, that seems to be the crux of  
the problem.  So I don't really understand copying the store file and  
them migrating.


I call
[self setFileURL:[NSURL fileURLWithPath:storeFilePath]];
	[self setFileModificationDate:[[fileManager  
fileAttributesAtPath:storeFilePath traverseLink:YES]  
fileModificationDate]];
and this changes the dialog message from ...changed by another  
app... to ...has been moved...


A little more info, this is 10.5 only and currently xml stores.

Thanks,

Dan



On Feb 4, 2009, at 4:14 PM, sanchezm wrote:


On Feb 4, 2009, at 12:25 PM, Dan Grassi wrote:


After having read everything I can google I have only progressed to:

The document “project.xml” has been moved.

I am doing a manual migration so I do not call  
configurePersistentStore:... as Miguel suggests but have tried  
setFileModificationDate as suggested and I only get a slightly  
better but still confusing message as above.




so where are you doing the migration?
If you're moving the document during your manual migration, I might  
suggest copying it and then migrating over the original copy.


- Miguel



I have tried FSExchangeObjects but that did not help.

I have not tried moving the migration code to a -writeToURL: or -  
saveToURL: method and calling that if I need to migrate, surely  
there is a less convoluted way.



Any help will be greatly appreciated.

Dan



On Feb 4, 2009, at 12:42 PM, Barry Wark wrote:


I recently asked a related question on StackOverflow:
http://stackoverflow.com/questions/380076/manual-core-data-schema-migration-without-document-changed-warning 
.

The answer should help you out.

On Tue, Feb 3, 2009 at 9:08 AM, Dan Grassi d...@marware.com wrote:
I have a CoreData application and am migrating the data store.   
When the
user opens an old store the migration happens automatically  
creating a new
file.  The problem is when the user saves the first time after  
the migration
he gets the message: This document's file has been changed by  
another

application since you opened or saved it.

What is the correct procedure for handling the file change or how  
can I

avoid this message?

Thanks,

Dan

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/sanchezm95%40gmail.com

This email sent to sanchez...@gmail.com




smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Full Screen Mode With MenuBar

2009-02-05 Thread Sean McBride
On 2/4/09 8:26 PM, Adam Gerson said:

I am looking to implement a fullscreen window while showing the
menubar. The consensus is that NSView's enterFullScreenMode is buggy
and doesn't support showing the menu bar.

True.

What is the alternative? Are
there any good examples out there? I have done many google searches
and read through the archives. Looks like many have asked, but an
exact answer is hard to come by.

Not sure how you do your searching, but there was a nice summary posted
just a few hours before your question:
http://www.cocoabuilder.com/archive/message/cocoa/2009/2/4/229467

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Interface Builder Nested Object Selection

2009-02-05 Thread Richard Somers

Joey and Jonathan,

Hey guys thanks for the tips! I had no idea this functionality was  
available in Interface Builder.


Richard

On Feb 4, 2009, at 6:36PM, Joey Hagedorn wrote:

One tip that you might find helpful to select nested items quickly  
in Interface Builder is to hold down Shift + Control when clicking.  
This brings up a menu of selectable items under the mouse. You can  
directly select the item you want on the first try with this method.


On Feb 4, 2009, at 6:37PM, Jonathan Hess wrote:

Try shift-right-click or shift-control-left-click to see a  
context menu of everything under the mouse.


Alternatively, see the Tools-Select Parent menu item with a key  
equivalent of command+control+Up Arrow.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Memory management question in Objective-C 2.0 @property notation

2009-02-05 Thread Bryan Henry
No, you do need to release it. You should release the ivars for any  
retain or copy-type properties in your -dealloc implementation. Is  
your property was just an assign property, then you would not need to  
release it in -dealloc.


Also - a common mistake when using properties is to set the ivar, but  
not use the property setter.


This:   name = [NSString string];
is very different from this:self.name = [NSString string];
as the latter is equivalent to: [self setName:[NSString string]];

Bryan

P.S. Why isn't cocoa-dev@lists.apple.com set as the Reply-To header  
for emails to the list? I know other people must make the mistake of  
hitting Reply instead of Reply All.


On Feb 5, 2009, at 3:21 AM, Devraj Mukherjee wrote:


Thanks again both of you.

assuming that I do self.name = [NSString string] and since it the
NSString helper message, I shouldn't have to release that in my
dealloc implementation.

Or am I understanding this incorrectly.

On Thu, Feb 5, 2009 at 5:01 PM, Kiel Gillard  
kiel.gill...@gmail.com wrote:

On 05/02/2009, at 4:20 PM, Chris Suter wrote:

On Thu, Feb 5, 2009 at 4:10 PM, Kiel Gillard  
kiel.gill...@gmail.com wrote:


However, doing this will yield a memory leak:

self.name = [[NSString alloc] init];

...because the property definition tells the compiler the methods it

synthesizes should retain the value.

You're right that it will leak in that case but you've given the  
wrong

reason as to why. Memory management rules are covered by Apple's
documentation.

Regards,

Chris

Thanks for your reply, Chris.
I suggest that the code quoted above will yield a memory leak  
because the

NSString instance allocated will have a retain count of two after the
setName: message has be sent to self. To correct this error, I  
suggest that

the code should read:
self.name = [[[NSString alloc] init] autorelease];
Under the heading of Setter Semantics
of http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_5_section_3.html#//apple_ref/doc/uid/TP30001163-CH17-SW2 
,
I can see that Apple's documentation clearly states that the  
implementation
of a property declared with a retain attribute will send a retain  
message to

the value given in the right hand side of the assignment.
I'm confused as to why else the memory would be leaking? Can you  
please

identify my error?
Thanks,
Kiel





--
The secret impresses no-one, the trick you use it for is everything
- Alfred Borden (The Prestiege)
___

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/bryanhenry%40mac.com

This email sent to bryanhe...@mac.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


[Q] How can one programatically begin a text editing session in a NSTextField?

2009-02-05 Thread Eric Gorr

The documentation at:

http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/TextEditing/Tasks/SetFocus.html#/ 
/apple_ref/doc/uid/2933


seems to indicate that one just needs to do:

[theWindow makeFirstResponder: theTextView];
[theTextView setSelectedRange:NSMakeRange(0,0)];

However, upon closer inspection, this seems to only apply to a  
NSTextView, not a NSTextField.
For example, NSTextField does not respond to the setSelectedRange  
message.


But, when I call makeFirstResponder on my NSTextField, it does return  
true, but an edit session is not started - I cannot type anything  
which changes the text in the field.


Thank you.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: another NSCFDictionary and GC problem?

2009-02-05 Thread Bill Bumgarner

On Feb 5, 2009, at 3:23 AM, Markus Guhe wrote:
I get the following elusive crash (about once in 20 app launches).  
It happens while decoding a dictionary using an NSKeyedUnarchiver  
from a saved file when my application starts. The value of the  
dictionary that causes this problem is an attributed string, and the  
crash only occurs if the string that's being decoded contains a non- 
text attachment (if it is an RTFD string).


This *might* be a bug in the framework, given the quite specific and  
somewhat corner case configuration required to cause it.   Or it might  
be a problem in your code that is uniquely triggered by this  
combination.


The problem only occurs if GC is turned on (and only on slower  
machines or when starting it with the standard Development profile  
from Xcode). It always occurs at this point in NSCFDictionary.


I saw the recent discussion on NSCFDictionary and GC thread on this  
list. Could this be related?


Nope -- that it is crashing NSCFDictionary is a symptom, not the  
problem.  The other issue was [most very likely] that the developer  
was using an older version of the Sparkle framework that is buggy (or  
that current Sparkle code has GC specific bugs).


I've been banging my head over this for some time now; so any help  
or hint is greatly appreciated! If this is a problem in the library:  
is there a workaround?


Please file a bug wit a binary of your application, some data you know  
crashes, and instructions for how the app should be launched to  
reproduce the issue (and send me the bug #).


http://bugreport.apple.com/

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 arch...@mail-archive.com


Re: why popupbuttoncell always select second item in tableview ?

2009-02-05 Thread Corbin Dunn


On Feb 4, 2009, at 7:47 PM, Yang Mu wrote:



How to implement difference popup items in each row in table view?

I want to make popup cell related to others. so different row show  
different pop cell.


but table view only can set datacell to column, how to set datacell  
to row?


I still suggest that you go through the examples and online  
documentation for NSTableView/NSOutlineView. In particular /Developer/ 
Examples/AppKit/DragNDropOutlineView. Your approach of creating an  
array of cells and returning the [cell objectValue] is not correct;  
create an array of data (ie: strings) and return those form your  
controller.


corbin


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Full Screen Mode With MenuBar

2009-02-05 Thread douglas welton

Adam,

How do you want to do fullscreen mode?

Do you want your window/view to take up the entire screen, except for  
the menu bar?  If so, have you tried to create a borderless window and  
resize it using [[NSScreen mainScreen] visibleFrame]?


or...

Do you want your window/view to take up the entire screen with the  
menubar appearing only when the cursor is moved into the top portion  
of the screen?  If so, have you read Tech Note 2062 about creating a  
Kiosk?


BTW, how does the Dock fit into your idea of what fullscreen mode is?

regards,

douglas

PS:  as for -enterFullScreenMode:options: being buggy, please see the  
discussion here: http://www.cocoabuilder.com/archive/message/cocoa/2009/1/6/226850 



On Feb 4, 2009, at 8:26 PM, Adam Gerson wrote:


I am looking to implement a fullscreen window while showing the
menubar. The consensus is that NSView's enterFullScreenMode is buggy
and doesn't support showing the menu bar. What is the alternative? Are
there any good examples out there? I have done many google searches
and read through the archives. Looks like many have asked, but an
exact answer is hard to come by.

Thanks,
Adam

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Confused about NSTrackingAreas with autoscroll [WORKAROUND]

2009-02-05 Thread Corbin Dunn


On Feb 4, 2009, at 5:51 PM, Luke Evans wrote:


OK, FWIW for the record here is the resolution I've arrived at:

mouseEntered and mouseExited events from tracking areas that are  
active when mouse dragging begins are dysfunctional in the drag,  
specifically when autoscrolling at the boundaries of the cliprect.   
I have a drag event loop per one of the suggested methods of handing  
drag in the Cocoa Event-Handling Guide, and start/stop NSPeriodic  
events to perform autoscrolling.


By way of a work-around, my drag loop requests these events in  
nextEventMatchingMask, but does not dispatch them.   
NSLeftMouseDragged is dispatched from the loop, and in the  
appropriate mouseDragged handler there's code to detect important  
boundary crossings (ordinarily handled by the tracking areas) that  
then sends synthetic mouseEntered and mouseExit events before  
handling the normal drag actions.  The mouseEntered and mouseExit  
methods handle all the tracking area boundary crossing in all cases  
(and were working without any special work in the case of non- 
dragging mouse moves and even dragging that didn't involve  
displacement of the view in scroll view).


Well, the trouble is, if you are consuming the event loop, then you  
need to dispatch things.


Have you seen: http://developer.apple.com/samplecode/PhotoSearch/

?

The cell consumes the event loop and dispatches events. Look at the  
code via http://developer.apple.com/samplecode/PhotoSearch/listing9.html


ie:
if ([theEvent type] == NSMouseEntered || [theEvent type] ==  
NSMouseExited) { [NSApp sendEvent:theEvent]; }
But do please log a bug; at worst, we can clarify with better  
documentation, or make it easier (somehow) with new API.



corbin


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Anyone using IKImageView/any alternatives ?

2009-02-05 Thread douglas welton
Have you tried using a CALayer or perhaps a CAScrollLayer in a layer- 
hosted view?  As for NSImageView, the things is supprots are listed in  
the documentation ;^}


On Feb 5, 2009, at 5:13 AM, Christian Graus wrote:

I am googling for example of IKImageView, and all I am finding is  
posts like

this one:
http://espresso-served-here.com/category/scribbler/

In short, lots of people are reporting that IKImageView plain does  
not work
as advertised.  Does anyone have any positive experience with this  
control ?
All I need to do is zoom and pan an image, does the NSImageView  
support

that, or is there somewhere else I should be looking ?

Thanks as always

Christian

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [Q] How can one programatically begin a text editing session in a NSTextField?

2009-02-05 Thread Andy Lee

On Feb 5, 2009, at 10:54 AM, Eric Gorr wrote:
For example, NSTextField does not respond to the setSelectedRange  
message.


[myTextField selectText:nil];

--Andy


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [Q] How can one programatically begin a text editing session in a NSTextField?

2009-02-05 Thread Eric Gorr


On Feb 5, 2009, at 10:54 AM, Eric Gorr wrote:


The documentation at:

http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/TextEditing/Tasks/SetFocus.html#/ 
/apple_ref/doc/uid/2933


seems to indicate that one just needs to do:

[theWindow makeFirstResponder: theTextView];
[theTextView setSelectedRange:NSMakeRange(0,0)];

However, upon closer inspection, this seems to only apply to a  
NSTextView, not a NSTextField.
For example, NSTextField does not respond to the setSelectedRange  
message.


But, when I call makeFirstResponder on my NSTextField, it does  
return true, but an edit session is not started - I cannot type  
anything which changes the text in the field.


Thank you.



In case it matters and in case someone can suggest something better,  
the reason why I need to do this is because I have a NSView  
(ResourceItem) which contains both a NSImageView and a NSTextField.  
You can see a picture here:


http://ericgorr.net/cocoadev/outlinetable/item.png

Now, what I will need to do eventually is be able to click and drag in  
this ResourceItem and drag the entire item elsewhere. What I noticed  
is that if I clicked in the NSTextField and started dragging, it would  
drag the text which is not the behavior I want.


So, to change this behavior, I have modified the hitTest method of  
ResourceItem to be the following:


- (NSView *) hitTest:(NSPoint)aPoint
{
NSView  *result;
NSRect  bounds  = [self bounds];

aPoint = [[self superview] convertPoint:aPoint toView:self];

result = ( NSPointInRect( aPoint, bounds ) ) ? self : nil;

return result;
}

Of course, when I do this, I can no longer click in the NSTextField  
and start typing, which is a problem.


However, the mouseDown, mouseDragged, and mouseUp methods of  
ResourceItem will get called. I figured that I could see where the  
mouse went up and if there was also a mouseDown and not a mouseDragged  
in the text field, programatically begin a text editing session in the  
NSTextField. Unfortunately, I cannot determine how do this.


But, perhaps, I need to actually use a NSTextView instead...?

Eventually, this view will be used in an entirely custom  
implementation of an outline view as pictured here:


http://ericgorr.net/cocoadev/outlinetable/outlineview.png

Sadly, it is impossible to subclass a NSTableView and NSOutlineView  
and get all of the functionality I need. It is also not possible to  
use a NSCollectionView in this situation without unacceptable behaviors.






___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [Q] How can one programatically begin a text editing session in a NSTextField?

2009-02-05 Thread Eric Gorr


On Feb 5, 2009, at 11:23 AM, Andy Lee wrote:


On Feb 5, 2009, at 10:54 AM, Eric Gorr wrote:

For example, NSTextField does not respond to the setSelectedRange
message.


[myTextField selectText:nil];


Thanks. Unfortunately, that is not quite the desired behavior as it  
causes all of the text to be selected and I want to see the blinking  
cursor. It did begin a text editing session though, so it is quite  
close.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Anyone using IKImageView/any alternatives ?

2009-02-05 Thread Jim Turner
I'm using IKImageView in an app and while it's far from being a
fully-featured control, it can do some things ok.  If all you need
to do is pan and zoom, IKImageView will work just fine.  It's when you
get into more advanced things like rotation and saving changes
where the implementation falls apart.

Stay in the shallow end of the pool and you'll be fine.  If you ever
plan on needing more than just pan and zoom, you'll be better off
looking somewhere else or just rolling your own from the start.

Jim

On Thu, Feb 5, 2009 at 4:13 AM, Christian Graus
christian.gr...@gmail.com wrote:
 I am googling for example of IKImageView, and all I am finding is posts like
 this one:
 http://espresso-served-here.com/category/scribbler/

 In short, lots of people are reporting that IKImageView plain does not work
 as advertised.  Does anyone have any positive experience with this control ?
 All I need to do is zoom and pan an image, does the NSImageView support
 that, or is there somewhere else I should be looking ?

 Thanks as always

 Christian
 ___

 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/jturner.lists%40gmail.com

 This email sent to jturner.li...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [Q] How can one programatically begin a text editing session in a NSTextField?

2009-02-05 Thread Andy Lee

On Feb 5, 2009, at 11:33 AM, Eric Gorr wrote:

[myTextField selectText:nil];


Thanks. Unfortunately, that is not quite the desired behavior as it  
causes all of the text to be selected and I want to see the blinking  
cursor. It did begin a text editing session though, so it is quite  
close.


[myTextField selectText:nil];
[[[myTextField window] fieldEditor:NO forObject:_textField2]  
setSelectedRange:NSMakeRange(0, 0)];


--Andy

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [Q] How can one programatically begin a text editing session in a NSTextField?

2009-02-05 Thread Kyle Sluder
On Thu, Feb 5, 2009 at 11:29 AM, Eric Gorr mail...@ericgorr.net wrote:
 In case it matters and in case someone can suggest something better, the
 reason why I need to do this is because I have a NSView (ResourceItem) which
 contains both a NSImageView and a NSTextField. You can see a picture here:

Maybe you should consider using NSImageCell and NSTextFieldCell
instead of subviews?

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [Q] How can one programatically begin a text editing session in a NSTextField?

2009-02-05 Thread Eric Gorr


On Feb 5, 2009, at 12:08 PM, Andy Lee wrote:



--Boundary_(ID_M0oYCC145WUCuhpk/sOO1w)
Content-type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
Content-transfer-encoding: 7BIT

On Feb 5, 2009, at 11:33 AM, Eric Gorr wrote:

[myTextField selectText:nil];


Thanks. Unfortunately, that is not quite the desired behavior as it
causes all of the text to be selected and I want to see the blinking
cursor. It did begin a text editing session though, so it is quite
close.


[myTextField selectText:nil];
[[[myTextField window] fieldEditor:NO forObject:_textField2]
setSelectedRange:NSMakeRange(0, 0)];


Excellent!

I wasn't sure what _textField2 was supposed to refer to exactly, so I  
tried this instead:


[[textField currentEditor] setSelectedRange:NSMakeRange(0, 0)];

and it worked.

Now, I just need to figure out, based on the location stored in the  
NSEvent for the mouse click, where to correctly set the selection.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [Q] How can one programatically begin a text editing session in a NSTextField?

2009-02-05 Thread Eric Gorr


On Feb 5, 2009, at 12:15 PM, Kyle Sluder wrote:

On Thu, Feb 5, 2009 at 11:29 AM, Eric Gorr mail...@ericgorr.net  
wrote:
In case it matters and in case someone can suggest something  
better, the
reason why I need to do this is because I have a NSView  
(ResourceItem) which
contains both a NSImageView and a NSTextField. You can see a  
picture here:


Maybe you should consider using NSImageCell and NSTextFieldCell
instead of subviews?


Sadly, can't use cells. Believe me, I tried my best working with DTS  
as well.


They have undesirable behaviors associated with them that I do not  
have control over. Basically, if you need to do something custom with  
them that doesn't involve only changing the look, they likely aren't  
for you. I somehow managed to hit their limitations rather quickly  
even though I didn't think I was trying to do anything particularly  
uncommon.


Furthermore, considering that some of the newest controls, like  
NSCollectionView, etc. are not based on the Control/Cell pattern, it  
would seem that Apple is moving away from them too and making NSView's  
efficient enough that the problems described by Hillegass in his Cocoa  
book, which lead to the creation of NSCell's, are going away.







___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Encoding to use for file names

2009-02-05 Thread Francis Devereux

Hi,

I am porting an app to Mac OS X (well, actually someone else has  
ported it and I am building a cocoa GUI).


I have an NSString with a filename in it that I need to pass to the  
portable code as a char *.  The portable code will then pass it to  
UNIX file handling functions like fopen().


I guess that I need to use NSString's getCString:maxLength:encoding:  
method, but what should I pass for the encoding parameter?  Phrased  
another way, what encoding does fopen() expect filenames to be in?


Thanks,

Francis
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [Q] How can one programatically begin a text editing session in a NSTextField?

2009-02-05 Thread Andy Lee

On Feb 5, 2009, at 12:17 PM, Eric Gorr wrote:

I wasn't sure what _textField2 was supposed to refer to exactly,


Oops, copy-paste error. :)


so I tried this instead:

[[textField currentEditor] setSelectedRange:NSMakeRange(0, 0)];


Bah, currentEditor is what I was trying to remember.

--Andy

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Encoding to use for file names

2009-02-05 Thread David Springer
I generally use UTF8.

On Thu, Feb 5, 2009 at 10:29 AM, Francis Devereux fran...@devrx.org wrote:

 Hi,

 I am porting an app to Mac OS X (well, actually someone else has ported it
 and I am building a cocoa GUI).

 I have an NSString with a filename in it that I need to pass to the
 portable code as a char *.  The portable code will then pass it to UNIX file
 handling functions like fopen().

 I guess that I need to use NSString's getCString:maxLength:encoding:
 method, but what should I pass for the encoding parameter?  Phrased another
 way, what encoding does fopen() expect filenames to be in?

 Thanks,

 Francis
 ___

 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/dspringer%40google.com

 This email sent to dsprin...@google.com




-- 
http://go/OnlyCheckEmailTwiceADay - join the movement
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [Q] How can one programatically begin a text editing session in a NSTextField?

2009-02-05 Thread Eric Gorr


On Feb 5, 2009, at 12:33 PM, Andy Lee wrote:


On Feb 5, 2009, at 12:17 PM, Eric Gorr wrote:

I wasn't sure what _textField2 was supposed to refer to exactly,


Oops, copy-paste error. :)


so I tried this instead:

[[textField currentEditor] setSelectedRange:NSMakeRange(0, 0)];


Bah, currentEditor is what I was trying to remember.


:-)

So, if you know of an easy way to determine the location in the string  
of a NSTextField where a click occurred, I am interested.


Or a better way, which works around this whole mess, to accomplish  
what I described in:


http://lists.apple.com/archives/cocoa-dev/2009/Feb/msg00341.html

I would be interested in that 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 arch...@mail-archive.com


Re: Encoding to use for file names

2009-02-05 Thread Joar Wingfors


On Feb 5, 2009, at 9:29 AM, Francis Devereux wrote:

I am porting an app to Mac OS X (well, actually someone else has  
ported it and I am building a cocoa GUI).


I have an NSString with a filename in it that I need to pass to the  
portable code as a char *.  The portable code will then pass it to  
UNIX file handling functions like fopen().


I guess that I need to use NSString's getCString:maxLength:encoding:  
method, but what should I pass for the encoding parameter?  Phrased  
another way, what encoding does fopen() expect filenames to be in?



The correct thing to do would be to use:

-[NSString fileSystemRepresentation]

	http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/fileSystemRepresentation 



j o a r


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Encoding to use for file names

2009-02-05 Thread Shawn Erickson
On Thu, Feb 5, 2009 at 9:29 AM, Francis Devereux fran...@devrx.org wrote:

 I guess that I need to use NSString's getCString:maxLength:encoding: method,
 but what should I pass for the encoding parameter?  Phrased another way,
 what encoding does fopen() expect filenames to be in?

-[NSString fileSystemRepresentation]

-Shawn
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Encoding to use for file names

2009-02-05 Thread Nick Zitzmann


On Feb 5, 2009, at 10:29 AM, Francis Devereux wrote:

I have an NSString with a filename in it that I need to pass to the  
portable code as a char *.  The portable code will then pass it to  
UNIX file handling functions like fopen().


I guess that I need to use NSString's getCString:maxLength:encoding:  
method, but what should I pass for the encoding parameter?  Phrased  
another way, what encoding does fopen() expect filenames to be in?



You guessed incorrectly, actually. Always use - 
fileSystemRepresentation or -getFileSystemRepresentation:maxLength:. - 
UTF8String will incidentally work for HFS+ and UFS, but it probably  
won't work with legacy file systems that don't support Unicode, such  
as HFS.


Nick Zitzmann
http://www.chronosnet.com/

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Encoding to use for file names

2009-02-05 Thread Douglas Davidson


On Feb 5, 2009, at 9:33 AM, David Springer wrote:


I generally use UTF8.

On Thu, Feb 5, 2009 at 10:29 AM, Francis Devereux  
fran...@devrx.org wrote:



Hi,

I am porting an app to Mac OS X (well, actually someone else has  
ported it

and I am building a cocoa GUI).

I have an NSString with a filename in it that I need to pass to the
portable code as a char *.  The portable code will then pass it to  
UNIX file

handling functions like fopen().

I guess that I need to use NSString's getCString:maxLength:encoding:
method, but what should I pass for the encoding parameter?  Phrased  
another

way, what encoding does fopen() expect filenames to be in?




The POSIX layer does indeed use a form of UTF-8, but the correct  
answer here is -fileSystemRepresentation or - 
getFileSystemRepresentation:maxLength:, which insulate you from the  
need to hard-code the encoding.


Also noted in the reference for this method:  To convert a char *  
path (such as you might get from a C library routine) to an NSString  
object, use NSFileManager‘s stringWithFileSystemRepresentation:length:  
method.


Douglas Davidson

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Encoding to use for file names

2009-02-05 Thread glenn andreas


On Feb 5, 2009, at 11:29 AM, Francis Devereux wrote:


Hi,

I am porting an app to Mac OS X (well, actually someone else has  
ported it and I am building a cocoa GUI).


I have an NSString with a filename in it that I need to pass to the  
portable code as a char *.  The portable code will then pass it to  
UNIX file handling functions like fopen().


I guess that I need to use NSString's getCString:maxLength:encoding:  
method, but what should I pass for the encoding parameter?  Phrased  
another way, what encoding does fopen() expect filenames to be in?



Don't use getCString:maxLenght:encoding: - use NSString's  
fileSystemRepresentation - it will do the right thing for encoding,  
surrogate pairs, decomposition, etc...


Glenn Andreas  gandr...@gandreas.com
 http://www.gandreas.com/ wicked fun!
JSXObjC | the easy way to unite JavaScript and Objective C




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Encoding to use for file names

2009-02-05 Thread Clark Cox
Just use:

const char *filename = [nsstring fileSystemRepresentation];

On Thu, Feb 5, 2009 at 9:29 AM, Francis Devereux fran...@devrx.org wrote:
 Hi,

 I am porting an app to Mac OS X (well, actually someone else has ported it
 and I am building a cocoa GUI).

 I have an NSString with a filename in it that I need to pass to the portable
 code as a char *.  The portable code will then pass it to UNIX file handling
 functions like fopen().

 I guess that I need to use NSString's getCString:maxLength:encoding: method,
 but what should I pass for the encoding parameter?  Phrased another way,
 what encoding does fopen() expect filenames to be in?

 Thanks,

 Francis
 ___

 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/clarkcox3%40gmail.com

 This email sent to clarkc...@gmail.com




-- 
Clark S. Cox III
clarkc...@gmail.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Encoding to use for file names

2009-02-05 Thread Francis Devereux

On 5 Feb 2009, at 17:40, Joar Wingfors wrote:


On Feb 5, 2009, at 9:29 AM, Francis Devereux wrote:

I am porting an app to Mac OS X (well, actually someone else has  
ported it and I am building a cocoa GUI).


I have an NSString with a filename in it that I need to pass to the  
portable code as a char *.  The portable code will then pass it to  
UNIX file handling functions like fopen().


I guess that I need to use NSString's  
getCString:maxLength:encoding: method, but what should I pass for  
the encoding parameter?  Phrased another way, what encoding does  
fopen() expect filenames to be in?



The correct thing to do would be to use:

-[NSString fileSystemRepresentation]

	http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/occ/instm/NSString/fileSystemRepresentation 



[NSString fileSystemRepresentation] works great, thanks to all who  
replied.


Francis
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [Q] How can one programatically begin a text editing session in a NSTextField?

2009-02-05 Thread Eric Gorr


On Feb 5, 2009, at 12:39 PM, Eric Gorr wrote:



On Feb 5, 2009, at 12:33 PM, Andy Lee wrote:


On Feb 5, 2009, at 12:17 PM, Eric Gorr wrote:

I wasn't sure what _textField2 was supposed to refer to exactly,


Oops, copy-paste error. :)


so I tried this instead:

[[textField currentEditor] setSelectedRange:NSMakeRange(0, 0)];


Bah, currentEditor is what I was trying to remember.


:-)

So, if you know of an easy way to determine the location in the  
string of a NSTextField where a click occurred, I am interested.


This actually turned out to be fairly easy:

NSTextView  *currentEditor  = (NSTextView*)[textField currentEditor];
NSPoint windowLocation  = [theEvent locationInWindow];
NSPoint		screenLocation	= [[self window]  
convertBaseToScreen:windowLocation];
NSUInteger	characterIndex	= [currentEditor  
characterIndexForPoint:screenLocation];


[currentEditor setSelectedRange:NSMakeRange(characterIndex + 1, 0)];

Woo Hoo

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Saving application data in ~/Library/Application Support/

2009-02-05 Thread Josh de Lioncourt


On Feb 5, 2009, at 4:49 AM, Mike Abdullah wrote:
Please, please, please do not store preferences in ~/Library/ 
Application Support/

They should go in ~/Library/Preferences
Everything else is fine to go in app support.

Apple provides both NSUserDefaults and CFPreferences APIs for  
storing your prefs, although you could do it manually if you really  
wish.


There are several reasons we're not doing it this way.  One is that  
our application data will be stored in a customized format that is  
*not* a .plist file, because we need to maintain cross-platform  
support.  Yes, I know that technically I could write WIndows code to  
parse the .plist, but the better, simpler solution for our specific  
situation is customized data files.  It doesn't seem wise to me to  
store non-.plist files in ~/Library/Preferences.  Believe me, I'm very  
familiar with Mac. I actually realy dislike Windows, and if I could  
drop cross-platform necessities, I would. :)


I've never seen anything that promoted the idea of storing non- 
standard data files in that folder.  If there's a good argument for  
it, please enlighten me.


Josh de Lioncourt
Mac-cessibility: http://www.Lioncourt.com
Twitter: http://twitter.com/Lioncourt


The rich declare themselves poor,
And most of us are not sure,
If we have too much,
But we'll take our chances,
'cause God stopped keeping score.
Praying for Time--George Michael






___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Open OtherApp just behind MyApp

2009-02-05 Thread Ken Thomases

On Feb 5, 2009, at 2:31 AM, Yang Meyer wrote:

Thanks for pointing out the potential cause. I read up on Obj-C  
trampoline methods/objects (pretty cool, actually!) and understand  
the basic idea, but honestly I'm not seeing the connection to my  
problem. Why and how would such a trampoline object help in delaying  
the call to -activateIgnoringOtherApps:? Could you maybe sketch out  
how the trampoline might look?


Sorry.  In this case I wasn't referring to any specific technique.  By  
trampoline I just meant a method that did have the appropriate  
signature to be invoked by performSelector:withObject:afterDelay:.   
For example, one which takes no arguments and then turns around and  
invokes [self activateIgnoringOtherApps:YES].


Regards,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Saving application data in ~/Library/Application Support/

2009-02-05 Thread I. Savant
On Thu, Feb 5, 2009 at 1:21 PM, Josh de Lioncourt
overl...@lioncourt.com wrote:

 There are several reasons we're not doing it this way.  One is that our
 application data will be stored in a customized format that is *not* a
 .plist file, because we need to maintain cross-platform support.  Yes, I
 know that technically I could write WIndows code to parse the .plist, but
 the better, simpler solution for our specific situation is customized data
 files.  It doesn't seem wise to me to store non-.plist files in
 ~/Library/Preferences.  Believe me, I'm very familiar with Mac. I actually
 realy dislike Windows, and if I could drop cross-platform necessities, I
 would. :)

  Your reasoning doesn't quite seem ... reasonable to me. :-)

  Specifically, when would your Windows version be reading the Mac
version's preferences and vice-versa? Presumably your user has *data*
they wish to share between their Mac and their Windows computers,
which is one thing, but the *preferences* are specific to the app /
machine (and even more specifically, the user), right? Why not use
each platform's native preferences/settings interfaces to store this
information where it belongs?

--
I.S.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Saving application data in ~/Library/Application Support/

2009-02-05 Thread Sean McBride
On 2/5/09 10:21 AM, Josh de Lioncourt said:

It doesn't seem wise to me to
store non-.plist files in ~/Library/Preferences.

I disagree.  The Mac OS had a standard Preferences folder since at least
System 7 and in those days we didn't have the CFPreferences API and apps
stored prefs in that folder in whatever format they wanted.  You should
store your prefs in Library/Preferences even if you use your own format.

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Encoding to use for file names

2009-02-05 Thread Clark Cox
On Thu, Feb 5, 2009 at 9:41 AM, Nick Zitzmann n...@chronosnet.com wrote:

 On Feb 5, 2009, at 10:29 AM, Francis Devereux wrote:

 I have an NSString with a filename in it that I need to pass to the
 portable code as a char *.  The portable code will then pass it to UNIX file
 handling functions like fopen().

 I guess that I need to use NSString's getCString:maxLength:encoding:
 method, but what should I pass for the encoding parameter?  Phrased another
 way, what encoding does fopen() expect filenames to be in?


 You guessed incorrectly, actually. Always use -fileSystemRepresentation or
 -getFileSystemRepresentation:maxLength:.

While fileSystemRepresentation is the correct call to use, ...

 -UTF8String will incidentally work
 for HFS+ and UFS, but it probably won't work with legacy file systems that
 don't support Unicode, such as HFS.

... this is not correct. The encoding of strings passed to the
POSIX/BSD layer of the OS does not change based on the filesystem.
Passing a UTF-8 string to open() will work just fine on HFS, FAT-32,
UFS, whatever.

The point of using fileSystemRepresentation is to protect you against
changes in the future (i.e. if some new, UTF-better encoding comes
out, and Apple ever decides to use that encoding for their BSD calls.)

-- 
Clark S. Cox III
clarkc...@gmail.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Saving application data in ~/Library/Application Support/

2009-02-05 Thread Mike Abdullah


On 5 Feb 2009, at 18:29, I. Savant wrote:


On Thu, Feb 5, 2009 at 1:21 PM, Josh de Lioncourt
overl...@lioncourt.com wrote:

There are several reasons we're not doing it this way.  One is that  
our
application data will be stored in a customized format that is  
*not* a
.plist file, because we need to maintain cross-platform support.   
Yes, I
know that technically I could write WIndows code to parse  
the .plist, but
the better, simpler solution for our specific situation is  
customized data

files.  It doesn't seem wise to me to store non-.plist files in
~/Library/Preferences.  Believe me, I'm very familiar with Mac. I  
actually
realy dislike Windows, and if I could drop cross-platform  
necessities, I

would. :)


 Your reasoning doesn't quite seem ... reasonable to me. :-)

 Specifically, when would your Windows version be reading the Mac
version's preferences and vice-versa? Presumably your user has *data*
they wish to share between their Mac and their Windows computers,
which is one thing, but the *preferences* are specific to the app /
machine (and even more specifically, the user), right? Why not use
each platform's native preferences/settings interfaces to store this
information where it belongs?


I think this reasoning makes even more sense when you consider those  
users out there having MobileMe synchronise their preferences. With  
your custom approach, this would break, against the user's expectations.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Confused about NSTrackingAreas with autoscroll [WORKAROUND]

2009-02-05 Thread Luke Evans

Hi Corbin.  Thanks for the note.

Well, the trouble is, if you are consuming the event loop, then you  
need to dispatch things.


Have you seen: http://developer.apple.com/samplecode/PhotoSearch/

?


Yes, I studied this before I started and used the patterns in there.

The cell consumes the event loop and dispatches events. Look at the  
code via http://developer.apple.com/samplecode/PhotoSearch/listing9.html


ie:
if ([theEvent type] == NSMouseEntered || [theEvent type] ==  
NSMouseExited) { [NSApp sendEvent:theEvent]; }
But do please log a bug; at worst, we can clarify with better  
documentation, or make it easier (somehow) with new API.



corbin



Absolutely.  I was dispatching NSMouseEntered, NSMouseExited and  
NSLeftMouseDrag.
This was all working perfectly until I added code to do the  
autoscrolling.  I used NSPeriodic for this (which I also tried  
dispatching, seeing as I was consuming it), and had the appropriate  
call to scroll the view on receipt of the periodic events.  At that  
point I found the tracking areas to be out of place with respect to  
the displacement of the view.


-- lwe


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Getting *my* object out of a tree controller?

2009-02-05 Thread Randall Meadows

I have an NSOutlineView backed by an NSTreeController.

selectedObject = [[treeController selectedObjects] objectAtIndex:n]

gives me back an object (of the type) that I expect. However, when I  
then try to find where that object lives in the tree


[treeView rowForItem:selectedObject]

returns -1 (not found).  I ultimately need to remove the object from  
the tree controller (using -removeObjectAtArrangedObjectIndexPath:  
presumably), but how do I get an index path to an object when I have  
*just* a pointer to that object?  I can get an index path to the  
selection, but in this case, the object to be deleted may not actually  
be selected in the view.  Based on the stuff I discovered below, I  
assume I need to be searching for the tree node representation of my  
object?  How do I get that just from the object itself?  Or do I need  
to remember that tree node information at the same time I get a handle  
to the object?


Thanks!
randy

-
OK, I figured out the following part: NSTreeControllerTreeNode must be  
a NSTreeNode, on which I can call -representedObject, which returns me  
an object of the type I expect; I left the rest in here in case I'm  
mistaken somehow, someone can set me straight.


Even when I query the tree controller directly for its items, I don't  
get *my* object types back, but rather NSTreeControllerTreeNodes:


(gdb) po [treeView itemAtRow:1]
NSTreeControllerTreeNode: 0x2a4a00, child nodes {}
(gdb) po [treeView itemAtRow:0]
NSTreeControllerTreeNode: 0x2d82b0, child nodes {	 
0:NSTreeControllerTreeNode: 0x2a4a00, child nodes {}

1:NSTreeControllerTreeNode: 0x2a4fb0, child nodes {}
}

Not only can I not find any documentation on this type, I can't even  
cmd-double-click or search to find *any* mention of it at all.   
Casting that to my object type was an exercise in futility (what was  
displayed was obviously not a valid object).

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [Q] How can one programatically begin a text editing session in a NSTextField?

2009-02-05 Thread Michael Ash
On Thu, Feb 5, 2009 at 12:39 PM, Eric Gorr mail...@ericgorr.net wrote:

 On Feb 5, 2009, at 12:33 PM, Andy Lee wrote:

 On Feb 5, 2009, at 12:17 PM, Eric Gorr wrote:

 I wasn't sure what _textField2 was supposed to refer to exactly,

 Oops, copy-paste error. :)

 so I tried this instead:

 [[textField currentEditor] setSelectedRange:NSMakeRange(0, 0)];

 Bah, currentEditor is what I was trying to remember.

 :-)

 So, if you know of an easy way to determine the location in the string of a
 NSTextField where a click occurred, I am interested.

 Or a better way, which works around this whole mess, to accomplish what I
 described in:

 http://lists.apple.com/archives/cocoa-dev/2009/Feb/msg00341.html

 I would be interested in that as well.

Let me see if I understand this correctly. You have a text field in a
view. You want to be able to drag the mouse anywhere in the view
without editing the text field, but you want to be able to click on
the text field to edit it, right?

Seems to me that the simplest solution would be to just selectively
forward events to the text field. Something like this in your view:

- (void)mouseDown:(NSEvent *)event {
[self setLastMouseDownEvent:event]; // this is just a setter for an ivar
}
- (void)mouseDragged:(NSEvent *)event {
[self setLastMouseDownEvent:nil];
/* do whatever it is that you do here */
}
- (void)mouseUp:(NSEvent *)event {
NSEvent *mouseDown = [self lastMouseDownEvent];
if(mouseDown) {
[NSApp postEvent:event atStart:YES];
[_textField mouseDown:mouseDown];
}
}

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 arch...@mail-archive.com


[moderator] Re: AquaticPrime Config.php + PayPal Advanced Variables Not Working

2009-02-05 Thread Scott Anguish
please take this discussion to either the creator of the AquaticPrime  
system or to the macsb (mac small business) list.



On 3-Feb-09, at 7:21 PM, Chunk 1978 wrote:


i have AquaticPrime set up with PayPal for a small software license
that i sell maybe once every 2 months.  i'm releasing something new
soon and i'm trying to customize the AquaticPrime .PHP scripts to
handle the production and emailing of 2 different licenses depending
on what the customer is buying.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Getting *my* object out of a tree controller?

2009-02-05 Thread Kyle Sluder
On Thu, Feb 5, 2009 at 3:36 PM, Randall Meadows cocoa-...@not-pc.com wrote:
 Even when I query the tree controller directly for its items, I don't get
 *my* object types back, but rather NSTreeControllerTreeNodes:

Why does this surprise you?  The outline view's data source (the tree
controller) is providing instances of NSTreeControllerTreeNode (which
is a private internal subclass of NSTreeNode), so the outline view is
going to give these back to you.

See http://www.cocoabuilder.com/archive/message/cocoa/2008/6/8/209677 .

--Kyle Sluder
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Saving application data in ~/Library/Application Support/

2009-02-05 Thread Andrew Farmer

On 05 Feb 09, at 10:21, Josh de Lioncourt wrote:
I've never seen anything that promoted the idea of storing non- 
standard data files in that folder.  If there's a good argument for  
it, please enlighten me.


Many Carbon applications (especially older ones) store preferences in  
~/Library/Preferences using custom file formats. This isn't by any  
means limited to older apps, though - for example, com.apple.dock.db  
was added in Leopard. :)


Short version, there's never been any requirement on what format you  
store your preferences in. Using plists simplifies some things, but it  
isn't mandatory.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Memory management question in Objective-C 2.0 @property notation

2009-02-05 Thread Kiel Gillard

Thanks mmalc, that clears things up for me.

On 05/02/2009, at 8:08 PM, mmalc Crawford wrote:



On Feb 4, 2009, at 10:01 PM, Kiel Gillard wrote:

I'm confused as to why else the memory would be leaking? Can you  
please identify my error?



The error is in your explanation.


However, doing this will yield a memory leak:
self.name = [[NSString alloc] init];
...because the property definition tells the compiler the methods  
it synthesizes should retain the value.


This is not a memory leak because the property definition tells the  
compiler the methods it synthesizes should retain the value; it is  
a leak because you're not abiding by the memory management rules.   
You're creating an object you own (alloc), and not relinquishing  
ownership.
(See http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html 
 for full details.)


There are several ways to remedy the problem; the overall best  
practice approach is:


NSString *aString = [[NSString alloc] init];
self.name = aString;
[aString release];


I suggest that the code quoted above will yield a memory leak  
because the NSString instance allocated will have a retain count of  
two


Explaining memory management at this level in terms of retain counts  
is a leap down the wrong path.


mmalc

___

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/kiel.gillard%40gmail.com

This email sent to kiel.gill...@gmail.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Confused about NSTrackingAreas with autoscroll [WORKAROUND]

2009-02-05 Thread Corbin Dunn


The cell consumes the event loop and dispatches events. Look at the  
code via http://developer.apple.com/samplecode/PhotoSearch/listing9.html


ie:
if ([theEvent type] == NSMouseEntered || [theEvent type] ==  
NSMouseExited) { [NSApp sendEvent:theEvent]; }
But do please log a bug; at worst, we can clarify with better  
documentation, or make it easier (somehow) with new API.



corbin



Absolutely.  I was dispatching NSMouseEntered, NSMouseExited and  
NSLeftMouseDrag.
This was all working perfectly until I added code to do the  
autoscrolling.  I used NSPeriodic for this (which I also tried  
dispatching, seeing as I was consuming it), and had the appropriate  
call to scroll the view on receipt of the periodic events.  At that  
point I found the tracking areas to be out of place with respect to  
the displacement of the view.


Definitely log a bug on this issue. I suspect you may need a way of  
informing tracking areas to lazily update, and for them to update when  
scrolling. Thanks!


corbin


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Transparency with PNG on NSImageView

2009-02-05 Thread Damien Cooke

Hi All,
I have what is probably a stupid problem. In my window I have a  
background NSImageView and I want to pop another much smaller one on  
top.  The one I am putting on top is a png with transparencies.  When  
I do this I get a rectangular image over my background but what I want  
to see is only the non transparent parts of my image.  I have set the  
background colour of my image via [image setBackgroundColor:[NSColor  
clearColor]] but I am perplexed with the spectacular lack of any change.


I feel I am completely on the wrong path.  Can someone point me in the  
right direction?


Regards
Damien


If you can't be kind, at least have the decency to be vague.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


How to transform a NSString to a NSString C string format?

2009-02-05 Thread Iceberg-Dev

Problem:


I would like to transform a NSString to a NSString conforming to the  
C string format.


Examples:
-

toto - toto

toto - \toto

toto   - toto\ntiti
titi


My Current Solution:


I can do this using a NSMutableString and a series of call to:

- replaceOccurrencesOfString:withString:options:range:

The problem I see with this solution is that I will probably forget  
some cases.


Question:
-

Would there be a better solution? (I couldn't find a method in  
NSString, NSMutableString CFStringRef APIs but I might missed it).



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Transparency with PNG on NSImageView

2009-02-05 Thread David Blanton

I do this to composite one image over another:

CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextClearRect(ctx, rect);  
CGContextDrawImage(ctx, rect, _meterImages[0]);
CGContextSetBlendMode (ctx, kCGBlendModeNormal);
CGContextDrawImage(ctx, rect, _meterImages[1]);

(iPhone example but the only difference I think is  
UIGraphicsGetCurrentContext)



On Feb 5, 2009, at 3:28 PM, Damien Cooke wrote:


Hi All,
I have what is probably a stupid problem. In my window I have a  
background NSImageView and I want to pop another much smaller one  
on top.  The one I am putting on top is a png with transparencies.   
When I do this I get a rectangular image over my background but  
what I want to see is only the non transparent parts of my image.   
I have set the background colour of my image via [image  
setBackgroundColor:[NSColor clearColor]] but I am perplexed with  
the spectacular lack of any change.


I feel I am completely on the wrong path.  Can someone point me in  
the right direction?


Regards
Damien


If you can't be kind, at least have the decency to be vague.



___

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/airedale% 
40tularosa.net


This email sent to aired...@tularosa.net




David Blanton





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Transparency with PNG on NSImageView

2009-02-05 Thread Damien Cooke
I create a new NSImageView and load it with the image then display the  
NSImageView


Damien


On 06/02/2009, at 9:13 AM, Randall Meadows wrote:


On Feb 5, 2009, at 3:28 PM, Damien Cooke wrote:


Hi All,
I have what is probably a stupid problem. In my window I have a  
background NSImageView and I want to pop another much smaller one  
on top.  The one I am putting on top is a png with transparencies.   
When I do this I get a rectangular image over my background but  
what I want to see is only the non transparent parts of my image.   
I have set the background colour of my image via [image  
setBackgroundColor:[NSColor clearColor]] but I am perplexed with  
the spectacular lack of any change.


How are you drawing the top image?


We act as though comfort and luxury were the chief requirements of  
life, when all that we need to make us happy is something to be  
enthusiastic about.


-- Albert Einstein




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to transform a NSString to a NSString C string format?

2009-02-05 Thread David Blanton

cStringUsingEncoding:

Returns a representation of the receiver as a C string using a given  
encoding.


- (const char *)cStringUsingEncoding:(NSStringEncoding)encoding


On Feb 5, 2009, at 3:52 PM, Iceberg-Dev wrote:


Problem:


I would like to transform a NSString to a NSString conforming to  
the C string format.


Examples:
-

toto - toto

toto - \toto

toto   - toto\ntiti
titi


My Current Solution:


I can do this using a NSMutableString and a series of call to:

- replaceOccurrencesOfString:withString:options:range:

The problem I see with this solution is that I will probably forget  
some cases.


Question:
-

Would there be a better solution? (I couldn't find a method in  
NSString, NSMutableString CFStringRef APIs but I might missed it).



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/airedale% 
40tularosa.net


This email sent to aired...@tularosa.net




David Blanton





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to transform a NSString to a NSString C string format?

2009-02-05 Thread Luke the Hiesterman

easiest for most cases to use [myString UTF8String].

Luke

On Feb 5, 2009, at 2:55 PM, David Blanton wrote:


cStringUsingEncoding:

Returns a representation of the receiver as a C string using a given  
encoding.


- (const char *)cStringUsingEncoding:(NSStringEncoding)encoding


On Feb 5, 2009, at 3:52 PM, Iceberg-Dev wrote:


Problem:


I would like to transform a NSString to a NSString conforming to  
the C string format.


Examples:
-

toto - toto

toto - \toto

toto   - toto\ntiti
titi


My Current Solution:


I can do this using a NSMutableString and a series of call to:

- replaceOccurrencesOfString:withString:options:range:

The problem I see with this solution is that I will probably forget  
some cases.


Question:
-

Would there be a better solution? (I couldn't find a method in  
NSString, NSMutableString CFStringRef APIs but I might missed it).



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/airedale%40tularosa.net

This email sent to aired...@tularosa.net




David Blanton





___

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/luketheh%40apple.com

This email sent to luket...@apple.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


underlining

2009-02-05 Thread Eric Slosser
I'm trying to draw underlined strings, but they come out wrong when  
the font is bold.  So I made a sample app from the Cocoa template, and  
added a custom view to the main window.  The code is below.  But the  
output doesn't underline correctly.  What am I doing wrong?








NSTextStorage* getTextStorage() {

if( !s_textStorage ){

s_textStorage = [[NSTextStorage alloc] init];
NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
NSTextContainer *textContainer = [[NSTextContainer alloc] init];
[layoutManager addTextContainer:textContainer];
[textContainer release];
[s_textStorage addLayoutManager:layoutManager];
[layoutManager release];
}
return s_textStorage;
}

- (void)drawRect:(NSRect)rect {

int fontSize = 41;
NSFontManager* fontManager = [NSFontManager sharedFontManager];
NSFont* boldFont = [fontManager fontWithFamily:@Arial traits:0  
weight:5 size:fontSize];
//boldFont = [fontManager convertFont:font  
toHaveTrait:NSBoldFontMask];



NSMutableDictionary* attr = [NSMutableDictionary  
dictionaryWithObject:font forKey:NSFontAttributeName];
[attr setObject:[NSNumber numberWithInt:NSSingleUnderlineStyle]  
forKey:NSUnderlineStyleAttributeName];


NSAttributedString* attrString = [[NSAttributedString alloc]  
initWithString:@Sample Text attributes:attr];


NSTextStorage* textStorage = getTextStorage();
[textStorage setAttributedString:attrString];

NSLayoutManager *layoutManager = (NSLayoutManager *)[[textStorage  
layoutManagers] objectAtIndex:0];
NSTextContainer *textContainer = (NSTextContainer *) 
[[layoutManager textContainers] objectAtIndex:0];


NSPoint point = NSMakePoint( 10, 10);
NSRange glyphRange = [layoutManager  
glyphRangeForTextContainer:textContainer];
[[textContainer layoutManager] drawGlyphsForGlyphRange:  
glyphRange atPoint:point  ];

}

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Transparency with PNG on NSImageView

2009-02-05 Thread Damien Cooke

Thanks David,
I am not sure that this will work for me in this instance as the  
smaller image needs to be in a NSImageView so I can drag n'drop other  
images in there.


Regards
Damien

On 06/02/2009, at 9:22 AM, David Blanton wrote:


I do this to composite one image over another:

CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextClearRect(ctx, rect);  
CGContextDrawImage(ctx, rect, _meterImages[0]);
CGContextSetBlendMode (ctx, kCGBlendModeNormal);
CGContextDrawImage(ctx, rect, _meterImages[1]);

(iPhone example but the only difference I think is  
UIGraphicsGetCurrentContext)



On Feb 5, 2009, at 3:28 PM, Damien Cooke wrote:


Hi All,
I have what is probably a stupid problem. In my window I have a  
background NSImageView and I want to pop another much smaller one  
on top.  The one I am putting on top is a png with transparencies.   
When I do this I get a rectangular image over my background but  
what I want to see is only the non transparent parts of my image.   
I have set the background colour of my image via [image  
setBackgroundColor:[NSColor clearColor]] but I am perplexed with  
the spectacular lack of any change.


I feel I am completely on the wrong path.  Can someone point me in  
the right direction?


Regards
Damien


If you can't be kind, at least have the decency to be vague.



___

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/airedale%40tularosa.net

This email sent to aired...@tularosa.net




David Blanton







If you can't be kind, at least have the decency to be vague.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to transform a NSString to a NSString C string format?

2009-02-05 Thread Sean McBride
On 2/5/09 11:52 PM, Iceberg-Dev said:

I would like to transform a NSString to a NSString conforming to the
C string format.

Examples:
-

toto - toto

toto - \toto

toto   - toto\ntiti
titi

I think people are misunderstanding your question.  I doubt Cocoa has
any built-in functionality to turn a string into something a C compiler
would accept.  You'll have to code up this logic yourself.  Using a
mutable string seems reasonable.

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Transparency with PNG on NSImageView

2009-02-05 Thread Quincey Morris

On Feb 5, 2009, at 14:28, Damien Cooke wrote:

I have what is probably a stupid problem. In my window I have a  
background NSImageView and I want to pop another much smaller one on  
top.  The one I am putting on top is a png with transparencies.   
When I do this I get a rectangular image over my background but what  
I want to see is only the non transparent parts of my image.  I have  
set the background colour of my image via [image setBackgroundColor: 
[NSColor clearColor]] but I am perplexed with the spectacular lack  
of any change.


Make sure you're using the correct mode, probably source over. The  
default copy mode doesn't do what you might expect with transparency.


FWIW


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Needed : set class for Cocoa

2009-02-05 Thread Tommy Nordgren
Do anyone know of a set container class for Cocoa objects, that use  
pointer semantics.


Like this:
	NSMutableString  * s1 = [@Hello mutableCopy],  * s2 = [@Hello  
mutableCopy];


Somesetclass *someSet = [[Somesetclass alloc]init];
[someSet add:s1];
[someSet add: s2];
	// After these calls, someSet should contain 2 elements because s1 !=  
s2 by pointer semantics

--
Home is not where you are born, but where your heart finds peace -
Tommy Nordgren, The dying old crone
tommy.nordg...@comhem.se


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: underlining

2009-02-05 Thread Graham Cox


On 6 Feb 2009, at 10:00 am, Eric Slosser wrote:


I'm trying to draw underlined strings, but they come out wrong



In what way?

The code looks OK to me, the -drawGlyphsForGlyphRange:atPoint: claims  
it handles all the underlining, etc.


I just had a load of pain with underlining too - what is drawn by  
NSLayoutManager is different from what the font metrics returned by  
NSFont suggest are the correct sizes and offsets for underlining. It  
varies with every font. I couldn't figure out exactly how  
NSLayoutManager arrived at its underlining decisions so in the end I  
gave up and just did what NSFont told me plus some minor tweaks to  
make it come out the same as NSLayoutManager for Helvetica. Not very  
satisfactory but there is no documentation that I could find that  
explains how the metrics are to be interpreted.


Is this what you're referring to?

--Graham


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Simple memory problem

2009-02-05 Thread harry greenmonster

while([inputString isMatchedByRegex:regexString]){

range = [inputString rangeOfRegex:regexString];

	inputString = [inputString stringByReplacingCharactersInRange:range  
withString:@];


}



'inputString' is a 5mb text file, Activity Monitor shows that memory  
increases by about 9mb per iteration. Which quickly becomes a serious  
problem.


I'm a little confused as to why I have a problem. My understanding is  
that 'inputString' (on the third line) is replaced by the modified  
version of itself. I was expecting the memory footprint for the app to  
reduce in size (if anything). Obviously I have the concept  
fundamentally wrong in my head.


a pointer address when replaced by another address free's up the old  
memory location it once pointed to, no?


By the way I'm using RegexKit. And I'm a little rusty as have not  
programed the mac for some considerable time.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Needed : set class for Cocoa

2009-02-05 Thread Jordan Breeding

On 05 Feb, 2009, at 17:29, Tommy Nordgren wrote:

Do anyone know of a set container class for Cocoa objects, that use  
pointer semantics.


Like this:
	NSMutableString  * s1 = [@Hello mutableCopy],  * s2 = [@Hello  
mutableCopy];


Somesetclass *someSet = [[Somesetclass alloc]init];
[someSet add:s1];
[someSet add: s2];
	// After these calls, someSet should contain 2 elements because s1 ! 
= s2 by pointer semantics

--
Home is not where you are born, but where your heart finds peace -
Tommy Nordgren, The dying old crone
tommy.nordg...@comhem.se



NSSet/NSMutableSet

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Needed : set class for Cocoa

2009-02-05 Thread Jordan Breeding

On 05 Feb, 2009, at 17:44, Jordan Breeding wrote:


On 05 Feb, 2009, at 17:29, Tommy Nordgren wrote:

Do anyone know of a set container class for Cocoa objects, that use  
pointer semantics.


Like this:
	NSMutableString  * s1 = [@Hello mutableCopy],  * s2 = [@Hello  
mutableCopy];


Somesetclass *someSet = [[Somesetclass alloc]init];
[someSet add:s1];
[someSet add: s2];
	// After these calls, someSet should contain 2 elements because  
s1 != s2 by pointer semantics

--
Home is not where you are born, but where your heart finds peace -
Tommy Nordgren, The dying old crone
tommy.nordg...@comhem.se



NSSet/NSMutableSet


Sorry, I guess that won't help, I forgot that you said you wanted to  
store two pointers to objects with the same value.  Pretty sure that  
NSSet/NSMutableSet rely on hash and isEqual: to do their storing.

smime.p7s
Description: S/MIME cryptographic signature
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Simple memory problem

2009-02-05 Thread Graham Cox


On 6 Feb 2009, at 10:39 am, harry greenmonster wrote:

a pointer address when replaced by another address free's up the old  
memory location it once pointed to, no?


No.

It just means you orphaned the object - the memory it occupies is  
still err, occupied. However, in this case it's OK to do that in  
theory because the string returned by -stringByReplacingCharacters...  
is autoreleased, meaning that at some point the autorelease pool will  
be drained, cleaning it up. But for strings 5Mb long, you have a  
problem.


The question is, at what point? Certainly not within this while loop,  
and that's why your footprint is growing.


So, try this:

while( ... )
{
NSAutoreleasePool* pool = [NSAutoreleasePool new];

// ...do your thing...



[pool drain];
}



hth,

--Graham


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Simple memory problem

2009-02-05 Thread Nick Zitzmann


On Feb 5, 2009, at 4:39 PM, harry greenmonster wrote:

I'm a little confused as to why I have a problem. My understanding  
is that 'inputString' (on the third line) is replaced by the  
modified version of itself. I was expecting the memory footprint for  
the app to reduce in size (if anything). Obviously I have the  
concept fundamentally wrong in my head.


a pointer address when replaced by another address free's up the old  
memory location it once pointed to, no?



No. Pointers are not freed until they are deallocated, either by  
free() or -dealloc or the garbage collector's scanner (if GC is on) or  
something similar. What's probably happening is the methods you are  
calling are generating a bunch of temporary objects and autoreleasing  
them. You can create a new pool and force it to pop at any time by  
initializing a new NSAutoreleasePool prior to calling some methods,  
and then calling -drain on the pool afterwards. It's a good idea to do  
this in a loop in any case...


Nick Zitzmann
http://www.chronosnet.com/

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Needed : set class for Cocoa

2009-02-05 Thread Graham Cox


On 6 Feb 2009, at 10:44 am, Jordan Breeding wrote:


NSSet/NSMutableSet



They don't compare by pointer, they compare using -isEqual:, which  
returns YES for the two strings that the OP indicated.


I can only suggest wrapping the objects in an NSValue using [NSValue  
valueWithPointer:]; though you'd need to experiment how exactly this  
tests for equality.


--Graham


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Simple memory problem

2009-02-05 Thread Ken Thomases

On Feb 5, 2009, at 5:39 PM, harry greenmonster wrote:


while([inputString isMatchedByRegex:regexString]){

range = [inputString rangeOfRegex:regexString];

	inputString = [inputString stringByReplacingCharactersInRange:range  
withString:@];


}



'inputString' is a 5mb text file, Activity Monitor shows that memory  
increases by about 9mb per iteration. Which quickly becomes a  
serious problem.


I'm a little confused as to why I have a problem. My understanding  
is that 'inputString' (on the third line) is replaced by the  
modified version of itself. I was expecting the memory footprint for  
the app to reduce in size (if anything). Obviously I have the  
concept fundamentally wrong in my head.


a pointer address when replaced by another address free's up the old  
memory location it once pointed to, no?


No.  The pointer merely stops pointing to what it used to.

If you are using garbage collection, then assigning the pointer _may_  
make the object available for collection.  I say may because the  
existence of another pointer pointing to the same object may keep the  
object around.


The thing is, the collector doesn't immediately collect everything  
which is collectable.  You can give it hints that it should collect at  
certain points in your program.


If you're not using garbage collection, then the objects being created  
in your loop are likely to be accumulating in the autorelease pool.   
You should create a local autorelease pool within your loop, draining  
it at the end of each iteration.


Regards,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Needed : set class for Cocoa

2009-02-05 Thread Ken Thomases

On Feb 5, 2009, at 5:29 PM, Tommy Nordgren wrote:

Do anyone know of a set container class for Cocoa objects, that use  
pointer semantics.


Like this:
	NSMutableString  * s1 = [@Hello mutableCopy],  * s2 = [@Hello  
mutableCopy];


Somesetclass *someSet = [[Somesetclass alloc]init];
[someSet add:s1];
[someSet add: s2];
	// After these calls, someSet should contain 2 elements because s1 ! 
= s2 by pointer semantics


If you can require Leopard, take a look at NSHashTable.

Prior to Leopard, you can use the C interface for the same  
functionality: http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#/ 
/apple_ref/doc/uid/2055-BCIGGJGB


Cheers,
Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Needed : set class for Cocoa

2009-02-05 Thread Quincey Morris

On Feb 5, 2009, at 15:29, Tommy Nordgren wrote:

Do anyone know of a set container class for Cocoa objects, that use  
pointer semantics.


Like this:
	NSMutableString  * s1 = [@Hello mutableCopy],  * s2 = [@Hello  
mutableCopy];


Somesetclass *someSet = [[Somesetclass alloc]init];
[someSet add:s1];
[someSet add: s2];
	// After these calls, someSet should contain 2 elements because s1 ! 
= s2 by pointer semantics


You could try:


http://developer.apple.com/documentation/Cocoa/Reference/NSHashTable_class/Introduction/Introduction.html

with maybe 'NSPointerFunctionsStrongMemory |  
NSPointerFunctionsOpaquePersonality' for the options.


Alternatively, you can use NSSet with values encoded by [NSValue  
valueWithPointer: someObject], and decoded by [someValueObject  
pointerValue].




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Needed : set class for Cocoa

2009-02-05 Thread Jason Foreman
You could throw the pointers into NSValue objects and store those in  
an NS[Mutable]Set..


Jason


On Feb 5, 2009, at 5:29 PM, Tommy Nordgren tommy.nordg...@comhem.se  
wrote:


Do anyone know of a set container class for Cocoa objects, that use  
pointer semantics.


Like this:
   NSMutableString  * s1 = [@Hello mutableCopy],  * s2 = [@Hello  
mutableCopy];


   Somesetclass *someSet = [[Somesetclass alloc]init];
   [someSet add:s1];
   [someSet add: s2];
   // After these calls, someSet should contain 2 elements because  
s1 != s2 by pointer semantics

--
Home is not where you are born, but where your heart finds peace -
Tommy Nordgren, The dying old crone
tommy.nordg...@comhem.se


___

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/jason%40threeve.org

This email sent to ja...@threeve.org

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Needed : set class for Cocoa

2009-02-05 Thread Quincey Morris

On Feb 5, 2009, at 15:59, Quincey Morris wrote:

Alternatively, you can use NSSet with values encoded by [NSValue  
valueWithPointer: someObject], and decoded by [someValueObject  
pointerValue].


Er, sorry, if you're going that route, it would be slightly more  
correct to use [NSValue valueWithNonretainedObject: someObject] and  
[someValueObject nonretainedObjectValue], so that you get the maximum  
compile-time type checking and self-documentation. But it's  
practically the same thing.



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Simple memory problem

2009-02-05 Thread Shawn Erickson
On Thu, Feb 5, 2009 at 3:39 PM, harry greenmonster
southwestmons...@googlemail.com wrote:

 'inputString' is a 5mb text file,

Since inputString is large you really should avoid causing it to be
copied over and over again which -[NSString
stringByReplacingCharactersInRange:withString:] is doing. You should
instead use a mutable string and -[NSMutableString
replaceCharactersInRange:withString:].

NSMutableString* tmpString = [[inputString mutableCopy] autorelease];
while([tmpString isMatchedByRegex:regexString]) {
   range = [tmpString rangeOfRegex:regexString];
   [tmpString replaceCharactersInRange:range withString:@];
}

-Shawn
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Simple memory problem

2009-02-05 Thread harry greenmonster


I had already tried an NSAutoreleasePool but came across issues, it  
released inputString  so as useless for the next iteration. So I tried  
keeping it around with...


if (inputString != nil) {
[inputString retain]; /* Keep match around. */
}
[inputString release];

within the NSAutoreleasePool ...and then I'm back to square one.

I understand the release retain concept reasonably well, it's just  
that as inputString was being replaced by a pointer of the same name I  
presumed the old one was autoreleased OR just replaced the address  
location.



So, how do I keep a copy hanging around AND kill the mysterious new  
copy then (which shares the same name as the old one presumably)?


Not really; the pointer to the old address is still hanging around  
out there until you ensure that it's taken care of.  In this case,  
yes, the stringByReplacing... method *does* return an autoreleased  
object, which will *eventually* get cleaned up, but since you're  
doing this in a tight loop, all that eventual cleanup is not going  
to be done until (possibly) much later.  If you wrap the contents of  
your while loop with


NSAutoreleasePool *pool = [NSAutoReleasePool new];
...
[pool drain];

This will clean up the autoreleased inputString each time, instead  
of collecting them all for later disposal.


See the Cocoa and Objective-C docs on Memory Management.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Needed : set class for Cocoa

2009-02-05 Thread Sean McBride
Tommy Nordgren (tommy.nordg...@comhem.se) on 2009-02-06 6:29 PM said:

Do anyone know of a set container class for Cocoa objects, that use
pointer semantics.

Like this:
   NSMutableString  * s1 = [@Hello mutableCopy],  * s2 = [@Hello
mutableCopy];

   Somesetclass *someSet = [[Somesetclass alloc]init];
   [someSet add:s1];
   [someSet add: s2];
   // After these calls, someSet should contain 2 elements because s1 !=
s2 by pointer semantics

Depending on your exact needs, maybe NSCountedSet would be useful.

Sean


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Simple memory problem

2009-02-05 Thread harry greenmonster
NSMutableString, good idea, I think that will work, will try that  
thanks.


And thanks everyone else.


On 6 Feb 2009, at 00:16, Shawn Erickson wrote:


On Thu, Feb 5, 2009 at 3:39 PM, harry greenmonster
southwestmons...@googlemail.com wrote:


'inputString' is a 5mb text file,


Since inputString is large you really should avoid causing it to be
copied over and over again which -[NSString
stringByReplacingCharactersInRange:withString:] is doing. You should
instead use a mutable string and -[NSMutableString
replaceCharactersInRange:withString:].

NSMutableString* tmpString = [[inputString mutableCopy] autorelease];
while([tmpString isMatchedByRegex:regexString]) {
  range = [tmpString rangeOfRegex:regexString];
  [tmpString replaceCharactersInRange:range withString:@];
}

-Shawn


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Simple memory problem

2009-02-05 Thread Shawn Erickson
On Thu, Feb 5, 2009 at 4:16 PM, Shawn Erickson shaw...@gmail.com wrote:
 On Thu, Feb 5, 2009 at 3:39 PM, harry greenmonster
 southwestmons...@googlemail.com wrote:

 'inputString' is a 5mb text file,

 Since inputString is large you really should avoid causing it to be
 copied over and over again which -[NSString
 stringByReplacingCharactersInRange:withString:] is doing. You should
 instead use a mutable string and -[NSMutableString
 replaceCharactersInRange:withString:].

 NSMutableString* tmpString = [[inputString mutableCopy] autorelease];
 while([tmpString isMatchedByRegex:regexString]) {
   range = [tmpString rangeOfRegex:regexString];
   [tmpString replaceCharactersInRange:range withString:@];
 }

...better yet use -[NSMutableString deleteCharactersInRange:] given
you are replacing with an empty string.

-Shawn
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Simple memory problem

2009-02-05 Thread Graham Cox


On 6 Feb 2009, at 11:16 am, Shawn Erickson wrote:


Since inputString is large you really should avoid causing it to be
copied over and over again



I agree wholeheartedly, the autorelease pool solution is a sticking  
plaster on a gaping wound. A better approach is to avoid the need for  
it in the first place. I'd also say that this looks like a O(n^2)  
operation which might be slow given the file sizes you mentioned. If  
this is being run on the main thread you might need to give some  
thought to keeping your app responsive, maybe by breaking this down  
into shorter chunks (or shunt this off onto another thread - it looks  
like a reasonable candidate).


--Graham


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: 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.

Enjoy,
   Peter.

--
  Keyboard Maestro 3 Now Available!
   Now run macros from your iPhone with Keyboard Maestro Control!

Keyboard Maestro http://www.keyboardmaestro.com/ Macros for your Mac
http://www.stairways.com/   http://download.stairways.com/
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


IKImageView selection issue

2009-02-05 Thread Christian Graus
I have a class derived from IKImageView, and in my initWithFrame ( which is
the only init I call ), I set [self setDelegate:self];
Once I do this, I have this code:

- (void) selectionRectAdded: (IKImageView *) imageView

{

NSLog(@Created sel rect);

}

I run the app and make a selection.  This log message is displayed twice (
sadly, both times before the selection ends, which is a PITA ).  Now, here's
where it gets interesting.  My app crashes with a bad access, and then XCode
reports that it's loading 40 stack frames or something.  Which makes me
think I've created infinite recursion, but I don't see how.  I only set the
delegate in initWithFrame, so I don't see how I could have set the delegate
over and over ( does it even work that way ? ).  Does anyone have any
suggestion what I may be doing wrong, please?

Christian
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CoreData migration and file change

2009-02-05 Thread Dave Fernandes
I do migration in a subclass of NSDocumentController in the  
openDocumentWithContentsOfURL:display:error: method. Works great, but  
I've only tested on 10.4 so far. You migrate the store and then call  
[super openDocumentWithContentsOfURL...].


Dave

On Feb 5, 2009, at 9:56 AM, Dan Grassi wrote:



I am doing the migration in
readFromURL:ofType:error:
I call: migrationManager with
	 
migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:des 
tinationType:destinationOptions:error:


Thus I get a new file on the migration, that seems to be the crux  
of the problem.  So I don't really understand copying the store  
file and them migrating.


I call
[self setFileURL:[NSURL fileURLWithPath:storeFilePath]];
	[self setFileModificationDate:[[fileManager  
fileAttributesAtPath:storeFilePath traverseLink:YES]  
fileModificationDate]];
and this changes the dialog message from ...changed by another  
app... to ...has been moved...


A little more info, this is 10.5 only and currently xml stores.

Thanks,

Dan



On Feb 4, 2009, at 4:14 PM, sanchezm wrote:


On Feb 4, 2009, at 12:25 PM, Dan Grassi wrote:


After having read everything I can google I have only progressed to:

The document “project.xml” has been moved.

I am doing a manual migration so I do not call  
configurePersistentStore:... as Miguel suggests but have tried  
setFileModificationDate as suggested and I only get a slightly  
better but still confusing message as above.




so where are you doing the migration?
If you're moving the document during your manual migration, I  
might suggest copying it and then migrating over the original copy.


- Miguel



I have tried FSExchangeObjects but that did not help.

I have not tried moving the migration code to a -writeToURL: or -  
saveToURL: method and calling that if I need to migrate, surely  
there is a less convoluted way.



Any help will be greatly appreciated.

Dan



On Feb 4, 2009, at 12:42 PM, Barry Wark wrote:


I recently asked a related question on StackOverflow:
http://stackoverflow.com/questions/380076/manual-core-data- 
schema-migration-without-document-changed-warning.

The answer should help you out.

On Tue, Feb 3, 2009 at 9:08 AM, Dan Grassi d...@marware.com wrote:
I have a CoreData application and am migrating the data store.   
When the
user opens an old store the migration happens automatically  
creating a new
file.  The problem is when the user saves the first time after  
the migration
he gets the message: This document's file has been changed by  
another

application since you opened or saved it.

What is the correct procedure for handling the file change or  
how can I

avoid this message?

Thanks,

Dan

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/sanchezm95% 
40gmail.com


This email sent to sanchez...@gmail.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/dave.fernandes% 
40utoronto.ca


This email sent to dave.fernan...@utoronto.ca


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Needed : set class for Cocoa

2009-02-05 Thread Tommy Nordgren


On Feb 6, 2009, at 1:18 AM, Sean McBride wrote:


Tommy Nordgren (tommy.nordg...@comhem.se) on 2009-02-06 6:29 PM said:


Do anyone know of a set container class for Cocoa objects, that use
pointer semantics.

Like this:
NSMutableString  * s1 = [@Hello mutableCopy],  * s2 = [@Hello
mutableCopy];

Somesetclass *someSet = [[Somesetclass alloc]init];
[someSet add:s1];
[someSet add: s2];
	// After these calls, someSet should contain 2 elements because  
s1 !=

s2 by pointer semantics


Depending on your exact needs, maybe NSCountedSet would be useful.

Sean


	I have decided to do an implementation myself, as an objective c++  
wrapper to
std::setid.  I want to use the class to aid in destruction of  
directed cyclical object graphs,

in dual mode frameworks. NSHashTable
-
This sig is dedicated to the advancement of Nuclear Power
Tommy Nordgren
tommy.nordg...@comhem.se




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Restoring selection to NSOutlineView

2009-02-05 Thread Randall Meadows
Man, I'm feeling dumb today...NSOutlineView/NSTreeController is  
kicking my butt...


I'm trying to determine a sane new selection for when I delete the  
currently selected item in an NSOutlineView.


I'm failing.

My thought was to get the index path of the item I deleted, then try  
to select that same index path, thinking that that would now be the  
next sibling if there was one, and the selection method would return  
NO if there was no next sibling (since the index path would be  
invalid).


However, if I've just deleted the last sibling (and thus there is  
not next sibling), the selection method (-setSelectionIndexPath:)  
actually returns YES, because instead of *not* changing the selection  
because the index path is invalid, it changes the selection to nothing  
because the index path is invalid (thus necessitating the YES return  
value).


If there was no next sibling, I was going to try to select the  
previous sibling, if there was one, and only if there wasn't, then  
proceed to select the deleted item's parent (if there was one).  But I  
can't get this far, because of the problem described in the previous  
paragraph.


So, it seems like I need to try to get the actual *object* pointed to  
by the index path and see if there is a valid object there, but I  
can't figure out how to do that, either from the NSOutlineView or its  
backing NSTreeController.


Any ideas?


Thanks!
randy
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Restoring selection to NSOutlineView

2009-02-05 Thread Rob Keniger


On 06/02/2009, at 11:06 AM, Randall Meadows wrote:

So, it seems like I need to try to get the actual *object* pointed  
to by the index path and see if there is a valid object there, but I  
can't figure out how to do that, either from the NSOutlineView or  
its backing NSTreeController.



This will give you the real object at a particular index path for an  
NSTreeController instance:


[[[treeController arrangedObjects]  
descendantNodeAtIndexPath:indexPath] representedObject];


--
Rob Keniger



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to transform a NSString to a NSString C string format?

2009-02-05 Thread Michael Ash
On Thu, Feb 5, 2009 at 5:52 PM, Iceberg-Dev dev.iceb...@gmail.com wrote:
 Problem:
 

 I would like to transform a NSString to a NSString conforming to the C
 string format.

 Examples:
 -

 toto - toto

 toto - \toto

 toto   - toto\ntiti
 titi


 My Current Solution:
 

 I can do this using a NSMutableString and a series of call to:

 - replaceOccurrencesOfString:withString:options:range:

 The problem I see with this solution is that I will probably forget some
 cases.

 Question:
 -

 Would there be a better solution? (I couldn't find a method in NSString,
 NSMutableString CFStringRef APIs but I might missed it).

Depending on your goal, it might be better to forget about special
cases and just escape *everything*.

E.g. instead of transforming toto - \toto, transform it to
\x22\x74\x6f\x74\x6f or to { 0x22, 0x74, 0x6f, 0x74, 0x6f, 0x00 }.
This obviously produces larger and somewhat less readable output, but
you're assured that it will work on any input and requires no special
casing.

If this happens to be part of a build script, also consider using
/usr/bin/xxd -i which will produce this sort of output for you with no
work on your part.

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 arch...@mail-archive.com


Re: How to transform a NSString to a NSString C string format?

2009-02-05 Thread Stephen J. Butler
On Thu, Feb 5, 2009 at 4:52 PM, Iceberg-Dev dev.iceb...@gmail.com wrote:
 Problem:
 

 I would like to transform a NSString to a NSString conforming to the C
 string format.

 Examples:
 -

 toto - toto

 toto - \toto

 toto   - toto\ntiti
 titi

Well, first consider how you want to handle non-ascii characters. That
is, do you want your C string to be in a specific coding, like UTF8.
Then, I'd do something like this:

const char* cSource = [source cStringUsingEncoding:NSUTF8StringEncoding];
int i = 0, j = 0;
int cSourceLen = strlen( cSource );
char *cResult = NULL;
NSString *result = nil;

cResult = (char*)calloc( (cSourceLen * 4) + 1, 1 ); // max possible

for (i = 0; i  cSourceLen; ++i) {
  if (isprint( cSource[ i ] )) {
cResult[ ++j ] = cSource[ i ];
  } else {
switch (cSource[ i ]) {
  case '\n':
strcpy( cResult[ j ], \\n );
j += 2;
break;

  case '\t':
// etc for the all the other special cases

  default:
sprintf( cResult[ j ], \\x%02x, cSource[ i ] );
j += 4;
break;
}
  }
}

result = [[NSString alloc] initWithBytesNoCopy:cResult length:j
encoding:NSASCIIStringEncoding freeWhenDone:YES];

That is 100% untested, btw. I have a meeting to go to :)
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Needed : set class for Cocoa

2009-02-05 Thread Sean McBride
Tommy Nordgren (tommy.nordg...@comhem.se) on 2009-02-06 7:55 PM said:

I have decided to do an implementation myself, as an objective c++
wrapper to
std::setid.  I want to use the class to aid in destruction of
directed cyclical object graphs,
in dual mode frameworks.

Dual mode as in both Retain-Release and Garbage Collection?  If so, be
careful.  I don't think an std::set will keep strong references to the
Obj-C objects it contains.  You may need to CFRetain()/CFRelease() your
objects manually.

Sean


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


More info - drag and drop could be the issue....

2009-02-05 Thread Christian Graus
So, it seems that if I set my class to be it's own delegate, then the drag
and drop code that exists in the containing class, does a perform drop when
I drag out a box in my IKImageView.  My breakpoints are not working properly
tho ( which often happens to me in XCode ).  So,



- (BOOL)performDragOperation:(id NSDraggingInfo)sender

{

#ifdef DEBUG

{

NSLog(@entering performDragOperation);

}

#endif

 if (sender == self)

return;


is in my class that contains the IKImageView derived class.  The check if
sender == self does not work ( does anyone have any idea how to do this ? )
and the breakpoint I set at this line, fires when I do a real drag and drop,
but not when I drag and let go all within the IKImageView.  Instead, this
code is running and reloading my image ( I'm not sure where from ).  I can
set a breakpoint, but it will stop inside the image load code, and while I
am looking at it, the stack overflows and the app crashs.  So, I am
expecting that the drop is occuring over and over, when I don't want it to
occur at all when I click, drag and let got of the mouse, all in the same
window.  I assume I am doing something stupid ?

I also tried to make this parent class register for events, but that
actually never fired anything.

Christian
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: IKImageView selection issue

2009-02-05 Thread Graham Cox


On 6 Feb 2009, at 11:50 am, Christian Graus wrote:

I have a class derived from IKImageView, and in my initWithFrame  
( which is

the only init I call ), I set [self setDelegate:self];
Once I do this, I have this code:

- (void) selectionRectAdded: (IKImageView *) imageView

{

NSLog(@Created sel rect);

}

I run the app and make a selection.  This log message is displayed  
twice (
sadly, both times before the selection ends, which is a PITA ).   
Now, here's
where it gets interesting.  My app crashes with a bad access, and  
then XCode
reports that it's loading 40 stack frames or something.  Which  
makes me
think I've created infinite recursion, but I don't see how.  I only  
set the
delegate in initWithFrame, so I don't see how I could have set the  
delegate

over and over ( does it even work that way ? ).  Does anyone have any
suggestion what I may be doing wrong, please?




Setting an object's delegate to itself is never a good idea. It's a  
common pattern that an object will implement a message foo which in  
turn will test if its delegate implements foo and if so, call it,  
and if not, do nothing or some default behaviour. If the delegate is  
self this will immediately enter an infinite loop (and it seems rare  
that an object will also test if delegate == self in these cases).


If you are subclassing the IKImageView, you have only to override the  
methods you're interested in. There's no need to set the delegate to  
self, it's not going to tell you anything different from what your  
subclass can find out directly. By the definition of the delegate  
pattern the delegate is *another object* that assists yours. If it's  
the same object it's not a delegate. (You don't keep a dog and bark  
yourself).


WAYTTD?

--Graham




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: IKImageView selection issue

2009-02-05 Thread Christian Graus
OK - that makes some sense, excepting that if I don't set the delegate, and
just define the methods, they don't get called at all.  Also, all the
delegates are useless to me, b/c none of them fire when the selection has
been made, only when the box is initially created.  I've set the delegate to
be the class that contains it and resolved my overall issue, but I cannot
get a mouseUp event from the IKImageView, without which, I don't see how to
respond to the end of a selection action, as opposed to the start of it ?
Thanks

Christian

On Fri, Feb 6, 2009 at 2:12 PM, Graham Cox graham@bigpond.com wrote:


 On 6 Feb 2009, at 11:50 am, Christian Graus wrote:

  I have a class derived from IKImageView, and in my initWithFrame ( which
 is
 the only init I call ), I set [self setDelegate:self];
 Once I do this, I have this code:

 - (void) selectionRectAdded: (IKImageView *) imageView

 {

 NSLog(@Created sel rect);

 }

 I run the app and make a selection.  This log message is displayed twice (
 sadly, both times before the selection ends, which is a PITA ).  Now,
 here's
 where it gets interesting.  My app crashes with a bad access, and then
 XCode
 reports that it's loading 40 stack frames or something.  Which makes
 me
 think I've created infinite recursion, but I don't see how.  I only set
 the
 delegate in initWithFrame, so I don't see how I could have set the
 delegate
 over and over ( does it even work that way ? ).  Does anyone have any
 suggestion what I may be doing wrong, please?




 Setting an object's delegate to itself is never a good idea. It's a common
 pattern that an object will implement a message foo which in turn will
 test if its delegate implements foo and if so, call it, and if not, do
 nothing or some default behaviour. If the delegate is self this will
 immediately enter an infinite loop (and it seems rare that an object will
 also test if delegate == self in these cases).

 If you are subclassing the IKImageView, you have only to override the
 methods you're interested in. There's no need to set the delegate to self,
 it's not going to tell you anything different from what your subclass can
 find out directly. By the definition of the delegate pattern the delegate is
 *another object* that assists yours. If it's the same object it's not a
 delegate. (You don't keep a dog and bark yourself).

 WAYTTD?

 --Graham





___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Simple memory problem

2009-02-05 Thread Scott Ribe
 So, how do I keep a copy hanging around AND kill the mysterious new
 copy then (which shares the same name as the old one presumably)?

2 pointer variables...

-- 
Scott Ribe
scott_r...@killerbytes.com
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 arch...@mail-archive.com


  1   2   >