Re: -NSMutableIndexSet shiftIndexesStartingAtIndex:by: weirdness

2009-09-17 Thread Tommy Nordgren


On 17 sep 2009, at 15.23, steven Hooley wrote:


- shiftIndexesStartingAtIndex:by: and
-containsIndexesInRange:NSMakeRange: don't seem to play nicely
together..
Is this expected?

NSMutableIndexSet *someIndexes = [NSMutableIndexSet indexSet];
[someIndexes addIndex:0];
[someIndexes addIndex:2];
[someIndexes shiftIndexesStartingAtIndex:2 by:-1];

BOOL result1 = [someIndexes containsIndex:0];
BOOL result2 = [someIndexes containsIndex:1];
BOOL result3 = [someIndexes containsIndexesInRange:NSMakeRange(0,2)];


Here is the error. You are asking if the index set contains (0,1,2),
But it only contains (0, 1) after the shift
Try using NSMakeRange (0,1) instead.

NSLog(@"%@ %@ %@", (result1 ? @"YES" : @"NO"), (result2 ? @"YES" :
@"NO"), (result3 ? @"YES" : @"NO") );

-- 2009-09-17 14:21:25.789 otest[19356:10b] YES YES NO

thanks
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/tommy.nordgren%40comhem.se

This email sent to tommy.nordg...@comhem.se


--
Skinheads are so tired of immigration, that they are going to move to  
a country that don't accept immigrants!

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


Re: How do I track down an OSStatus error code?

2009-07-21 Thread Tommy Nordgren


On Jul 20, 2009, at 10:00 PM, Michael A. Crawford wrote:


Looking for the meaning behind the value -43.

-Michael


	Do a batch file search of header files in your SDK for -43, using  
TextWrangler or BBEdit

(http://www.barebones.com)
--
What is a woman that you forsake her, and the hearth fire and the home  
acre,
to go with the old grey Widow Maker.  --Kipling, harp song of the Dane  
women

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


Re: GC bug in NSFontManager?

2009-07-01 Thread Tommy Nordgren


On Jul 1, 2009, at 5:34 PM, Ross Carter wrote:



On Jun 30, 2009, at 7:57 PM, Tommy Nordgren wrote:

	Is CCMApp an NSApplication subclass. This stack trace seems to  
indicate that there is an instance of it in

your nib/xib file.


Nope, it's the application delegate. The principal class is  
NSApplication.

___



You might check if any of the following methods depends on outlets  
being correctly set:
2 com.cocomot.Pagehand 0x0003a706 -[CCMFontCollectionsController  
fontNamesFamiliesDictionary] + 312
3 com.cocomot.Pagehand 0x0003a1fc -[CCMFontCollectionsController  
fontCollectionsArrayForControls] + 60

4 com.cocomot.Pagehand 0x000305fe -[CCMApp init] + 806
If so you need to move the code called in CCMApp init,
to the method [CCMApp awakeFromNib] which is called after the nib  
loading mechanism have set all outlets for

the nib
--
What is a woman that you forsake her, and the hearth fire and the home  
acre,
to go with the old grey Widow Maker.  --Kipling, harp song of the Dane  
women

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


Re: GC bug in NSFontManager?

2009-06-30 Thread Tommy Nordgren


On Jul 1, 2009, at 1:57 AM, Tommy Nordgren wrote:



On Jun 30, 2009, at 11:48 PM, Ross Carter wrote:



On Jun 30, 2009, at 3:33 PM, Quincey Morris wrote:


On Jun 30, 2009, at 11:34, Ross Carter wrote:

I am receiving crash reports for code that enumerates an array  
returned by NSFontManager. The app is garbage-collected.


Chances are someone will recognize the exact problem and jump in  
with an explanation, but in case not:


(a) Can you post back-traces from the points of failure  
corresponding to the source code?


This one is typical:

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


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


Thread 0 Crashed:
0 libobjc.A.dylib 0x917e768c objc_msgSend + 28
1 com.apple.AppKit 0x94d3ef43 -[NSFontManager  
availableMembersOfFontFamily:] + 963
2 com.cocomot.Pagehand 0x0003a706 -[CCMFontCollectionsController  
fontNamesFamiliesDictionary] + 312
3 com.cocomot.Pagehand 0x0003a1fc -[CCMFontCollectionsController  
fontCollectionsArrayForControls] + 60

4 com.cocomot.Pagehand 0x000305fe -[CCMApp init] + 806
5 com.apple.AppKit 0x94b48e03 -[NSCustomObject nibInstantiate] + 315
6 com.apple.AppKit 0x94b297f5 -[NSIBObjectData instantiateObject:]  
+ 259
7 com.apple.AppKit 0x94b28f16 -[NSIBObjectData  
nibInstantiateWithOwner:topLevelObjects:] + 297

8 com.apple.AppKit 0x94b1f616 loadNib + 264
9 com.apple.AppKit 0x94b1ef78 +[NSBundle(NSNibLoading)  
_loadNibFile:nameTable:withZone:ownerBundle:] + 946
10 com.apple.AppKit 0x94b1ebbb +[NSBundle(NSNibLoading)  
loadNibFile:externalNameTable:withZone:] + 171
11 com.apple.AppKit 0x94b1eaf9 +[NSBundle(NSNibLoading)  
loadNibNamed:owner:] + 391

12 com.apple.AppKit 0x94b1e7a8 NSApplicationMain + 434
13 com.cocomot.Pagehand 0x2d66 start + 54

	Is CCMApp an NSApplication subclass. This stack trace seems to  
indicate that there is an instance of it in

your nib/xib file.
	If so, your application is initialized in an incorrect way, and  
outlets in it may not be set up correctly.
	To fix, delete it from your nib, and set the value for the key   
NSPrincipalClass in your Info.plist file to CCMApp
	(NSApplicationMain uses this key to create an instance of the  
correct NSApplication (sub)class.


	One more thing - you need to move the code from CCMApp init  to  
finishLaunching, a method that is invoked

immediately before the runloop starts


(b) Can you reproduce the problem locally? (That is, are you in a  
position to try changes and see if the problem goes away?)


No, I have never seen it happen.
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/tommy.nordgren%40comhem.se

This email sent to tommy.nordg...@comhem.se


---
Engineers supporting greenpeace: Comparable to Afroamericans who  
wants to join the Ku Klux Klan


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/tommy.nordgren%40comhem.se

This email sent to tommy.nordg...@comhem.se


-
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


Re: GC bug in NSFontManager?

2009-06-30 Thread Tommy Nordgren


On Jun 30, 2009, at 11:48 PM, Ross Carter wrote:



On Jun 30, 2009, at 3:33 PM, Quincey Morris wrote:


On Jun 30, 2009, at 11:34, Ross Carter wrote:

I am receiving crash reports for code that enumerates an array  
returned by NSFontManager. The app is garbage-collected.


Chances are someone will recognize the exact problem and jump in  
with an explanation, but in case not:


(a) Can you post back-traces from the points of failure  
corresponding to the source code?


This one is typical:

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


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

Thread 0 Crashed:
0 libobjc.A.dylib 0x917e768c objc_msgSend + 28
1 com.apple.AppKit 0x94d3ef43 -[NSFontManager  
availableMembersOfFontFamily:] + 963
2 com.cocomot.Pagehand 0x0003a706 -[CCMFontCollectionsController  
fontNamesFamiliesDictionary] + 312
3 com.cocomot.Pagehand 0x0003a1fc -[CCMFontCollectionsController  
fontCollectionsArrayForControls] + 60

4 com.cocomot.Pagehand 0x000305fe -[CCMApp init] + 806
5 com.apple.AppKit 0x94b48e03 -[NSCustomObject nibInstantiate] + 315
6 com.apple.AppKit 0x94b297f5 -[NSIBObjectData instantiateObject:] +  
259
7 com.apple.AppKit 0x94b28f16 -[NSIBObjectData  
nibInstantiateWithOwner:topLevelObjects:] + 297

8 com.apple.AppKit 0x94b1f616 loadNib + 264
9 com.apple.AppKit 0x94b1ef78 +[NSBundle(NSNibLoading)  
_loadNibFile:nameTable:withZone:ownerBundle:] + 946
10 com.apple.AppKit 0x94b1ebbb +[NSBundle(NSNibLoading)  
loadNibFile:externalNameTable:withZone:] + 171
11 com.apple.AppKit 0x94b1eaf9 +[NSBundle(NSNibLoading)  
loadNibNamed:owner:] + 391

12 com.apple.AppKit 0x94b1e7a8 NSApplicationMain + 434
13 com.cocomot.Pagehand 0x2d66 start + 54

	Is CCMApp an NSApplication subclass. This stack trace seems to  
indicate that there is an instance of it in

your nib/xib file.
	If so, your application is initialized in an incorrect way, and  
outlets in it may not be set up correctly.
	To fix, delete it from your nib, and set the value for the key   
NSPrincipalClass in your Info.plist file to CCMApp
	(NSApplicationMain uses this key to create an instance of the correct  
NSApplication (sub)class.


(b) Can you reproduce the problem locally? (That is, are you in a  
position to try changes and see if the problem goes away?)


No, I have never seen it happen.
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/tommy.nordgren%40comhem.se

This email sent to tommy.nordg...@comhem.se


---
Engineers supporting greenpeace: Comparable to Afroamericans who wants  
to join the Ku Klux Klan


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


Objective C Compiler Settings

2009-06-28 Thread Tommy Nordgren
Are there any compiler flags you can provide when compiling Objective  
C code,
that causes an exception to be triggered when a category implements a  
method

that is already implemented in the target class?
---
See the amazing new SF reel: Invasion of the man eating cucumbers from  
outer space.
On congratulations for a fantastic parody, the producer replies :  
"What parody?"


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


Re: Why is -makeWindowControllers getting called twice?

2009-05-04 Thread Tommy Nordgren

Are the listing from two different GDB sessions?
Otherwise, judging from the value of self in [MyDocument  
makeWindowControllers],

you have TWO instances of the MyDocument class. Is this intentional?
On May 4, 2009, at 3:38 AM, David Scheidt wrote:

I'm trying to figure out why my NSPersistantDocuement subclass's - 
makeWindowControllers is getting called twice.  I'm also trying to  
figure out why a nib that I'm trying to load from a viewcontroller  
created by the window controller made by -makeWindowController isn't  
loading.  I'm willing to bet they're related.  I'm further willing  
to bet it's something I've done, but I'm stumped.


Some relevant bits of GDB:

gdb) where
#0  -[MyDocument makeWindowControllers] (self=0x10471d0,  
_cmd=0x9464d69c) at /./MyDocument.m:84
#1  0x946e8e02 in -[NSDocumentController  
openUntitledDocumentAndDisplay:error:] ()

#2  0x946e895f in -[NSDocumentController(NSInternal) _openUntitled] ()
#3  0x946e87b1 in -[NSApplication _doOpenUntitled] ()
#4  0x946e7e95 in -[NSApplication(NSAppleEventHandling)  
_handleAEOpen:] ()
#5  0x946e76bc in -[NSApplication(NSAppleEventHandling)  
_handleCoreEvent:withReplyEvent:] ()
#6  0x912ee43f in -[NSAppleEventManager  
dispatchRawAppleEvent:withRawReply:handlerRefCon:] ()

#7  0x912ee14f in _NSAppleEventManagerGenericHandler ()
#8  0x95bb4648 in aeDispatchAppleEvent ()
#9  0x95bb457e in dispatchEventAndSendReply ()
#10 0x95bb4425 in aeProcessAppleEvent ()
#11 0x917279a5 in AEProcessAppleEvent ()
#12 0x946e4f91 in _DPSNextEvent ()
#13 0x946e4630 in -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:] ()

#14 0x946dd66b in -[NSApplication run] ()
#15 0x946aa8a4 in NSApplicationMain ()
#16 0x2eee in main (argc=1, argv=0xb7e4) at /Users/dms/ 
Documents/w/main.m:13

(gdb) go
Undefined command: "go".  Try "help".
(gdb) cont
Continuing.
(gdb) continue
2009-05-03 21:31:04.429 mwa3[61892:813] MANAgedobjectContext is  


(gdb) continue
(gdb) continue
2009-05-03 21:31:08.161 mwa3[61892:813] Cannot create NSSet from  
object  of class  
BottlesDetailViewController

(gdb) where
#0  -[MyDocument makeWindowControllers] (self=0x105d5b0,  
_cmd=0x9464d69c) at /Users/dms/Documents/wine/mwa3-view/MyDocument.m: 
84
#1  0x946e8e02 in -[NSDocumentController  
openUntitledDocumentAndDisplay:error:] ()

#2  0x946e895f in -[NSDocumentController(NSInternal) _openUntitled] ()
#3  0x946e87b1 in -[NSApplication _doOpenUntitled] ()
#4  0x946e7e95 in -[NSApplication(NSAppleEventHandling)  
_handleAEOpen:] ()
#5  0x946e76bc in -[NSApplication(NSAppleEventHandling)  
_handleCoreEvent:withReplyEvent:] ()
#6  0x912ee43f in -[NSAppleEventManager  
dispatchRawAppleEvent:withRawReply:handlerRefCon:] ()

#7  0x912ee14f in _NSAppleEventManagerGenericHandler ()
#8  0x9138459c in _NSAppleEventManagerPreDispatchHandler ()
#9  0x95bb4648 in aeDispatchAppleEvent ()
#10 0x95bb457e in dispatchEventAndSendReply ()
#11 0x95bb4425 in aeProcessAppleEvent ()
#12 0x917279a5 in AEProcessAppleEvent ()
#13 0x946e4f91 in _DPSNextEvent ()
#14 0x946e4630 in -[NSApplication  
nextEventMatchingMask:untilDate:inMode:dequeue:] ()

#15 0x946dd66b in -[NSApplication run] ()
#16 0x946aa8a4 in NSApplicationMain ()
#17 0x2eee in main (argc=1, argv=0xb7e4) at /Users/dms/ 
Documents/wine/mwa3-view/main.m:13

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/tommy.nordgren%40comhem.se

This email sent to tommy.nordg...@comhem.se


---
See the amazing new SF reel: Invasion of the man eating cucumbers from  
outer space.
On congratulations for a fantastic parody, the producer replies :  
"What parody?"


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


Re: C numerical libraries for integrating with Cocoa

2009-04-23 Thread Tommy Nordgren


On Apr 17, 2009, at 6:56 PM, Chris Goedde wrote:


Hi,

I'm looking for suggestions for C numerical libraries to integrate  
with a Cocoa app. Either freeware or commercial is okay, I'm looking  
for something that will compile under Leopard and integrate with  
Xcode without too much fiddling around. I don't need anything too  
fancy, solving sets of odes and solving nonlinear equations (in one  
variable) mostly. Maybe some eigenvalue computations or matrix  
decomposition down the line.


I've been doing some googling, but thought maybe someone here would  
have some suggestions.


Thanks.

Chris Goedde

___

GNU Scientific Library, if the GPL license is acceptable.
--
What is a woman that you forsake her, and the hearth fire and the home  
acre,
to go with the old grey Widow Maker.  --Kipling, harp song of the Dane  
women

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


Re: Need localization-proof method of transporting dates.

2009-04-04 Thread Tommy Nordgren


On Apr 4, 2009, at 2:01 PM, Graham Cox wrote:


My app encodes expiry dates for demo versions, etc.

One problem I've had occasional reports of is that the expiry is  
prematurely detected, and it seems to be on systems with system  
language set other than English. I need to store and check the dates  
in a way that is not sensitive to this. I thought I was, yet the  
reports persist.


Here's what I'm doing:

The stored date originally comes from a NSDatePicker control,  
textual with stepper. I retrieve the date using its -dateValue method.


The date, along with other data, is digitally signed with a SHA-1  
hash, which in turn is based on the object's -hash method. As far as  
I could tell, the -hash method returns a value that is sensitive to  
the actual stored date, but not to the date localization on the  
system.


At runtime, the date is recovered and verified by rehashing and  
comparing the hash, then the date value is simply compared to see if  
the current date is before or after it using [[NSDate date]  
timeIntervalSinceDate:expiryDate] (if negative, hasn't expired).


Can anyone spot any problem with this approach? Note that the SHA-1  
check appears to pass OK - it's the date comparison that seems to be  
wrong. Unfortunately I can't reproduce the bug locally so I'm  
relying on reports from relatively non-technical testers who aren't  
able to give me much to go on.


--Graham



	I suggest encoding your dates as strings, in standard Iso Text Format  
(-mm-ss)

---
See the amazing new SF reel: Invasion of the man eating cucumbers from  
outer space.
On congratulations for a fantastic parody, the producer replies :  
"What parody?"


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


Re: KVO Code Breaks Undo

2009-03-28 Thread Tommy Nordgren


On Mar 28, 2009, at 1:33 PM, Richard Somers wrote:

I have core data document based application with a custom opengl  
layer-hosting view. Everything works except when objects are added  
or removed from the managed object model the view is not redrawn. So  
I add the following to code to redraw the view but then automatic  
undo is broken.


// Receive KVO change notifications if objects are added to or removed
// from the array so we can redraw the display. !!!: Breaks undo!
- (void)awakeFromNib
{
   [observableController addObserver:self  
forKeyPath:@"arrangedObjects" options:NSKeyValueObservingOptionNew  
context:NULL];

}


// Respond to KVO change notifications. !!!: Breaks undo!
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject: 
(id)object change:(NSDictionary *)change context:(void *)context

{
   [graphicsLayer setNeedsDisplay];
	You need to invoke base class method; Otherwise the standard  
behaviour won't be used.


}

Any ideas as to why undo stopped working?

Richard

___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/tommy.nordgren%40comhem.se

This email sent to tommy.nordg...@comhem.se


---
See the amazing new SF reel: Invasion of the man eating cucumbers from  
outer space.
On congratulations for a fantastic parody, the producer replies :  
"What parody?"


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


Re: Fast dictionary with integer keys?

2009-03-15 Thread Tommy Nordgren


On Mar 16, 2009, at 1:35 AM, Joseph Kelly wrote:



On Mar 15, 2009, at 12:18 PM, Tommy Nordgren wrote:

	You can write your implementation file in Objective C++ , and use  
std::map




	You can also use std::hashmap . It uses a hash table instead  
of a balanced binary tree.

This is however dependent of a good hash function.
That was my first case, but I just wanted to make sure: I've run  
some tests, and std::map outperforms NSMutableDictionary as  
described, until around n = 10^6, at which point,  
NSMutableDictionary becomes much faster, both at inserting in-order,  
and looking up randomly. I didn't test for random insertion, however.


Here's an interesting article about CFArray/NSArray behavior  
characteristics -- as compared to a straight C array and an  
std::vector:


http://ridiculousfish.com/blog/archives/2005/12/23/array/

I think it's been mentioned already that if you've got a finite set  
of keys, that if you use a fixed array with a hash function (if it's  
a small and finite pre-determined set of keys, you could just do a  
1:1 hash -- i.e. just index into the array using the key), that  
you'll get best case O(1) inserts and lookups.


Fun stuff to think about.

Joe K.
___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/tommy.nordgren%40comhem.se

This email sent to tommy.nordg...@comhem.se


-
How many National Democrats does it take to change a light bulb?
108: 8 who smashes the rest of the light bulbs, and 100 to blame a  
zionist world conspiracy for the darkness

--
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


Re: Fast dictionary with integer keys?

2009-03-15 Thread Tommy Nordgren


On Mar 15, 2009, at 7:33 PM, Oleg Krupnov wrote:


I need to use a dictionary inside a long, time-consuming operation.
The keys of the dictionary are integers, the values are NSObjects.

I could use NSDictionary, but I don't like the overhead of creating
NSNumbers for the keys and then comparing them, where I could use
integers directly more efficiently, both by time and memory.

The question is: is there this kind of fast int-keyed dictionary in
Cocoa or elsewhere? Thanks!
___


	You can write your implementation file in Objective C++ , and use  
std::map

Then write your header like this:
#ifdef __cplusplus
#include 
#endif

@interface MyClass: NSObject
{
#ifdef __cplusplus
std::map * mymap; //All data pointers have same size,
#else
void *   mymap;
#endif
}

@end

Then in your implementation file initialize your pointer:
mymap = new std::map

and use it like this:
(*mymap) [integervalue] = someid;


---
See the amazing new SF reel: Invasion of the man eating cucumbers from  
outer space.
On congratulations for a fantastic parody, the producer replies :  
"What parody?"


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


Re: Moving oneself to /Applications (or ~/Applications)

2009-02-23 Thread Tommy Nordgren


On Feb 24, 2009, at 3:34 AM, Shawn Erickson wrote:


On Mon, Feb 23, 2009 at 6:22 PM, Tommy Nordgren
 wrote:

The following code will test if you are running from the DMG:

NSString * volName = @"Mother";
NSString * appName = @"MyApp.app";

if ([[[NSBundle mainBundle] bundlePath] isEqualTo: [ NSString
stringWithFormat:@"/Volumes/%@/%@",volName,appName]) {

  //Here you can show an alert telling the user to to copy the  
app to

the applications folder

}


If a disk image it mounted a second time (can happen in a few ways) it
won't be at /Volumes/Mother/... but at /Volumes/Mounter 1/... Also you
can mount disk images in location other then under /Volumes/...

If you really want to check this you should utilize
DiskImages.framework (IIRC) or possibly use "hdutil info -plist" and
look for your disk image and its current mount location. Then compare
that to your bundles location.

-Shawn


Unfortunately, the DiskImages framework is private (no headers)
Getting the output of hdiutil is a little awkward since the NSDictionary
class has no method to initialize from a pipe.
--
What is a woman that you forsake her, and the hearth fire and the home  
acre,
to go with the old grey Widow Maker.  --Kipling, harp song of the Dane  
women

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


Re: Moving oneself to /Applications (or ~/Applications)

2009-02-23 Thread Tommy Nordgren


On Feb 24, 2009, at 4:53 AM, Kyle Sluder wrote:


5) Not just using the system-provided facilities to ask the direct
question ("Is the volume on which this app's bundle resides
removable?") but relying on aforementioned assumptions to ask an
indirect question ("Does the path of the bundle of this app match a
pattern that resembles that of the system-created directories in the
default location for mount points?")

--Kyle Sluder
	This last trick is not useful for telling wether the user is running  
the app directly from the download

dmg.
	Testing wether the Volume containing the app is removeable will match  
for ANY volume except the boot volume.

---
Engineers supporting greenpeace: Comparable to Afroamericans who wants  
to join the Ku Klux Klan

----
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


Re: Moving oneself to /Applications (or ~/Applications)

2009-02-23 Thread Tommy Nordgren


On Feb 24, 2009, at 3:34 AM, Shawn Erickson wrote:


On Mon, Feb 23, 2009 at 6:22 PM, Tommy Nordgren
 wrote:

The following code will test if you are running from the DMG:

NSString * volName = @"Mother";
NSString * appName = @"MyApp.app";

if ([[[NSBundle mainBundle] bundlePath] isEqualTo: [ NSString
stringWithFormat:@"/Volumes/%@/%@",volName,appName]) {

  //Here you can show an alert telling the user to to copy the  
app to

the applications folder

}


If a disk image it mounted a second time (can happen in a few ways) it
won't be at /Volumes/Mother/... but at /Volumes/Mounter 1/... Also you
can mount disk images in location other then under /Volumes/...

It will be /Volumes/Mother 1/...  I've tested.
This can be handled by using a regexp class for the matching instead  
of a simple

equality test.
	Also, while it's possible to mount a disk image at other places than  
under Volumes,
that won't happen when doubleclicking a disk image or it being mounted  
from Safari

--
The three things an undertaker should never say to a client:
-Nice doing business with you.
-Welcome back.
-Have a nice day. (The King of ID)
--
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


Re: Moving oneself to /Applications (or ~/Applications)

2009-02-23 Thread Tommy Nordgren

The following code will test if you are running from the DMG:

NSString * volName = @"Mother";
NSString * appName = @"MyApp.app";

if ([[[NSBundle mainBundle] bundlePath] isEqualTo: [ NSString  
stringWithFormat:@"/Volumes/%@/%@",volName,appName]) {


	//Here you can show an alert telling the user to to copy the app to  
the applications folder


}
On Feb 24, 2009, at 1:04 AM, Alex Kac wrote:

Let me give you an example why I disagree with the advice. Yes, well  
written applications can run from anywhere and all apps should!  
However its a user experience issue. Not everyone wants to write a  
pkg installer for a variety of reasons.


So first here is a story. I have a friend I switched over to the  
Mac. She downloaded Firefox and started running it from the DMG. She  
just is not advanced enough to move it to the Applications folder.  
But she thinks her Mac is broken on why sometimes she can find it  
and sometimes she can't. The reason sometimes it works is the DMG is  
mounted, and other times its not.


If Firefox would just ask - would you like to install this to the  
Applications dir *once* on first run - this issue would be negated.  
Interestingly I can name dozens of users whom I've moved to the Mac  
in the last 2-3 years that have had the exact same issue. Firefox is  
not the only example.


People can suggest this is an issue with Firefox's distribution  
mechanism - DMG, but frankly you as an engineer don't always have  
control over that. Sometimes its easier to get management to accept  
something like the above than to change distribution mechanisms.


Secondly, I think this group does a great job of pushing high  
standards in development and I applaud it for that. However I also  
think it tends to punish people who have innovative ideas to help  
the user that does not hurt the Mac experience, but helps it. I  
think Ben's question has a lot of merit and instead of having 50  
emails about something obvious and had nothing to do with his  
question, just assumptions, I think some help would've been more  
appropriate.


On Feb 23, 2009, at 5:25 PM, Tommy Nordgren wrote:



On Feb 18, 2009, at 7:28 AM, Ben Lachman wrote:


Hi all:

I'm wanting to move away from DMGs to ZIP delivery.  As part of  
this move I'd like to have my app, SousChef, prompt the user on  
first run to move itself to /Applications (or ~/Applications as  
appropriate).  In a short search I can't find any code examples  
hanging about to do something like this.  Would anyone mind  
sharing ideas/code on how to do this?


Thanks,
->Ben
--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: blach...@mac.com
twitter: @benlachman
mobile: 740.590.0009



	My advice is: Don't do that. Well written applications can run  
from any directory the user have read access to;

for example a subdirectory of /Applications.
	I have for example subdirectories of /Application for thirdparty  
software development tools, and for webeditors

-
How many National Democrats does it take to change a light bulb?
108: 8 who smashes the rest of the light bulbs, and 100 to blame a  
zionist world conspiracy for the darkness

--
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/alex%40webis.net

This email sent to a...@webis.net


Alex Kac - President and Founder
Web Information Solutions, Inc.






---
See the amazing new SF reel: Invasion of the man eating cucumbers from  
outer space.
On congratulations for a fantastic parody, the producer replies :  
"What parody?"


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


Re: Moving oneself to /Applications (or ~/Applications)

2009-02-23 Thread Tommy Nordgren

Actually there is an easy way to find the apps runtime path:

[[NSBundle mainBundle] bundlePath]
You can extract the info from the returned string.
On Feb 24, 2009, at 1:04 AM, Alex Kac wrote:

Let me give you an example why I disagree with the advice. Yes, well  
written applications can run from anywhere and all apps should!  
However its a user experience issue. Not everyone wants to write a  
pkg installer for a variety of reasons.


So first here is a story. I have a friend I switched over to the  
Mac. She downloaded Firefox and started running it from the DMG. She  
just is not advanced enough to move it to the Applications folder.  
But she thinks her Mac is broken on why sometimes she can find it  
and sometimes she can't. The reason sometimes it works is the DMG is  
mounted, and other times its not.


If Firefox would just ask - would you like to install this to the  
Applications dir *once* on first run - this issue would be negated.  
Interestingly I can name dozens of users whom I've moved to the Mac  
in the last 2-3 years that have had the exact same issue. Firefox is  
not the only example.


People can suggest this is an issue with Firefox's distribution  
mechanism - DMG, but frankly you as an engineer don't always have  
control over that. Sometimes its easier to get management to accept  
something like the above than to change distribution mechanisms.


Secondly, I think this group does a great job of pushing high  
standards in development and I applaud it for that. However I also  
think it tends to punish people who have innovative ideas to help  
the user that does not hurt the Mac experience, but helps it. I  
think Ben's question has a lot of merit and instead of having 50  
emails about something obvious and had nothing to do with his  
question, just assumptions, I think some help would've been more  
appropriate.


On Feb 23, 2009, at 5:25 PM, Tommy Nordgren wrote:



On Feb 18, 2009, at 7:28 AM, Ben Lachman wrote:


Hi all:

I'm wanting to move away from DMGs to ZIP delivery.  As part of  
this move I'd like to have my app, SousChef, prompt the user on  
first run to move itself to /Applications (or ~/Applications as  
appropriate).  In a short search I can't find any code examples  
hanging about to do something like this.  Would anyone mind  
sharing ideas/code on how to do this?


Thanks,
->Ben
--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: blach...@mac.com
twitter: @benlachman
mobile: 740.590.0009



	My advice is: Don't do that. Well written applications can run  
from any directory the user have read access to;

for example a subdirectory of /Applications.
	I have for example subdirectories of /Application for thirdparty  
software development tools, and for webeditors

-
How many National Democrats does it take to change a light bulb?
108: 8 who smashes the rest of the light bulbs, and 100 to blame a  
zionist world conspiracy for the darkness

--
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/alex%40webis.net

This email sent to a...@webis.net


Alex Kac - President and Founder
Web Information Solutions, Inc.






--
The three things an undertaker should never say to a client:
-Nice doing business with you.
-Welcome back.
-Have a nice day. (The King of ID)
--
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


Re: Help with recursive includes

2009-02-23 Thread Tommy Nordgren


On Feb 22, 2009, at 2:12 AM, Aaron Wallis wrote:

While that's always an option, it's not exactly the answer I was  
hoping to hear :D


The good news is I was able to recreate the file in a considerably  
smaller scale and have uploaded the source here: http://junk.isnot.tv/test.zip


As you can see, i've got two classes which include each others  
headers (since they need to call each others methods directly)
I may be breaking some design patterns by doing this, and if so,  
please point them out - cause they could be the cause of the  
problem :D
	Are you importing the header files from each other? That's the  
problem. In one of the header files at least, you should

forward declare the class defined in the other header file like this:

@class SomeClass;

@interface MyClass: NSObject
{
SomeClass * aMember;
}

This style will probably fix your problem if you applies it consistenly
--
What is a woman that you forsake her, and the hearth fire and the home  
acre,
to go with the old grey Widow Maker.  --Kipling, harp song of the Dane  
women

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


Re: Moving oneself to /Applications (or ~/Applications)

2009-02-23 Thread Tommy Nordgren


On Feb 18, 2009, at 7:28 AM, Ben Lachman wrote:


Hi all:

I'm wanting to move away from DMGs to ZIP delivery.  As part of this  
move I'd like to have my app, SousChef, prompt the user on first run  
to move itself to /Applications (or ~/Applications as appropriate).   
In a short search I can't find any code examples hanging about to do  
something like this.  Would anyone mind sharing ideas/code on how to  
do this?


Thanks,
->Ben
--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: blach...@mac.com
twitter: @benlachman
mobile: 740.590.0009

	My advice is: Don't do that. Well written applications can run from  
any directory the user have read access to;

for example a subdirectory of /Applications.
	I have for example subdirectories of /Application for thirdparty  
software development tools, and for webeditors

-
How many National Democrats does it take to change a light bulb?
108: 8 who smashes the rest of the light bulbs, and 100 to blame a  
zionist world conspiracy for the darkness

--
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


Re: Needed : set class for Cocoa

2009-02-06 Thread Tommy Nordgren


On Feb 6, 2009, at 2:50 AM, Sean McBride wrote:


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::set.  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


	No It won't; However, I intend to use this class only from the  
dealloc method of the object that manages
the object graph, so that it will be possible to reclaim the space if  
the framework is run on systems without gc

enabled.
What I intend to do is :
1 Create a custom subclass of NSCoder, that stores each object pointer  
passed to encodeObject:

in a set.
2. Retains each set member
3. Passes each set member a message telling it to release each  
reference it's retained.

4. Release each set member
and 5. Release any references kept directly in the managing object.

--
Skinheads are so tired of immigration, that they are going to move to  
a country that don't accept immigrants!

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


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::set.  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


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: More - Safari Download Security Alerts

2008-12-16 Thread Tommy Nordgren


On Dec 15, 2008, at 6:41 PM, Dave wrote:


Hi,

I looked at the Man page below, I can't see anything that says  
"udifrez". Is this meant for me? I'm not sure what I am supposed to  
do with it.


All the Best
Dave


I also looked at the hdiutil manpage:
For the verb udifrez it states:
 udifrez [options] image
Attaches resources (software license agreements, for  
example)

to a disk image.

That is you invoke it something like this:
hdiutil udifrez   

--
"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: controlTextDidChange for UITextField?

2008-12-14 Thread Tommy Nordgren


On Dec 15, 2008, at 12:15 AM, Debajit Adhikary wrote:


Is there any way to call a method each time the text of a UITextField
changes?
controlTextDidChange does not seem to exist for UITextField's
___

I can find no class UITextField in the developerdocs.
Do you mean NSTextField.
The method is declared in one of the base classes (NSControl),
so it is always available for any control. Note that the Cocoa docs
don't redeclare the same method name in derived classes, but i's still
available
--
Skinheads are so tired of immigration, that they are going to move to  
a country that don't accept immigrants!

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


Re: Using a string as filepath

2008-11-28 Thread Tommy Nordgren


On Nov 27, 2008, at 1:09 AM, Knut Lorenzen wrote:


Dear list,

I would like to name a file according to an user defined entry.  
However, the user's name entry might be illegal as a filepath,  
containing illegal characters for a pathname like "." or "-" as 1st  
character, "/", ":", etc.


I've looked into the Cocoa docs for NSString and NSFileManager to no  
avail.


Is there a recommended way to "clean" an NSString in order to get a  
valid filepath? One could simply replace all suspicious characters  
with an underscore (or something else), but that is not very elegant  
and feels like fighting the framework.


Cheers,

Knut


try using -[NSString fileSystemRepresentation]

--
What is a woman that you forsake her, and the hearth fire and the home  
acre,
to go with the old grey Widow Maker.  --Kipling, harp song of the Dane  
women

Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa and NSLog

2008-11-14 Thread Tommy Nordgren


On 10 nov 2008, at 07.16, Marcus wrote:



9 nov 2008 kl. 23.03 skrev Tommy Nordgren:


Is it possible to open an Additional file for use by logging in Cocoa
(I want it to contain ONLY the info logged from my App)


You can do that by just redirect standard error to a file. Since  
each process has their own set of file descriptors it will only  
affect your application.


int fd = creat ("/Users/marcus/my_log", S_IRUSR | S_IWUSR | S_IRGRP  
| S_IROTH);

close (STDERR_FILENO);
dup (fd);
close (fd);
NSLog(@"this will be written to my_log");

Marcus


	The specified method don't work. The default console log don't get a  
copy this way.
	A similar methods works if I forks, and pipes standard error into the  
tee command.
	I had really hoped there would be a method to set up the standard  
error fd to

echo it's data to multiple file descriptors in my process.

--
Skinheads are so tired of immigration, that they are going to move to  
a country that don't accept immigrants!

Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Inviting to comment on Cocoa categories

2008-11-09 Thread Tommy Nordgren


On 10 nov 2008, at 00.07, Graham Cox wrote:



On 10 Nov 2008, at 5:47 am, Tommy Nordgren wrote:


//  TN+NSAffineTransform.h
@interface NSAffineTransform (TNGraphics)



A comment on naming conventions. It doesn't matter that much  
especially if you are just using them privately, but there's an  
inconsistency here. Usually I name category files primarily by the  
class they are a category on + the name of the category:


NSAffineTransform+TNGraphics.h

This seems to be a widely adopted convention.

Doing this allows you to see at a glance that the file contains  
functions which extend NSAffineTransform, which you might miss if  
the name doesn't start with the class. I tend to work with a  
narrowish files column in Xcode which truncates long filenames, so I  
find this helps there too.



+(NSAffineTransform *) transformRotatedAroundPoint:(NSPoint) p  
degrees:(CGFloat) deg;



A handy method, but I wonder if it could be named to be more  
readable with respect to its actual function, for example:


+ transformWithPoint:rotatedByDegrees:


this way each section of the method name is a functional description  
in its own right, whereas degrees: isn't (though in this case it's  
easy to guess what is wanted there). Also, it's not the transform  
that is rotated, so +transformRotatedAroundPoint: is not an accurate  
description of what the method returns. However I'm sure this could  
be improved upon further, just my first thought.


--Graham

Good point.
A better name would probably be:
+ transformRotatingAroundPoint: byDegrees.
I will change it so.
I don't think the name you suggested accurately describes that the  
supplied point is the origin of the rotation.

--
The three things an undertaker should never say to a client:
-Nice doing business with you.
-Welcome back.
-Have a nice day. (The King of ID)
--
Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Cocoa and NSLog

2008-11-09 Thread Tommy Nordgren

Is it possible to open an Additional file for use by logging in Cocoa
(I want it to contain ONLY the info logged from my App)
--
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
[EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Inviting to comment on Cocoa categories

2008-11-09 Thread Tommy Nordgren


TN+NSAffineTransform.h
Description: Binary data


TN+NSBezierPath.h
Description: Binary data


TN+NSAffineTransform.m
Description: Binary data


TN+NSBezierPath.m
Description: Binary data



I would like comments on the following Categories on NSBezierPath and  
NSAffineTransform.
In particular I would like comments on other suitable methods to be  
added, and alternate protocols

to set up input data.
I'm not including the code in the body of the message,but as  
Attachments.

//
//  TN+NSAffineTransform.h
//  GraphicsUtilities
//
//  Created by Tommy Nordgren ([EMAIL PROTECTED]  http://www.tommynordgren.com 
) on 2008-11-09.

//  Copyright 2008 Tommy Nordgren. All rights reserved.
//

#import 


@interface NSAffineTransform (TNGraphics)

+(NSAffineTransform *) transformRotatedAroundPoint:(NSPoint) p degrees: 
(CGFloat) deg;


+(NSAffineTransform *) transformRotatedAroundPoint:(NSPoint) p radians: 
(CGFloat) rad;


+(NSAffineTransform *) transformByTranslatingOriginToPoint:(NSPoint) p;

@end

//
//  TN+NSBezierPath.h
//  GraphicsUtilities
//
//  Created by Tommy Nordgren ([EMAIL PROTECTED]  http://www.tommynordgren.com 
) on 2008-11-09.

//  Copyright 2008 Tommy Nordgren. All rights reserved.
//

#import 


@interface NSBezierPath (TNGraphics)

+(NSBezierPath *) bezierPathWithOvalInRectOfWidth:(CGFloat) w height: 
(CGFloat) h centeredAt:(NSPoint) p rotatedByDegrees:(CGFloat) d;
+(NSBezierPath *) bezierPathWithOvalInRectOfWidth:(CGFloat) w height: 
(CGFloat) h centeredAt:(NSPoint) p rotatedByRadians:(CGFloat) r;
+(NSBezierPath *) bezierPathWithRectOfWidth:(CGFloat) w height: 
(CGFloat) h centeredAt:(NSPoint) p rotatedByDegrees:(CGFloat) d;
+(NSBezierPath *) bezierPathWithRectOfWidth:(CGFloat) w height: 
(CGFloat) h centeredAt:(NSPoint) p rotatedByRadians:(CGFloat) r;


@end

---
See the amazing new SF reel: Invasion of the man eating cucumbers from  
outer space.
On congratulations for a fantastic parody, the producer replies :  
"What parody?"


Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]

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

2008-11-02 Thread Tommy Nordgren


On 31 okt 2008, at 02.30, Peter N Lewis wrote:

AI am a newbie to the cocoa world (PC -> Mac switcher).  I have a  
fair amount of experience coding in C and C++ and I am just getting  
into Obj C now.  Right now I am trying to learn the language idioms  
and patterns in the Obj C world, specifically, when do you find  
yourself mixing C++ code with your Obj C code in your project?  How  
often do you do that? What's the pros and cons of doing that?


Keyboard Maestro was written entirely in in C++/Carbon.  There were  
a couple useful Cocoa classes, so I mixed them in (eg Cocoa has a  
method to expand ~ in file paths).


When it was time to start moving to Cocoa more seriously, I just  
turned the compiler on to Objective C++ for the entire project,  
recompiled and there was essentially no change (no size or speed  
changes were noticeable).  Then I just started writing Cocoa objects  
for various UI.  Many of my Cocoa objects have a C interface to  
create them and a C++ pointer as a "delegate" to interface with.


About the biggest issue is that you cannot have C++ objects in an  
Objective C object (their constructors and destructors wont be  
called).  You can happily have pointers to C++ objects though, you  
just have to manage the creation and destruction yourself (which can  
be a bit of a pain in Cocoa as there is no single constructor place  
- but fortunately (or not) you wont be using Garbage Collection any  
time soon so at least dealloc is a single point for removal in most  
cases).


	You can invoke the constructors and destructors yourself, using  
placement new. Also, supporting GC is no big deal:

simnply add a finalize method to destroy c++ objects.

You also need tor read the Apple docs on mixing Carbon & Cocoa.

Introduction to Carbon-Cocoa Integration Guide
<http://developer.apple.com/documentation/Cocoa/Conceptual/CarbonCocoaDoc/CarbonCocoaDoc.html 
>



But basically, "it just works".  There isn't much pain with simply  
using Objective C++ and writing parts of your code in Cocoa.


Enjoy,
  Peter.

--
 Keyboard Maestro 3 Now Available!
   Now With Status Menu triggers!

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/tommy.nordgren%40comhem.se

This email sent to [EMAIL PROTECTED]


--
The three things an undertaker should never say to a client:
-Nice doing business with you.
-Welcome back.
-Have a nice day. (The King of ID)
--
Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Porting from Windows to Mac

2008-10-30 Thread Tommy Nordgren


On 30 okt 2008, at 08.31, Rakesh Singhal wrote:


Hi all

I have to port a project form windows to Mac. The existing code is in
C++ and classes are inherited from MFC library classes. Do I have any
alternative for MFC in MAC OS?

I have gone through some posting on Apple lists and I found that there
are 2 cross-platform tools Power Plant and Code Warrior. Which one is
better and If I want to use any of them then do I need to install them
on Mac system and will I need to modify the code very much? Which type
of application do I need to choose for porting in Mac cocoa or carbon
or something?

Thanks in advance.

Regards
rksinghal
___


I suggest you port your app to use the Qt framework from TrollTech
(http://www.trolltech.com) It is implemented in C++, and the native  
layer

on Mac OS X is implemented using Carbon and Cocoa.
You might have to implement some modules in your app differently
depending on target OS, particularly to get native look and feel.
The most important thing with using Qt, is that you will be able to
port your app to any unix dialect that uses X windows, as well.
--
What is a woman that you forsake her, and the hearth fire and the home  
acre,
to go with the old grey Widow Maker.  --Kipling, harp song of the Dane  
women

Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Cocoa and Printing (Advanced Q)

2008-10-28 Thread Tommy Nordgren


On 27 okt 2008, at 18.42, David Duncan wrote:


On Oct 26, 2008, at 3:06 PM, Tommy Nordgren wrote:


A specific printer can be used ONLY by a special app.


Any printer that can be seen by Print Center can be used by all  
applications by default. If you are a printer vendor, then you can  
do additional things, but you will need to write to CUPS (the  
subsystem that eventually handles all printing on Mac OS X).



Changing printer settings for an App affects that app only.


Some printer settings are system wide, some are tied to print  
sessions. What settings do you need to change?

--
David Duncan
Apple DTS Animation and Printing

	I want to reserve a printer for economy software, (i fact a submodule  
of it) since the invoice

function will print on particularly expensive invoice paper.
--
The three things an undertaker should never say to a client:
-Nice doing business with you.
-Welcome back.
-Have a nice day. (The King of ID)
--
Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to check the number of pending events in the application event queue?

2008-10-27 Thread Tommy Nordgren


On 27 okt 2008, at 13.54, Oleg Krupnov wrote:


In my app I'd like to perform some background task without affecting
the responsiveness of the UI. To avoid multi-threading, I just
postpone the task to a moment when the user becomes and stays idle for
a certain time.

I call NSObject's performSelector: afterDelay: and then use
CGEventSourceSecondsSinceLastEventType to check if the idleness period
has elapsed. If not, I wait again the remaining time, else I begin
performing the task.

Also, because the background task is quite lengthy, I make the task
poll periodically if the user has become active during the task, and
in this case postpone the task's continuation again until the user
becomes idle again.

This solution seems to be quite good, but for one question : how do I
check if there are pending events in the application's queue right at
the moment of timer firing? This would work as a double-check that
there are no pending tasks for the application (e.g. other periodic
events of the app) that would always have to be done before the
low-priority background task.

I tried NSApplication's nextEventMatchingMask, but it blocks execution
if there are no events, whereas I'd like it to return nil. Any other
suggestions?
___


Use a separate thread.
--
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
[EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Cocoa and Printing (Advanced Q)

2008-10-26 Thread Tommy Nordgren

Is it possible to configure printing via Cocoa API:s
such that:
A specific printer can be used ONLY by a special app.
Changing printer settings for an App affects that app only.
--
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
[EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Security - Write to protected directory

2008-10-24 Thread Tommy Nordgren


On 3 okt 2008, at 16.39, Michael Ash wrote:


...snip



Nope! AEWP is a rather broken API in more ways than one. One of the
ways that it's broken is that it is *impossible* to correctly use it
without a subprocess which will cooperate with you. The reason for
this is that you *must* use wait4 or waitpid to reap the zombie that
will be created when the subprocess terminates, but AEWP provides *no*
way to get the pid. (You cannot use wait or wait3 because those could
	NOPE. As soon as the App terminates, any unreaped subprocess will  
become a child

of, and finally reaped by launchd


end up inadvertently reaping a child process spawned by a library
you're using.) So your subprocess must have a way to communicate its
pid back to the parent, and do so very early before it does anything
that could make it crash or otherwise terminate.

Correct use of AEWP is extremely weird and un-fun. I definitely
recommend finding some of Apple's sample code on the subject, and then
adapting it to do what you need, rather than trying to figure out how
to use it on your own. In particular, the BetterAuthorizationSample,
while probably not doing what you need, is full of useful commentary
on how it works and how it gets around the various problems with the
AEWP API:

http://developer.apple.com/samplecode/BetterAuthorizationSample/index.html

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/tommy.nordgren%40comhem.se

This email sent to [EMAIL PROTECTED]


--
What is a woman that you forsake her, and the hearth fire and the home  
acre,
to go with the old grey Widow Maker.  --Kipling, harp song of the Dane  
women

Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Restoring a .nib's Edit menu

2008-09-28 Thread Tommy Nordgren


On Sep 28, 2008, at 3:32 PM, Matt wrote:

I should add that I currently have all the menu items connected, the  
only
ones I can't seem to get working are the Find Next, and Find  
Previous, and
Use Selection For Find. The standard Edit menu in a new .nib does  
not show
any default action for these items. I also tried replacing this  
submenu with
the standard one available in the IB palette. I'm wondering if these  
need to

be connected to the standard Find window in some way?

Again, sorry for the off-topic question. Any advice or pointers in  
the right

direction greatly appreciated.
Thank you



On Sun, Sep 28, 2008 at 5:36 AM, Matt <[EMAIL PROTECTED]> wrote:

I apologize that this isn't a direct Cocoa question but I'm in a  
bit of jam
here and am desperate for any help. My edit menu was removed  
accidentally
from my app's main nib file. In IB3 I dragged a new Edit menu into  
the menu
bar, but nothing on it is working. I can make some of the items  
work by
directly connecting the items (such as Copy, Paste, etc.) onto the  
First

Responder object and choosing their actions manually.

However, some of the other normal Edit functions are still  
disabled, such

as the standard Find/Replace dialogue. I cannot find the appropriate
actions/connections for all of these items (performFindAction is  
not working

fully).

Is there a more direct way of restoring a .nib's standard Edit menu  
with

its proper default connections?

Thank you very much for your time


	Generate a new project from the same template your project is  
instantiated from.

Then you can open both nibs in IB to compare them manually.
--
Skinheads are so tired of immigration, that they are going to move to  
a country that don't accept immigrants!

Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Finding other apps' paths - deterministically!

2008-09-21 Thread Tommy Nordgren


On Sep 21, 2008, at 11:25 PM, Peter O'Gorman wrote:


Peter O'Gorman wrote:

Tommy Nordgren wrote:

On Sep 21, 2008, at 6:36 AM, Michael Ash wrote:


On Sat, Sep 20, 2008 at 12:57 PM, Tommy Nordgren
<[EMAIL PROTECTED]> wrote:

 Use NSTask with the command line find -x /  -name '*.app'


Dunno how I missed the -x, does not matter though, find -x / on a  
large

filesystem with many files will take too long.

Peter


	Sure, but you don't need to do the scan every time. See the comment  
on caching.






Do this on a separate thread, and cache the result.
I highly recommend against this approach. One problem is that it  
will

fail badly if any of the returned paths contain the \n character,
   Not true. With the given command line, find will return  
absolute paths.

So this anomaly is easily detected when parsing find output


Don't do find /, please! It could end up looking through every  
directory

entry on a remote petabyte filesystem. Even if you restrict it to
"local" storage, you could be going to the network for iSCSI devices,
and if you avoid that, some people have multi-terabyte filesystems  
with

a lot of directory entries, they will be disappointed in any software
that does a find /.


--
What is a woman that you forsake her, and the hearth fire and the home  
acre,
to go with the old grey Widow Maker.  --Kipling, harp song of the Dane  
women

Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Finding other apps' paths - deterministically!

2008-09-21 Thread Tommy Nordgren


On Sep 21, 2008, at 6:36 AM, Michael Ash wrote:


On Sat, Sep 20, 2008 at 12:57 PM, Tommy Nordgren
<[EMAIL PROTECTED]> wrote:

  Use NSTask with the command line find -x /  -name '*.app'
Do this on a separate thread, and cache the result.


I highly recommend against this approach. One problem is that it will
fail badly if any of the returned paths contain the \n character,

Not true. With the given command line, find will return absolute paths.
So this anomaly is easily detected when parsing find output


which is a perfectly legal path character. For another it will fail if
the new process would exceed the user's process limit, a limit which
tends to be much lower than most other resource limits and thus much
easier to encounter in realistic situations.
	Firstly you can just increase the soft limit. Hard limits on Mac OS X  
is very generous.
	Secondly it would fail because maximum number of processes have been  
reached,

you can simply retry later.
	I have never had a process break because it has reached the maximum  
allowed cpu-time,

except in situations where I've deliberately set it very low,



For the original problem, I'd recommend using something like
LSCopyApplicationURLsForURL() if it's at all possible. Of course maybe
you have data that isn't good for that, but if you can use it then
that's the way to go.

If you must search the disk, use Spotlight if you can. It will be
vastly faster than anything else. The downside is that it won't work
if indexing is disabled or if the desired application is in an
excluded directory.

	Using Spotlight to search for applications won't work, because some  
open-source

packages install apps in directories that's not searched by spotlight,
For example - the default install path for Qt is in directory
/usr/local/Trolltech/Qt-

If you must search the whole disk without Spotlight, use
NSDirectoryEnumerator. Or if you're the sort who likes to use
unsupported private functions, you may be interested in the discussion
near the bottom of http://www.cocoadev.com/index.pl?AllApplications

Mike



---


See the amazing new SF reel: Invasion of the man eating cucumbers from  
outer space.
On congratulations for a fantastic parody, the producer replies :  
"What parody?"


Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Finding other apps' paths - deterministically!

2008-09-20 Thread Tommy Nordgren


On Sep 18, 2008, at 8:47 PM, Jerry Krinock wrote:


The methods for finding applications,

  -[NSWorkspace fullPathForApplication:]
  -[NSWorkspace absolutePathForAppBundleWithIdentifier:]
  AppleScript's  'path to application'

all return only ONE result.  If there is more than installation of  
the application, which often happens out here in real life, the  
above methods will often pick different installations, and even if  
you run the same methods several minutes apart I sometimes get  
different answers.


Is there any way to make these methods behave deterministically?  If  
not, what's a better way?  Do I have to do a Spotlight search?  I  
know that unix 'find' would be way too slow.


Thanks,

Jerry Krinock


Use NSTask with the command line find -x /  -name '*.app'
Do this on a separate thread, and cache the result.

--


What is a woman that you forsake her, and the hearth fire and the home  
acre,
to go with the old grey Widow Maker.  --Kipling, harp song of the Dane  
women

Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Trouble with Scripting Bridge

2008-08-31 Thread Tommy Nordgren


On 31 aug 2008, at 03.12, Peter Stirling wrote:


Hi,

I've been trying to do some python scripting of iTunes using pyobjc  
and ScriptingBridge, and I've been having some problems (I reduced  
everything to objective-c on its own in order work out if it was  
caused by pyobjc).


According to:

http://developer.apple.com/releasenotes/scriptingautomation/RN-ScriptingBridge/index.html

running:
  sdef /Applications/iTunes.app/ | sdp -f h --basename iTunes

should generate an objective-c header file which you can use in  
conjunction with [SBApplication  
applicationWithBundleIdentifier:@"com.apple.iTunes"]

(which it does).

An excerpt from the file I generated (included in the zip file):

@interface iTunesTrack : iTunesItem
...
@property BOOL gapless;  // is this track from a gapless album?
...
@end

So there should be an accessor method on iTunesTrack objects called  
gapless that returns a BOOL.


[track respondsToSelector:@selector(gapless)] returns YES

However it doesn't seem to work, the code provided in the zip  
archive (when executed on my machine), produces a list of all the  
gapless tracks in my mp3 collection, but every line ALSO claims that  
the track is 'not gapless'.


(The original python code that I was using seemed to get different  
answers depending on ordering of operations, including calling the  
accessor twice in a row on the same object giving different answers).


Am I doing something wrong? The other accessors that I call appear  
to return the right data, though I've not done exhaustive testing.


(As a background to what I'm doing, I want my iTunes playlists  
random except for gapless cds, which I want to be seamless, the  
shuffle provided by itunes can't make that distinction for itself).





From test.m :
  NSPredicate* predicate = [NSPredicate  
predicateWithFormat:@"gapless=YES"];


this should probably be :   . predicateWithFormat:@"gapless==YES"];
---
See the amazing new SF reel: Invasion of the man eating cucumbers from  
outer space.
On congratulations for a fantastic parody, the producer replies :  
"What parody?"


Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Hillegass, Third Edition, Chapter 18

2008-07-15 Thread Tommy Nordgren


On 15 jul 2008, at 13.25, Jon Buys wrote:


...snip
Drawing a new rect on every mouseDown is the main problem I'm having  
now,
but I think it's because I'm not adding the rect to an  
NSMutableArray.  I'm
working on that now, but I've run out of time this morning.  How can  
I add a

rect to an array?  Do I have to convert it first?


...
Don't even think about storing the NSRects in an NSArray.
NSRect is a struct -- not a class
Instead store NSBezierPath instances, or create an oval class.
---
See the amazing new SF reel: Invasion of the man eating cucumbers from  
outer space.
On congratulations for a fantastic parody, the producer replies :  
"What parody?"


Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to converting a Carbon nib to Cocoa?

2008-07-03 Thread Tommy Nordgren


On 3 jul 2008, at 14.54, Kyle Sluder wrote:

On Thu, Jul 3, 2008 at 8:27 AM, Tommy Nordgren <[EMAIL PROTECTED] 
> wrote:
So it is a matter of writing and applying a suitable xsl stylesheet  
file.


The transformations required to obtain a meaningful Cocoa XIB from a
Carbon NIB are impossible to express in XSL.  Or any language for that
matter.  It requires human thought, because Carbon NIBs and Cocoa XIBs
do not express the same concept.  Even if you could transform a
particular Carbon NIB to a Cocoa XIB (certainly a challenge,
considering the spec is not documented and warned to be very fragile)
it would be a very bad idea to do so, particularly because they would
not be semantically equivalent.

--Kyle Sluder
	Not correct. Of course connections can't be created this way, but it  
is certainly possible

to replace carbon objects with the equivalent Cocoa objects.
	Niltargeted actions for the standard menu items can also be set up  
this way.

--
Skinheads are so tired of immigration, that they are going to move to  
a country that don't accept immigrants!

Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: How to converting a Carbon nib to Cocoa?

2008-07-03 Thread Tommy Nordgren


On 3 jul 2008, at 06.47, Steve Christensen wrote:

This question was asked recently on the carbon-dev list and the  
answer was that there is no way to automate the process, nor even a  
method to get you part-way. Unfortunately this is likely to be one  
of those painful transitions for you...




it is probably possible to do, with significant  difficulties.
Carbon nibs are bundles, with the real payload saved as an xml file
IB [version bundled with xcode 2.x] can also save nibs in a format  
where the principal file is

XML-encoded.
With the latest IB, they can also be converted to xib, a flat file xml  
format.
So it is a matter of writing and applying a suitable xsl stylesheet  
file.

Writing such a stylesheet is however, far from trivial.

On Jul 2, 2008, at 8:31 PM, Fosse wrote:

It would be a nightmare to recreate them by hand... , especially  
for the big

project which needs to move to Cocoa..

No better method?


On Mon, Jun 30, 2008 at 3:37 AM, Christopher Pavicich  
<[EMAIL PROTECTED]> wrote:



Hi:

 There is no way to automatically convert a Carbon Interface Builder
Document into a Cocoa Interface Builder Document.
 You are going to need to recreate all of your Carbon dialogues in  
Cocoa.

By hand.

--Chris


On Jun 29, 2008, at 1:59 AM, Fosse wrote:

My Carbon nib contains a lot of dialogs.  I want to make it be  
used by
another cocoa application and don't want to create all those  
dialogs and
econstruct the entire control hierarchy manually in the Interface  
Builder.
I don't care about connections, I'll wire them up myself. I'm  
just hoping

to avoid repeating the layout work.

The Cocoa nib uses binary file objects.nib which is different  
with the xml
file used byCarbon nib . I can't find any way to convert it with  
either

Interface Builder or nibtool.

Does anyone know of an automated method for doing the  
conversion?  Or

method to create Cocoa NIB without using Interface Builder?

I found two related questions here but no more answers..
http://lists.apple.com/archives/cocoa-dev/2001/Jul/msg00243.html
http://lists.apple.com/archives/carbon-development/2003/Aug/msg00161.html

Thanks a lot!


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/tommy.nordgren%40comhem.se

This email sent to [EMAIL PROTECTED]


--
Skinheads are so tired of immigration, that they are going to move to  
a country that don't accept immigrants!

Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Creating AppControllers in InterfaceBuilder 3.1

2008-06-30 Thread Tommy Nordgren


On 30 jun 2008, at 16.14, [EMAIL PROTECTED] wrote:


Hi

I'm writing my first project in Leopard and can't figure out how to  
accomplish the old
"Subclass NSObject/Generate Files/Instantiate" series of steps in  
Interface Builder 3.1.


I'm sure Interface Builder has a new way to do that but I can't find  
it.


Any help appreciated




You create the files from an XCode file template,
and drag the header file into IB
-
This sig is dedicated to the advancement of Nuclear Power
Tommy Nordgren
[EMAIL PROTECTED]




___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: looking for a crc code

2008-06-14 Thread Tommy Nordgren


On 14 jun 2008, at 19.49, Michael Hall wrote:



...snip



#import 
# include 
#include 

int main(int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

unsigned long crc = crc32(0L, Z_NULL, 0);
char * test = "TEST";

crc = crc32(crc,test,4);
 fprintf(stdout,"crc=%i\n",crc);
}

compiled with...
gcc -framework Cocoa -lz -o testcrc testcrc.m
(Note the -lz for zlib also find some copy of zlib.h for more info  
on the crc32() method or a adler or other zlib supported alternative)


Unfortunately, testing got sort of inconsistent results.
./testcrc
crc=-286616648

doesn't seem to work out quite the same as...
crc32 test.txt
f783d7be
(man crc32, it appears to be the tcl version mentioned in the blog  
above.).


The crc's as far as I know should be the same here, so not quite  
sure what the deal is there, but zlib crc's I think should always be  
available.


Mike Hallhallmike at att dot net
http://www.geocities.com/mik3hall
http://sourceforge.net/projects/macnative



	The problem is 1: You have inserted a newline or a return character  
in the file you use for testing
2: In order to compare your code should print with the %x  
command line directive , since the

command line tool you compare with uses hexadecimal
--
What is a woman that you forsake her, and the hearth fire and the home  
acre,
to go with the old grey Widow Maker.  --Kipling, harp song of the Dane  
women

Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Quit iTunes

2008-05-24 Thread Tommy Nordgren


On 24 maj 2008, at 18.33, Mr. Gecko wrote:


How would I do that?


	NSAppleScript * script = [[[NSAppleScript alloc]  
initWithSource:@"tell application \"iTunes\" \n quit \nend tell"]  
autoRelease];

[script executeAndReturnError: nil];




I have been looking for a while and I found aevtquit but I can't  
find out how to send.

On May 24, 2008, at 11:13 AM, Tommy Nordgren wrote:



On 24 maj 2008, at 17.49, Mr. Gecko wrote:

How would I quit iTunes. There is a way to launch it with  
NSWorkspace but how about quit?

___

Send a quit AppleEvent
--
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
[EMAIL PROTECTED]




___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/tommy.nordgren%40comhem.se

This email sent to [EMAIL PROTECTED]


--
Skinheads are so tired of immigration, that they are going to move to  
a country that don't accept immigrants!

Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Quit iTunes

2008-05-24 Thread Tommy Nordgren


On 24 maj 2008, at 17.49, Mr. Gecko wrote:

How would I quit iTunes. There is a way to launch it with  
NSWorkspace but how about quit?

___

Send a quit AppleEvent
--
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
[EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Where is mach_port_deallocate()?

2008-04-21 Thread Tommy Nordgren


On 22 apr 2008, at 02.50, stephen joseph butler wrote:


egrep -R mach_port_deallocate /usr/include

	Even better - use the search dialog in the free Text Editor  
TextWrangler from BareBones Software
(www.barebones.com) Then you will get a dialog where you can browse  
any results.

---
See the amazing new SF reel: Invasion of the man eating cucumbers from  
outer space.
On congratulations for a fantastic parody, the producer replies :  
"What parody?"


Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Bypassing inter-cell navigation for NSButtonCell in NSOutlineView

2008-03-02 Thread Tommy Nordgren


On 2 mar 2008, at 13.29, Nicholas Riley wrote:


...sbip...


7. overriding keyDown: in the outline view to intercept Tab, which  
works fine, except...



- Back tabbing into a table will select the last focusable cell.


and I can't figure out how to stop that from happening.

Help?

--
Nicholas Riley <[EMAIL PROTECTED]> | <http://www.uiuc.edu/ph/www/njriley 
>


	You probably need to modify your keyDown: method to intercept  
backtabs as well


--
What is a woman that you forsake her, and the hearth fire and the home  
acre,
to go with the old grey Widow Maker.  --Kipling, harp song of the Dane  
women

Tommy Nordgren
[EMAIL PROTECTED]



___

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

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

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

This email sent to [EMAIL PROTECTED]


Re: Event Logging

2008-02-26 Thread Tommy Nordgren


On 26 feb 2008, at 14.31, Philip Bridson wrote:

Yeah that is what I mean. I was reading in the Documentation though  
that paths to file system folders should not be hard coded. This may  
sound a little dumb but is the freopen a C function? I used to write  
in C++ before Obj-C so I haven't used it before. Is it best to use  
this method or to use File Manager?


Many thanks.

Phil.


freopen is a standard ANSI/ISO library function.
--
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
[EMAIL PROTECTED]


___

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

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

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

This email sent to [EMAIL PROTECTED]