NSOutlineView
Hi all I'm new to cocoa. I want to display the outline view item by a disclosure triangle, then one checkbox, then text field to display the name of the nodes. I didn't find any documentation regarding this. How can I do this ? Thanks in advance. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Binding NSButton state to an NSMutableArray inside an NSMutableArray
Hi you did a part of the work. Using a second array controller is correct, because you have a second array. What you need is a UI, that depends on the number and content of the items contained in the second array. There are two views, that provide this: NSTableView and – I think this is the correct one for your UI – NSMatrix. So try using an instance of NSMatrix. Cheers Amin Am Fr,15.08.2008 um 20:10 schrieb TouchCab Developer: Hi list. I'm new to the list and fairly new to cocoa, although many years of programming assembler, C and C++ helps a lot. I'm getting the hang of Objective-C and enjoying it very much. In my App Delegate file I keep an NSMutableArray of base objects which is my application's data core. I need an arbitrary number of Windows/Panels to access this array, and show/manipulate the contents of one of the base objects, selectable by a designated key in my object using an NSTableView in the window. This works nicely for most objects inside the base objects, binding an NSArrayController to the array. Each base object, however, holds an NSMutableArray of NSNumbers. I want the boolean value of these NSNumbers to represent the state of an equal number of buttons in the window, so that if one of the NSNumbers changes its value, the state of the corresponding NSButton changes as well. The message flow is: 1) Click button - IBAction: send message to network device and reset button to its former state (to show nothing happened yet). 2) Receive reply from network device - update the NSNumber, thereby updating the state of the button to show the user that something happened out there The reason for doing it this way is I want to show the user that the change actually took place in the network device, and not just the button changing state, assuming everything went well. I use an on/ off button, since momentary buttons don't show their state. The reply from the network device holds information about the index in the array, and I can get as far as setting the NSNumbers in the nested array using replaceObjectAtIndex from the input stream handler, but I can't bind that array to the button states. I have tried a second NSArrayController (well, I've tried a lot of things), and I can bind to the nested array, but I can't for the life of me figure out how I bind the NSNumbers in the nested array to my button states. Perhaps I need to place the buttons in an array and bind the contents of the array in the base object to the contents of the array in the NSWindowController? For now, I have scrapped the nested array altogether and have a bunch of internal variables with getters and setters in both ends. In the input stream handler, I build a selector to the setter functions from the index information. It works, but it seems very un- cocoa-ish, and it's certainly not pretty. Does anyone know how to do this? Regards, and thanks in advance, Jens ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de This email sent to [EMAIL PROTECTED] Amin Negm-Awad [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: CF Network memory leak? Or false positive in Leaks?
On Aug 17, 2008, at 22:40 , Lawrence Johnston wrote: Hey everybody, I've got a situation I'm kind of puzzling over. If I run my program though leaks, I'm getting a leak at a certain point, but where it's coming from is really confusing me. I've pulled the urlRequest entirely out into a new dummy program and I'm still getting a leak here. This is the code I'm using: [snip] and then if I run it using a leak I'm getting a leak, for example the last time I got a leak of size 3.58KB at 0.16 minutes (9.6 seconds). The leak is as follows: # Category EventType Timestamp Address SizeResponsible Library Responsible Caller 0 GeneralBlock -3584 Malloc 00:05.5380x83b200 3584CFNetwork httpWrFilterOpen 1 GeneralBlock -3584 Free00:14.5390x83b200 -3584libSystem.B.dylib _pthread_body 2 GeneralBlock -2048 Realloc00:14.7030x83b200 2048CFNetworksendDidReceiveDataCallback The weird part is as far as I can tell the memory in question is actually getting released! (at 14 seconds) So is this some sort of weird false positive? Or am I missing something? It looks to me like the 3.58KB was released... that's number 1 on your list, so there is not leak. The memory you have allocated (2048 bytes) looks like it's the read buffer that was created for you and which you either haven't read yet or simply hasn't been released yet. CFNetwork may also keep the buffer around in case you call it again to avoid allocating and reallocating memory all the time. /jason smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSOutlineView
Hi, do you want to display all three items (triangle, icon, text) in one column? Than you need an ImageAndTextCell. Browse your examples folder to get it. Amin Am Mo,18.08.2008 um 08:38 schrieb [EMAIL PROTECTED]: Hi all I'm new to cocoa. I want to display the outline view item by a disclosure triangle, then one checkbox, then text field to display the name of the nodes. I didn't find any documentation regarding this. How can I do this ? Thanks in advance. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de This email sent to [EMAIL PROTECTED] Amin Negm-Awad [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: Changing NSTextFieldCells' editing appearance?
Am Fr,15.08.2008 um 19:41 schrieb [EMAIL PROTECTED]: -setBackgroundColor: didn't work? Nope, it didn't. But even if it would've, the background would have been visible at all times. I'm sorry if I didn't write clearly enough, No, I speak english badly enough to misunderstand this. :-) but it's only when the cell is being edited that the background becomes black (Instead of white like it usually does). When I'm not editing the cell, the cell doesn't have a background. Did you read the documentation about the relationship between cells and views? Is that in the Control and Cell programming topics for Cocoa? All I could find is that NSTextField uses NSTextFieldCell, but I'm not really sure if that's what you meant? The behaviour of an NSTextField depends on the behaviour of an NSTextFieldCell. Most of the behaviour of an NSTextField is done by an NSTextFieldCell. So it is a little bit strange to ask, whether a cell should behave as its control. Probably you can clearify this: - Do you use an NSTextFieldCell without its NSTextField? - Which specific behaviour the control did fail using the cell? Cheers, Amin Thanks for you help, Tim Andersson Amin Negm-Awad [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: NSUInteger hash
Hi Steve, Am So,17.08.2008 um 18:43 schrieb Steve Wart: Hi Aaron, That's always a good question to ask. I'm porting a Smalltalk/OpenGL maze application I wrote a few years ago to Cocoa. The maze is initialized by creating a 2D matrix of Room objects which are separated by Wall objects. Every room has an ordered collection of walls which I've put into an NSMutableArray. Every wall has a start point and an end point and exists in exactly one room. So the common wall separating a pair of rooms is actually represented by two walls. I think, that this is the root of the problem. Two rooms are seperated by one wall. This is the (virtual) reality. Modelling this in a different way (rooms are seperated by two surfaces) will cause problems in many ways. What about remodelling this struture? If you need double attributes for a wall like color, hasWallPaper …, which are different on each surface, yo should model it this way: One wall entity with two surface entities. Actually you divide one thing (wall) into two things (surfaces) and get problems, to glue it together again. Cheers, Amin I go through the rooms in random order, pick a wall at random, and knock it down (also being careful to knock down the corresponding wall in any adjacent rooms). By knocking down a wall, two rooms become merged into one. When I have only one room left, it means that the maze is complete. I depend on isEqualTo: to compare the walls. They are both created from the same set of points but they are different objects, so I can't use an identity comparison. The Smalltalk code is reasonably clean but it's bloating unpleasantly in Objective C so I will probably need to take a higher-level look at what I'm trying to accomplish. The original maze algorithm was cribbed from C so it shouldn't be too hard to make it work :-) Steve On Sun, Aug 17, 2008 at 12:10 AM, Aaron Lees [EMAIL PROTECTED] wrote: What are you trying to do? It's usually a bad idea to compare floating point values for equality since you will run into subtle bugs to do with rounding. If you want to use your objects as dictionary keys it's often better to use a pointer equality rule instead of semantic equality. You can do this with NSMapTable without any overrides in your class. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de This email sent to [EMAIL PROTECTED] Amin Negm-Awad [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]
Right place to unobserve notifications in a document
Hi, for some teaching reasons I have a document class, which observes a notification. Of course I have to unobserve this notification, when the document is closed. Doing this in -dealloc is no good design (fuunctional overhead in -dealloc, garbage collection …). But I read in the documentation, that -close (myDocument) wouldn't be called in some situations. Is there a save place to unobserve notifications? (Or providing other clean-up.) I couldn't find a hint in the documentation!? Cheers Amin Negm-Awad [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]
Hex representation of NSString
Hi,I'm trying to find a way how to get hex representation of NSString. I know I can convert NSString to NSData but I would like to rather not to do it. Or am I missing anything obvious? Thanks Robert ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Hex representation of NSString
Am Mo,18.08.2008 um 12:21 schrieb Robert Černý: Hi,I'm trying to find a way how to get hex representation of NSString. I know I can convert NSString to NSData but I would like to rather not to do it. Or am I missing anything obvious? Maybe: Do it this way. Why don't you like it? Cheers, Amin BTW: This isn't the hex representation, but the binary, serialized representation. Hex, octal and so on are terms used in relation to display something. Thanks Robert ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de This email sent to [EMAIL PROTECTED] Amin Negm-Awad [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: Hex representation of NSString
I don't like it because the string will be converted. I'm interested in exact values and even allowLossyConversion:NO doesn't guarantee it. Or am I wrong? Robert 2008/8/18 Negm-Awad Amin [EMAIL PROTECTED] Am Mo,18.08.2008 um 12:21 schrieb Robert Černý: Hi,I'm trying to find a way how to get hex representation of NSString. I know I can convert NSString to NSData but I would like to rather not to do it. Or am I missing anything obvious? Maybe: Do it this way. Why don't you like it? Cheers, Amin BTW: This isn't the hex representation, but the binary, serialized representation. Hex, octal and so on are terms used in relation to display something. Thanks Robert ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de This email sent to [EMAIL PROTECTED] Amin Negm-Awad [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: Problem redirecting NSLog() output to stderr
Thanks for the suggestions Mike. I had an intuition that my core Unix knowledge was wanting here. It turns out that a call to ftruncate(STDERR_FILENO, 0) does indeed do the job. Jonathan You can't detect that the stderr stream is no longer valid in these cases because, in fact, it *is* still valid. In UNIX, when you delete a file which some process still has open, that file doesn't actually go away. It remains on disk, and that process's file descriptor to it remains valid. Writes and reads continue to work as expected. Once the file descriptor is closed (or the process terminates, or the computer reboots, etc.) the file is finally removed from the disk. Rather than delete the file, it may work if you simply truncate it. New writes should then go to the end of the newly truncated file. If you really need to function after deletes (for example if you don't control the code that deletes the file, or you want to continue to function after the user trashes it from the Finder or something) then you can use kqueue to find out when something happens to the file, or even just poll it every few seconds if you can't rely on kqueue to be available on the filesystem in question. Mike Hello List My app consists of a GUI process, a daemon and a number of worker processes. Each of these processes has their stderr redirected via freopen() to the same log file. For the purposes of simple logging this arrangement works acceptably. There is a thread on why this should be: http://www.cocoabuilder.com/archive/message/cocoa/2003/6/16/3689 The user may however delete the shared log from the GUI. After this the daemon and worker process log output is lost. In those cases can I detect that the stderr stream is no longer valid? I have tried fcntl(), fileno(), fstat(), ftell() and feof() without success. My actual call to NSLog() is wrapped in a generic logging class. My only solution so far is to issue freopen(logfile, a, stderr) prior to each and every call to NSLog(). But this seems brutal. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Hex representation of NSString
Am Mo,18.08.2008 um 12:40 schrieb Robert Černý: I don't like it because the string will be converted. I'm interested in exact values Oh, may I ask why? The string class encapsulates its representation. Anyway, if you want to look inside the instance, you probably have to subclass it or doing some undocumentated stuff. Cheers, Amin and even allowLossyConversion:NO doesn't guarantee it. Or am I wrong? Robert 2008/8/18 Negm-Awad Amin [EMAIL PROTECTED] Am Mo,18.08.2008 um 12:21 schrieb Robert Černý: Hi,I'm trying to find a way how to get hex representation of NSString. I know I can convert NSString to NSData but I would like to rather not to do it. Or am I missing anything obvious? Maybe: Do it this way. Why don't you like it? Cheers, Amin BTW: This isn't the hex representation, but the binary, serialized representation. Hex, octal and so on are terms used in relation to display something. Thanks Robert ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de This email sent to [EMAIL PROTECTED] Amin Negm-Awad [EMAIL PROTECTED] Amin Negm-Awad [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: Hex representation of NSString
Actually,I'm trying to debug some weird problems with clipboard. My problem is that data copied into clipboard from legacy java application doesn't match data pasted into Cocoa application. I've got data with accented characters which gets converted through MacOS Roman encoding even the visual representation in java is correct. Robert 2008/8/18 Negm-Awad Amin [EMAIL PROTECTED] Am Mo,18.08.2008 um 12:40 schrieb Robert Černý: I don't like it because the string will be converted. I'm interested in exact values Oh, may I ask why? The string class encapsulates its representation. Anyway, if you want to look inside the instance, you probably have to subclass it or doing some undocumentated stuff. Cheers, Amin and even allowLossyConversion:NO doesn't guarantee it. Or am I wrong? Robert 2008/8/18 Negm-Awad Amin [EMAIL PROTECTED] Am Mo,18.08.2008 um 12:21 schrieb Robert Černý: Hi,I'm trying to find a way how to get hex representation of NSString. I know I can convert NSString to NSData but I would like to rather not to do it. Or am I missing anything obvious? Maybe: Do it this way. Why don't you like it? Cheers, Amin BTW: This isn't the hex representation, but the binary, serialized representation. Hex, octal and so on are terms used in relation to display something. Thanks Robert ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de This email sent to [EMAIL PROTECTED] Amin Negm-Awad [EMAIL PROTECTED] Amin Negm-Awad [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: Hex representation of NSString
Am Mo,18.08.2008 um 13:18 schrieb Robert Černý: Actually, I'm trying to debug some weird problems with clipboard. My problem is that data copied into clipboard from legacy java application doesn't match data pasted into Cocoa application. I've got data with accented characters which gets converted through MacOS Roman encoding even the visual representation in java is correct. Ah, for debugging purpose only. I think, that it is difficult to get the NSString backend, since it is a abstract baseclass to a class cluster. But there is a clipboard viewer app in the examples, which lets you inspect the raw data. Maybe this helps to find the problem. Cheers, Amin Robert 2008/8/18 Negm-Awad Amin [EMAIL PROTECTED] Am Mo,18.08.2008 um 12:40 schrieb Robert Černý: I don't like it because the string will be converted. I'm interested in exact values Oh, may I ask why? The string class encapsulates its representation. Anyway, if you want to look inside the instance, you probably have to subclass it or doing some undocumentated stuff. Cheers, Amin and even allowLossyConversion:NO doesn't guarantee it. Or am I wrong? Robert 2008/8/18 Negm-Awad Amin [EMAIL PROTECTED] Am Mo,18.08.2008 um 12:21 schrieb Robert Černý: Hi,I'm trying to find a way how to get hex representation of NSString. I know I can convert NSString to NSData but I would like to rather not to do it. Or am I missing anything obvious? Maybe: Do it this way. Why don't you like it? Cheers, Amin BTW: This isn't the hex representation, but the binary, serialized representation. Hex, octal and so on are terms used in relation to display something. Thanks Robert ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de This email sent to [EMAIL PROTECTED] Amin Negm-Awad [EMAIL PROTECTED] Amin Negm-Awad [EMAIL PROTECTED] Amin Negm-Awad [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]
NSCalendarDate to be deprecated
My application needs to obtain the day of year for a given date. In the past, this was easily done with an NSCalendarDate. // NSCalendarDate faces deprecation int dayOfYearForDate1(NSDate *_date) { NSTimeZone *gmtTimeZone = [NSTimeZone timeZoneForSecondsFromGMT:0]; NSCalendarDate *calendarDate = [_date dateWithCalendarFormat:nil timeZone:gmtTimeZone]; int day = [calendarDate dayOfYear]; return day; } NSCalendarDate faces deprecation: Use of NSCalendarDate strongly discouraged. It is not deprecated yet, however it may be in the next major OS release after Mac OS X v10.5. For calendrical calculations, you should use suitable combinations of NSCalendar, NSDate, and NSDateComponents, as described in Calendars in Dates and Times Programming Topics for Cocoa. The above advice led to two alternate functions: int dayOfYearForDate2(NSDate *_date) { NSTimeZone *gmtTimeZone = [NSTimeZone timeZoneForSecondsFromGMT:0]; NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; [calendar setTimeZone:gmtTimeZone]; NSDateComponents *components = [calendar components:NSYearCalendarUnit fromDate:_date]; int year = [components year]; components = [[NSDateComponents alloc] init]; [components setYear:year -1]; [components setMonth:12]; [components setDay:30]; [components setHour:23]; [components setMinute:59]; [components setSecond:59]; NSDate *lastYear1230 = [calendar dateFromComponents:components]; [components release]; components = [calendar components:NSDayCalendarUnit fromDate:lastYear1230 toDate:_date options:0]; int day = [components day]; [calendar release]; return day; } int dayOfYearForDate3(NSDate *_date) { NSTimeZone *gmtTimeZone = [NSTimeZone timeZoneForSecondsFromGMT:0]; NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; [calendar setTimeZone:gmtTimeZone]; NSDateComponents *components = [calendar components:NSYearCalendarUnit fromDate:_date]; int year = [components year]; NSString *dateString = [NSString stringWithFormat:@%d-12-30 23:59:59 -, year - 1]; NSDate *lastYear1230 = [NSDate dateWithString:dateString]; components = [calendar components:NSDayCalendarUnit fromDate:lastYear1230 toDate:_date options:0]; int day = [components day]; [calendar release]; return day; } To decide whether to use dayOfYearForDate2() or dayOfYearForDate3() in my application, I benchmarked all three functions: dayOfYearForDate1(): 8.76544 microseconds dayOfYearForDate2(): 46.9595 microseconds dayOfYearForDate3(): 74.5191 microseconds (The above times include 0.4 microseconds attributable to the testing overhead.) Since Apple's engineers would not throw away a perfectly good object without providing something better, I must be doing things the hard way. What is the easy way? Thanks in advance. ++ Tom Tom Bernard [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: Hex representation of NSString
On Aug 18, 2008, at 07:18 , Robert Černý wrote: Actually,I'm trying to debug some weird problems with clipboard. My problem is that data copied into clipboard from legacy java application doesn't match data pasted into Cocoa application. I've got data with accented characters which gets converted through MacOS Roman encoding even the visual representation in java is correct. If you want to print the string as hexadecimal without any conversions, you can do something like the following (keep in mind this is showing you basically the UCS-2 version of the string): void dumpString(NSString *str) { NSUInteger len = [str length]; unichar *chars = malloc(len * sizeof(unichar)); [str getCharacters:chars]; uint i; printf(NSString at %08p = { , str); for( i = 0; i len; i++ ) { if( i % 7 == 0 i 0 ) printf(\n ); printf(0x%04X , chars[i]); } printf( }\n); free(chars); } smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSCalendarDate to be deprecated
You could do this: int dayOfYearForDate(NSDate *_date) { NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIndentifier:NSGregorianCalendar]]; int day = [calendar ordinalityOfUnit:NSDayCalendarUnit inUnit:NSYearCalendarUnit forDate:_date]; return day; } I've never benchmarked this, but it's certainly a lot less code. Eliza On Aug 18, 2008, at 8:32 AM, Tom Bernard wrote: My application needs to obtain the day of year for a given date. In the past, this was easily done with an NSCalendarDate. // NSCalendarDate faces deprecation int dayOfYearForDate1(NSDate *_date) { NSTimeZone *gmtTimeZone = [NSTimeZone timeZoneForSecondsFromGMT:0]; NSCalendarDate *calendarDate = [_date dateWithCalendarFormat:nil timeZone:gmtTimeZone]; int day = [calendarDate dayOfYear]; return day; } NSCalendarDate faces deprecation: Use of NSCalendarDate strongly discouraged. It is not deprecated yet, however it may be in the next major OS release after Mac OS X v10.5. For calendrical calculations, you should use suitable combinations of NSCalendar, NSDate, and NSDateComponents, as described in Calendars in Dates and Times Programming Topics for Cocoa. The above advice led to two alternate functions: int dayOfYearForDate2(NSDate *_date) { NSTimeZone *gmtTimeZone = [NSTimeZone timeZoneForSecondsFromGMT:0]; NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; [calendar setTimeZone:gmtTimeZone]; NSDateComponents *components = [calendar components:NSYearCalendarUnit fromDate:_date]; int year = [components year]; components = [[NSDateComponents alloc] init]; [components setYear:year -1]; [components setMonth:12]; [components setDay:30]; [components setHour:23]; [components setMinute:59]; [components setSecond:59]; NSDate *lastYear1230 = [calendar dateFromComponents:components]; [components release]; components = [calendar components:NSDayCalendarUnit fromDate:lastYear1230 toDate:_date options:0]; int day = [components day]; [calendar release]; return day; } int dayOfYearForDate3(NSDate *_date) { NSTimeZone *gmtTimeZone = [NSTimeZone timeZoneForSecondsFromGMT:0]; NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; [calendar setTimeZone:gmtTimeZone]; NSDateComponents *components = [calendar components:NSYearCalendarUnit fromDate:_date]; int year = [components year]; NSString *dateString = [NSString stringWithFormat:@%d-12-30 23:59:59 -, year - 1]; NSDate *lastYear1230 = [NSDate dateWithString:dateString]; components = [calendar components:NSDayCalendarUnit fromDate:lastYear1230 toDate:_date options:0]; int day = [components day]; [calendar release]; return day; } To decide whether to use dayOfYearForDate2() or dayOfYearForDate3() in my application, I benchmarked all three functions: dayOfYearForDate1(): 8.76544 microseconds dayOfYearForDate2(): 46.9595 microseconds dayOfYearForDate3(): 74.5191 microseconds (The above times include 0.4 microseconds attributable to the testing overhead.) Since Apple's engineers would not throw away a perfectly good object without providing something better, I must be doing things the hard way. What is the easy way? Thanks in advance. ++ Tom Tom Bernard [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/eliza.block%40nyu.edu This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Hex representation of NSString
On Mon, Aug 18, 2008 at 5:38 AM, Jason Coco [EMAIL PROTECTED] wrote: On Aug 18, 2008, at 07:18 , Robert Černý wrote: Actually,I'm trying to debug some weird problems with clipboard. My problem is that data copied into clipboard from legacy java application doesn't match data pasted into Cocoa application. I've got data with accented characters which gets converted through MacOS Roman encoding even the visual representation in java is correct. If you want to print the string as hexadecimal without any conversions, you can do something like the following (keep in mind this is showing you basically the UCS-2 version of the string): Not UCS-2, UTF-16. (The distinction is important if the string contains any characters outside of the BMP. void dumpString(NSString *str) { NSUInteger len = [str length]; unichar *chars = malloc(len * sizeof(unichar)); [str getCharacters:chars]; uint i; i should be NSUInteger as well. printf(NSString at %08p = { , str); No need to use %08p, just use %p. for( i = 0; i len; i++ ) { if( i % 7 == 0 i 0 ) printf(\n ); printf(0x%04X , chars[i]); } printf( }\n); free(chars); } -- Clark S. Cox III [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: Hex representation of NSString
On Aug 18, 2008, at 10:18 , Clark Cox wrote: On Mon, Aug 18, 2008 at 5:38 AM, Jason Coco [EMAIL PROTECTED] wrote: On Aug 18, 2008, at 07:18 , Robert Černý wrote: Actually,I'm trying to debug some weird problems with clipboard. My problem is that data copied into clipboard from legacy java application doesn't match data pasted into Cocoa application. I've got data with accented characters which gets converted through MacOS Roman encoding even the visual representation in java is correct. If you want to print the string as hexadecimal without any conversions, you can do something like the following (keep in mind this is showing you basically the UCS-2 version of the string): Not UCS-2, UTF-16. (The distinction is important if the string contains any characters outside of the BMP. Yeah, my bad... UTF-16, not UCS-2 void dumpString(NSString *str) { NSUInteger len = [str length]; unichar *chars = malloc(len * sizeof(unichar)); [str getCharacters:chars]; uint i; i should be NSUInteger as well. I don't think that really matters all that much, just a matter of style mostly. I think /should/ is strong. It could be NSUInteger or just int or uint32_t or unsigned int or whatever... it's just a counter for a simple debugging example, right :) printf(NSString at %08p = { , str); No need to use %08p, just use %p. I wanted %08p... it was on purpose. I like my debugging messages to line up properly :) smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Changing NSTextFieldCells' editing appearance?
18 aug 2008 kl. 10.15 skrev Negm-Awad Amin: No, I speak english badly enough to misunderstand this. :-) I'm sorry if I made it sound like a insult - That wasn't my intention. The behaviour of an NSTextField depends on the behaviour of an NSTextFieldCell. Most of the behaviour of an NSTextField is done by an NSTextFieldCell. So it is a little bit strange to ask, whether a cell should behave as its control. Probably you can clearify this: - Do you use an NSTextFieldCell without its NSTextField? - Which specific behaviour the control did fail using the cell? Cheers, Amin I'm using the NSTextFieldCell in a NSTableView. When using a NSTextField without a border and focus ring, the only thing that happens when you start editing the field is that the text is highlighted. When I edit my NSTextFieldCell (Without border and focus ring) in my NSTableView, the background goes black and a white border is shown around it, as the following picture shows: http://img143.imageshack.us/img143/5513/bild2su2.png I hope that clarifies what I'm trying to do. :) Cheers, Tim Andersson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Changing NSTextFieldCells' editing appearance?
Am Mo,18.08.2008 um 17:00 schrieb Tim Andersson: 18 aug 2008 kl. 10.15 skrev Negm-Awad Amin: No, I speak english badly enough to misunderstand this. :-) I'm sorry if I made it sound like a insult - That wasn't my intention. No, my fault. The behaviour of an NSTextField depends on the behaviour of an NSTextFieldCell. Most of the behaviour of an NSTextField is done by an NSTextFieldCell. So it is a little bit strange to ask, whether a cell should behave as its control. Probably you can clearify this: - Do you use an NSTextFieldCell without its NSTextField? - Which specific behaviour the control did fail using the cell? Cheers, Amin I'm using the NSTextFieldCell in a NSTableView. When using a NSTextField without a border and focus ring, the only thing that happens when you start editing the field is that the text is highlighted. When I edit my NSTextFieldCell (Without border and focus ring) in my NSTableView, the background goes black and a white border is shown around it, as the following picture shows: http://img143.imageshack.us/img143/5513/bild2su2.png I hope that clarifies what I'm trying to do. :) Cheers, Tim Andersson Yes, it did. Probably the table view will set some attributes from its own state instead of respecting your cell. For example a table view has a background and the cell has. I never had that problem, but to solve this, you maybe should overwrite -editColumn:row:withEvent:select: (NSTableView) and debug, what is going on. Maybe you can set some attributes before the editing starts. Cheers, Amin Negm-Awad [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: NSCalendarDate to be deprecated
I wish NSCalendarDate could be fixed instead of discarded. I find it a convenient class, and it is heavily used in the standard sync schemas. If it must go, I hope somebody comes up with an open source replacement for it. :) Dave ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Hex representation of NSString
On Mon, Aug 18, 2008 at 7:38 AM, Jason Coco [EMAIL PROTECTED] wrote: On Aug 18, 2008, at 10:18 , Clark Cox wrote: On Mon, Aug 18, 2008 at 5:38 AM, Jason Coco [EMAIL PROTECTED] wrote: On Aug 18, 2008, at 07:18 , Robert Černý wrote: Actually,I'm trying to debug some weird problems with clipboard. My problem is that data copied into clipboard from legacy java application doesn't match data pasted into Cocoa application. I've got data with accented characters which gets converted through MacOS Roman encoding even the visual representation in java is correct. If you want to print the string as hexadecimal without any conversions, you can do something like the following (keep in mind this is showing you basically the UCS-2 version of the string): Not UCS-2, UTF-16. (The distinction is important if the string contains any characters outside of the BMP. Yeah, my bad... UTF-16, not UCS-2 void dumpString(NSString *str) { NSUInteger len = [str length]; unichar *chars = malloc(len * sizeof(unichar)); [str getCharacters:chars]; uint i; i should be NSUInteger as well. I don't think that really matters all that much, just a matter of style mostly. I think /should/ is strong. It could be NSUInteger or just int or uint32_t or unsigned int or whatever... If the length is an NSUInteger, then the counter should be as well. it's just a counter for a simple debugging example, right :) Indeed, but unless there's a good reason, using different types for the index and the limit is not a good idea. printf(NSString at %08p = { , str); No need to use %08p, just use %p. I wanted %08p... it was on purpose. I like my debugging messages to line up properly :) Then what happens when you build 64-bit? :) -- Clark S. Cox III [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: Table column header not highlighted at first
On Aug 16, 2008, at 6:26 AM, Graham Cox wrote: On 16 Aug 2008, at 1:36 am, Graham Cox wrote: I need to figure out why the second table works even though I'm not doing anything special (and none of the autosave stuff you mentioned either). OK, very simple: it was set in the nib. I didn't realise that presetting this in the nib was possible, so I must have set it up that way more or less by accident. OK, my understanding has improved... (Thanks!) Now I have a new problem which is somewhat related (same tables and to do with these sort descriptors). Table has two columns, one of which contains strings, the other, checkboxes. I set up a sort descriptor for the strings column and that works great. Then I came to add a sort descriptor to the checkbox column. This requires a custom compare method so I wrote one, then set that up as the sort descriptor's selector, with 'self' as the keyed property. Something weird happens in IB. As soon as I add this information to the column, my two column headers seem to get locked together - they both turn blue at the same time, and clicking either one inverts both of them together. I can't seem to fix this - even scrapping the table and starting over I end up in the same fix. This is in IB long before my own code gets a shot at it - and when it does it's the same story - the columns lock together. Do you have any console logs? It sounds like an exception is being raised by IB. Other than that, I don't know...I haven't heard of this before. 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 [EMAIL PROTECTED]
Re: Hiding NSTableColumn causes other columns to shrink
On Aug 16, 2008, at 6:59 PM, Markus Spoettl wrote: Hi List, it appears it's time for a stupid question again. I'm experiencing some odd behavior of NSOutlineView (probably NSTableView as well) when hiding and showing table columns dynamically. I have an outline with a number of columns, the first and last column have resize with table turned on, most of the other columns don't. Now, when I change [column isHidden] of any column programmatically, the first and last column shrink to their minimum size (as set in IB). It doesn't matter whether a column gets hidden or shown, the effect is the same for both actions. The shrinking appears to affect the two outermost columns (from left and right edge respectively) that have resize with table set. Does anyone know why? Is there a cure (other than turning off resize with table)? It's trying to take up the size that has been added/removed with the available (resizable) columns. It sounds like bug -- can you please log a bug to bugreporter.apple.com? If you have a test project, that will speed up the process. 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 [EMAIL PROTECTED]
Re: Right place to unobserve notifications in a document
Am Mo,18.08.2008 um 17:37 schrieb Michael Ash: On Mon, Aug 18, 2008 at 5:59 AM, Negm-Awad Amin [EMAIL PROTECTED] wrote: Hi, for some teaching reasons I have a document class, which observes a notification. Of course I have to unobserve this notification, when the document is closed. Doing this in -dealloc is no good design (fuunctional overhead in -dealloc, garbage collection …). There's nothing wrong with doing it in -dealloc, and in fact this is the standard way to do it. Overhead is not a problem. That code has to run *sometime*, and -dealloc is not in anybody's critical path the way -finalize is. Garbage collection is not a problem, because notification observers are held with weak references in a GC Argh, yes, I forgot this. environment, so you don't need to manually unobserve at all. Also note that it's pretty rare and undesirable to write dual-mode code. If you're running under GC, just forget about unobserving. If you're not, then forget about problems with GC. Thanks a lot! With the fact above, -dealloc seems to be a nice place, because it is *not* executed running garbage collection. But anyway I do not think, that doing something else then memory management in -dealloc is good design. Normally I unregister observation in delegate methods like -applicationWillTerminate:. 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/negm-awad%40cocoading.de This email sent to [EMAIL PROTECTED] Amin Negm-Awad [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: Hex representation of NSString
On Aug 18, 2008, at 11:38 , Clark Cox wrote: On Mon, Aug 18, 2008 at 7:38 AM, Jason Coco [EMAIL PROTECTED] wrote: On Aug 18, 2008, at 10:18 , Clark Cox wrote: On Mon, Aug 18, 2008 at 5:38 AM, Jason Coco [EMAIL PROTECTED] wrote: On Aug 18, 2008, at 07:18 , Robert Černý wrote: Actually,I'm trying to debug some weird problems with clipboard. My problem is that data copied into clipboard from legacy java application doesn't match data pasted into Cocoa application. I've got data with accented characters which gets converted through MacOS Roman encoding even the visual representation in java is correct. If you want to print the string as hexadecimal without any conversions, you can do something like the following (keep in mind this is showing you basically the UCS-2 version of the string): Not UCS-2, UTF-16. (The distinction is important if the string contains any characters outside of the BMP. Yeah, my bad... UTF-16, not UCS-2 void dumpString(NSString *str) { NSUInteger len = [str length]; unichar *chars = malloc(len * sizeof(unichar)); [str getCharacters:chars]; uint i; i should be NSUInteger as well. I don't think that really matters all that much, just a matter of style mostly. I think /should/ is strong. It could be NSUInteger or just int or uint32_t or unsigned int or whatever... If the length is an NSUInteger, then the counter should be as well. it's just a counter for a simple debugging example, right :) Indeed, but unless there's a good reason, using different types for the index and the limit is not a good idea. This is true... I guess using good habits are important even when building a quick dirty little debugging example... it really does suck when your debugging code has bugs that make you chase your tail :) printf(NSString at %08p = { , str); No need to use %08p, just use %p. I wanted %08p... it was on purpose. I like my debugging messages to line up properly :) Then what happens when you build 64-bit? :) Cry? :) smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Right place to unobserve notifications in a document
On Aug 18, 2008, at 11:51 AM, Negm-Awad Amin wrote: But anyway I do not think, that doing something else then memory management in -dealloc is good design. Normally I unregister observation in delegate methods like -applicationWillTerminate:. I understand your concern -- you meant functional overhead in the sense of a design taboo, not a performance cost -- but in this case I think -dealloc is not only okay, but sometimes the only correct place to unregister a notification. Suppose an invariant of your design is that an object should receive notifications as long as, and only as long as, the object exists. If you unregister too soon, you may have an alive object that fails to get a notification. If unregister too late, the notification center will send the notification to a dangling pointer and your app will crash. I think it's okay to unregister in -dealloc because conceptually it's related to releasing your ivars. You're explicitly dissolving a relationship between the object being dealloced and some other object -- a relationship you have to manually manage in the absence of garbage collection. --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 [EMAIL PROTECTED]
Re: arch: posix_spawnp: /Developer/Tools/otest: Bad CPU type in executable
Upgrading to Xcode 3.1 solved the problem. On Aug 15, 2008, at 1:01 PM, Nick Pilch wrote: Hi. I'm trying to put the infrastructure into my project for running unit tests and I'm stuck. The tests don't seem to execute. I've set things up as described here for independent tests: http://developer.apple.com/documentation/DeveloperTools/Conceptual/UnitTesting/Articles/CreatingTests.html When trying to build/run this test I get: arch: posix_spawnp: /Developer/Tools/otest: Bad CPU type in executable Here's my test method: - (void) testTest { STAssertEquals(0, 1, @Dude, 0 is not 1, nil); } Any help? 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/npilch%40tacitknowledge.com This email sent to [EMAIL PROTECTED] Nick Pilch / Tacit Knowledge, LLC [EMAIL PROTECTED] Cell: 510-381-6777 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Changing NSTextFieldCells' editing appearance?
The black color you're seeing when editing is the -backgroundColor of the table view. Just override that method and return a more appropriate color. On 18-Aug-08, at 11:00 AM, Tim Andersson wrote: I'm using the NSTextFieldCell in a NSTableView. When using a NSTextField without a border and focus ring, the only thing that happens when you start editing the field is that the text is highlighted. When I edit my NSTextFieldCell (Without border and focus ring) in my NSTableView, the background goes black and a white border is shown around it, as the following picture shows: http://img143.imageshack.us/img143/5513/bild2su2.png I hope that clarifies what I'm trying to do. :) Cheers, Tim Andersson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Changing NSTextFieldCells' editing appearance?
18 aug 2008 kl. 18.30 skrev Brandon Walkin: The black color you're seeing when editing is the -backgroundColor of the table view. Just override that method and return a more appropriate color. Oh, I see. Now all I have to do is get rid of the white border that appears around the cell.. Thanks for your help, Tim Andersson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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]
ScriptingBrige InDesign
Hi, I try to use the scriptingBridge feature with InDesign CS3. My guiding line is the ReadMe.txt file in the SBSendEmail project example. The Adobe InDesign CS3.h file will be generated, but when I import this file I get about 800 errors like: error: duplicate declaration of method '- checkInVersionComments:forceSave:' When I add iCal in the same way to the project everything works as it should. I also searched the InDesign scripting list without success . Any hint is welcome. Götz ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Hex representation of NSString
Hi there! Just subscribed to this list. @Robert: Do you mean by hex representation this: hello - 0x68 0x61 0x6C 0x6C 0x6F ? Then i suggest you use the C language to do it, just convert a string to an array of characters by [yourstring UTF8String] And loop through the result and printf it. Am 18.08.2008 um 12:45 schrieb Negm-Awad Amin: Am Mo,18.08.2008 um 12:40 schrieb Robert Černý: I don't like it because the string will be converted. I'm interested in exact values Oh, may I ask why? The string class encapsulates its representation. Anyway, if you want to look inside the instance, you probably have to subclass it or doing some undocumentated stuff. Cheers, Amin and even allowLossyConversion:NO doesn't guarantee it. Or am I wrong? Robert 2008/8/18 Negm-Awad Amin [EMAIL PROTECTED] Am Mo,18.08.2008 um 12:21 schrieb Robert Černý: Hi,I'm trying to find a way how to get hex representation of NSString. I know I can convert NSString to NSData but I would like to rather not to do it. Or am I missing anything obvious? Maybe: Do it this way. Why don't you like it? Cheers, Amin BTW: This isn't the hex representation, but the binary, serialized representation. Hex, octal and so on are terms used in relation to display something. Thanks Robert ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de This email sent to [EMAIL PROTECTED] Amin Negm-Awad [EMAIL PROTECTED] Amin Negm-Awad [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/uni%40blaettermann-software.de This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Hex representation of NSString
Hi there! Just subscribed to this list. @Robert: Do you mean by hex representation this: hello - 0x68 0x61 0x6C 0x6C 0x6F ? Then I suggest you use the C language to do it, just convert a string to an array of characters by [yourstring UTF8String] And loop through the result and printf it. Kind regards, Chris Am 18.08.2008 um 12:45 schrieb Negm-Awad Amin: Am Mo,18.08.2008 um 12:40 schrieb Robert Černý: I don't like it because the string will be converted. I'm interested in exact values Oh, may I ask why? The string class encapsulates its representation. Anyway, if you want to look inside the instance, you probably have to subclass it or doing some undocumentated stuff. Cheers, Amin and even allowLossyConversion:NO doesn't guarantee it. Or am I wrong? Robert 2008/8/18 Negm-Awad Amin [EMAIL PROTECTED] Am Mo,18.08.2008 um 12:21 schrieb Robert Černý: Hi,I'm trying to find a way how to get hex representation of NSString. I know I can convert NSString to NSData but I would like to rather not to do it. Or am I missing anything obvious? Maybe: Do it this way. Why don't you like it? Cheers, Amin BTW: This isn't the hex representation, but the binary, serialized representation. Hex, octal and so on are terms used in relation to display something. Thanks Robert ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de This email sent to [EMAIL PROTECTED] Amin Negm-Awad [EMAIL PROTECTED] Amin Negm-Awad [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/uni%40blaettermann-software.de This email sent to [EMAIL PROTECTED] Am 18.08.2008 um 13:18 schrieb Robert Černý: Actually,I'm trying to debug some weird problems with clipboard. My problem is that data copied into clipboard from legacy java application doesn't match data pasted into Cocoa application. I've got data with accented characters which gets converted through MacOS Roman encoding even the visual representation in java is correct. Robert 2008/8/18 Negm-Awad Amin [EMAIL PROTECTED] Am Mo,18.08.2008 um 12:40 schrieb Robert Černý: I don't like it because the string will be converted. I'm interested in exact values Oh, may I ask why? The string class encapsulates its representation. Anyway, if you want to look inside the instance, you probably have to subclass it or doing some undocumentated stuff. Cheers, Amin and even allowLossyConversion:NO doesn't guarantee it. Or am I wrong? Robert 2008/8/18 Negm-Awad Amin [EMAIL PROTECTED] Am Mo,18.08.2008 um 12:21 schrieb Robert Černý: Hi,I'm trying to find a way how to get hex representation of NSString. I know I can convert NSString to NSData but I would like to rather not to do it. Or am I missing anything obvious? Maybe: Do it this way. Why don't you like it? Cheers, Amin BTW: This isn't the hex representation, but the binary, serialized representation. Hex, octal and so on are terms used in relation to display something. Thanks Robert ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/negm-awad%40cocoading.de This email sent to [EMAIL PROTECTED] Amin Negm-Awad [EMAIL PROTECTED] Amin Negm-Awad [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/uni%40blaettermann-software.de This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Clearing a Memory Buffer?
Hi All, I'm fairly new to Cocoa and was wondering if there are OS functions to Copy and Clear/Fill Memory available? I've tried searching for obvious names like MemoryZero, ZeroMemory, CopyMemory etc. but can't seem to find anything. Thanks a lot All the Best Dave ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
document based app, custom ibaction
Hi, I'm quite new to cocoa developing, but things start to work out finally. At the moment I'm working at a document based app (first time). It is based on an arraycontroller in combination with a tableview I am able to use buttons to add and delete entries. However I would like to add a button in my document which is connected to some code, to process the data in the array (etc count up data in columns). I was trying to do this by adding an IBAction function to the MyDocument.h en MyDocument.m files. The problem is that I do not know how to connect the button from my GUI to this action (normally I can ctrl-drag from the button to the object, but I guess this works different for document based apps? Some help would be appreciated. Bart ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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]
NSString Question
Hi, I'm tring to create an NSString object from data contained within a file. The following code attempts to do this. The data is read from the file OK and all the size information etc. is OK. Here is a code snippet: myOSStatus = [self ReadUInt32LEFromPosition: myCurrentFilePosition + 28 IntPtr:myBufferSize]; myStringSize = (myBufferSize / 2) + 1; myStringBufferPtr = malloc(myBufferSize + 2); bzero(myStringBufferPtr,myBufferSize + 2); myOSStatus = [self ReadFromPosition: myCurrentFilePosition + 40 ForSize: myBufferSize BufferPtr:myStringBufferPtr]; [thePropertiesInfoPtr-mNameString initWithCharacters: myStringBufferPtr length:myStringSize]; - thePropertiesInfoPtr pointer to a C Structure that contains the following member: NSString* mNameString; When the initWithCharacters method is called, the variables are setup as follows: myBufferSize = 54 myStringSize = 28 myStringBufferPtr is a pointer the following: 41 00 42 00 43 00 44 00 45 00 46 00 47 00 48 00 49 00 4A 00 4B 00 4C 00 4D 00 4D 00 4E 00 4F 00 50 00 51 00 52 00 53 00 54 00 55 00 56 00 57 00 58 00 59 00 5A 00 00 00 But I get an Access Error when I run it. Could someone tell me what I am doing wrong and how I can correct it? Thanks a lot All the Best Dave ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Address Book: updating a person's phone number info...
Environment: Xcode 3.1 OS: Leopard (10.5.4+) Generic Environment: MacBook Pro NDA devices Greetings: I'm partially clear about access/updating the Address Book using the C interfaces. However, I'm slamming into the wall with confusion on updating a multi-value item like a phone number. Overview: 1) check if person has a particular phone label (e.g., 'mobile'); 2) if so, modify it or create it. This is what I essentially know: 1) Create a local copy of Address Book, with its members already there: ABAddressBookRef addressBook = ABAddressBookCreate(); 2) Get the target person's record (I've stored the person's Unique ID): ABRecordRef thePerson = ABAddressBookGetPersonWithRecordID (addressBook, (NSInteger)[gSelectedMemberDict objectForKey:@uniqueID]); 3) Extract the person's multi-value property (which are not mutable, need a copy): a) Copy the value of the particular property (in this case, multi-string property?): ABRecRef abRecRef = get the Record Reference via its unique id ABMutableMultiValueRef phoneNumberMultiValue = ABRecordCopyValue( abRecordRef, kABPersonPhoneProperty); --- if found, use it phoneNumberMultValue for loop { --- don't know count syntax here --- } --- if not found, create it ABMutableMultiValueRef phoneNumberMultiValue = ABMultiValueCreateMutable(kABPersonPhoneProperty); ABMultiValueAddValueAndLabel(phoneNumberMultiValue, @(555) 123-4567, kABPersonPhoneMobileLabel, NULL); 4) Now I need to attach this property to the person Record (I'm lost here): bool ABRecordSetValue (thePerson, phoneNumberMultiValue ABRecordRef record, ABPropertyID property, -- how do I get this? CFTypeRef value, CFErrorRef *error ); 5) Once I got the person record updated, insert it back into address Book... I don't see an API that actually INSERTS a person's record into the address book So do I just do an AddressBook Save? ABAddressBookSave(addressBook, error); I've slammed into the wall here, confused. Much obliged to help... Ric. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Right place to unobserve notifications in a document
Am Mo,18.08.2008 um 18:18 schrieb Andy Lee: On Aug 18, 2008, at 11:51 AM, Negm-Awad Amin wrote: But anyway I do not think, that doing something else then memory management in -dealloc is good design. Normally I unregister observation in delegate methods like -applicationWillTerminate:. I understand your concern -- you meant functional overhead in the sense of a design taboo, not a performance cost Oh, yes, sorry for the ambigious statement. I'm a fan of Knuths phrase, so I talk about performance very rarely. -- but in this case I think -dealloc is not only okay, but sometimes the only correct place to unregister a notification. Suppose an invariant of your design is that an object should receive notifications as long as, and only as long as, the object exists. If you unregister too soon, you may have an alive object that fails to get a notification. This is little bit a circular argumentation: I need it the whole lifetime, so i manage it the whole lifetime. Why do you need it until the instance becomes deconstructed? I think this is the right pattern: 1. Construct and init the object 2. Let them work (register observations, handling threads, $whatever … ) 3. Stop them 4. Deconstruct them So there are 4 steps, not 2. In former times I often finished functional work in -dealloc. This ofen works, no problem. But it is a poor design. Sure, you shouldn't develop for garbage collection and reference counting in the same code. But thinking about this can sometimes focus a problem with design. No design should depend on the memory management model accept of the memory managing itself, should it? If unregister too late, the notification center will send the notification to a dangling pointer and your app will crash. Of course you have to stop functional work before decnstrcuting the instance. I think it's okay to unregister in -dealloc because conceptually it's related to releasing your ivars. You're explicitly dissolving a relationship between the object being dealloced and some other object -- a relationship you have to manually manage in the absence of garbage collection. In this case it seems to be ok. Maybe this is the reason for the weak reference. Thanks for your thoughts. Cheers, Amin --Andy Amin Negm-Awad [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: Right place to unobserve notifications in a document
On Mon, Aug 18, 2008 at 11:51 AM, Negm-Awad Amin [EMAIL PROTECTED] wrote: But anyway I do not think, that doing something else then memory management in -dealloc is good design. Normally I unregister observation in delegate methods like -applicationWillTerminate:. I think you may be a little too strict about this. First, this really is memory management, it's just not so obvious. You're removing another object's weak reference to your own object. The logical place to do this is right before your own object is deallocated. Second, it's fine, even good, to clean up arbitrary resources in -dealloc. There are two things to watch out for, though: 1) You shouldn't clean up *scarce* resources *only* in dealloc. For example, file descriptors. It's fine to close fds in dealloc. In fact, you really should do this. But you should *also* provide an explicit close method and use it. The close in dealloc will just function as a failsafe. This is because your object's lifetime may be much longer than you want it to be due to things like autorelease pools, so you want scarce resources to be under explicit control. This is much more important in a GC environment than in the manual environment, however. 2) You shouldn't clean up *external* resources *only* in dealloc. For example, if you have an object that keeps a temporary file around, then only deleting it in dealloc is a bad idea. This is because, as you're probably aware, there's no guarantee that your objects get deallocated before your application terminates. But again, it's fine to do this kind of cleanup in dealloc as a failsafe, just don't have it be the *only* place it happens. What you don't want to do is make dealloc part of an RAII (Resources Acquisition is Initialization) pattern, or do long running computations there, or things like that. But cleaning up external references to your object before you disappear is a good thing to do there. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Clearing a Memory Buffer?
Le 18 août 08 à 15:19, Dave a écrit : Hi All, I'm fairly new to Cocoa and was wondering if there are OS functions to Copy and Clear/Fill Memory available? I've tried searching for obvious names like MemoryZero, ZeroMemory, CopyMemory etc. but can't seem to find anything. Thanks a lot All the Best Dave Just use the libc functions: memset, bzero, memcpy, and more. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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]
Audio Queue Services example?
Hello, all ... I need to play an MP3 stream from a server in ObjC, so i'm looking at the Audio Queue services API. I see examples of streaming from a file, but I don't know how to feed the queue when i'm streaming from a TCP port. Can someone point me to an example / tell me what API to call to feed the queue my MP3 data? Regards, John Falling You - exploring the beauty of voice and sound http://www.fallingyou.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Clearing a Memory Buffer?
On Mon, Aug 18, 2008 at 9:19 AM, Dave [EMAIL PROTECTED] wrote: Hi All, I'm fairly new to Cocoa and was wondering if there are OS functions to Copy and Clear/Fill Memory available? I've tried searching for obvious names like MemoryZero, ZeroMemory, CopyMemory etc. but can't seem to find anything. Remember, Objective-C is also C. :-) Try memset(). sherm-- -- Cocoa programming in Perl: http://camelbones.sourceforge.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Clearing a Memory Buffer?
Since Objective-C is a superset of C, you can use standard C libraries. My knowledge of those libraries is weak, but apropos zero memory in the Terminal turned up a bunch of stuff including bzero, memset, and calloc. I see in Foundation there is an NSZoneCalloc() function and a bunch of related functions. --Andy On Aug 18, 2008, at 9:19 AM, Dave wrote: Hi All, I'm fairly new to Cocoa and was wondering if there are OS functions to Copy and Clear/Fill Memory available? I've tried searching for obvious names like MemoryZero, ZeroMemory, CopyMemory etc. but can't seem to find anything. Thanks a lot All the Best Dave ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/aglee%40mac.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Clearing a Memory Buffer?
On Aug 18, 2008, at 09:19 , Dave wrote: Hi All, I'm fairly new to Cocoa and was wondering if there are OS functions to Copy and Clear/Fill Memory available? I've tried searching for obvious names like MemoryZero, ZeroMemory, CopyMemory etc. but can't seem to find anything. bzero(3), bcopy(3) memset(3), memcpy(3), memmove(3) strlcmp(3), strlcat(3) smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: document based app, custom ibaction
On Mon, Aug 18, 2008 at 9:52 AM, Bart Beulen [EMAIL PROTECTED] wrote: However I would like to add a button in my document which is connected to some code, to process the data in the array (etc count up data in columns). I was trying to do this by adding an IBAction function to the MyDocument.h en MyDocument.m files. The problem is that I do not know how to connect the button from my GUI to this action (normally I can ctrl-drag from the button to the object, but I guess this works different for document based apps? Connect it to the First Responder icon in IB. That will route the action message through the responder chain, one element of which is the currently-active document. Details: http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/chapter_2_section_6.html sherm-- -- Cocoa programming in Perl: http://camelbones.sourceforge.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Hex representation of NSString
On Aug 18, 2008, at 6:18 AM, Robert Černý wrote: Actually,I'm trying to debug some weird problems with clipboard. My problem is that data copied into clipboard from legacy java application doesn't match data pasted into Cocoa application. I've got data with accented characters which gets converted through MacOS Roman encoding even the visual representation in java is correct. It sounds like you don't really want to use NSString at all. Have you tried just using -[NSPasteboard dataForType:] instead of - [NSPasteboard stringForType:] to get the raw pasteboard data as it's coming from the Java application? Charles___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: CATiledLayer documentation
Hi, I have an example on my blog of using the CATiledLayer with a big pdf file and the CA book (I am the author) has an example of using image tiles. http://www.pragprog.com/titles/bdcora http://bill.dudney.net/roller/objc Good luck, -bd- On Aug 18, 2008, at 10:37 AM, Houdah - ML Pierre Bernard wrote: Hi! I would like to create a map view using several tile images: the map is made of tiles; tiles are available for various zoom levels. Seems like CATiledLayer seems the right thing to use. Problem is that I can't seem to find any documentation beyond a rehash of the header file. Is there any documentation? Is there sample code? Pierre ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/bdudney%40mac.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Right place to unobserve notifications in a document
Am Mo,18.08.2008 um 18:57 schrieb Michael Ash: On Mon, Aug 18, 2008 at 11:51 AM, Negm-Awad Amin [EMAIL PROTECTED] wrote: But anyway I do not think, that doing something else then memory management in -dealloc is good design. Normally I unregister observation in delegate methods like -applicationWillTerminate:. I think you may be a little too strict about this. As I said, it is for teching. So Strictness (correct noun?) is a good approach. First, this really is memory management, it's just not so obvious. You're removing another object's weak reference to your own object. The logical place to do this is right before your own object is deallocated. Second, it's fine, even good, to clean up arbitrary resources in -dealloc. There are two things to watch out for, though: 1) You shouldn't clean up *scarce* resources *only* in dealloc. For example, file descriptors. It's fine to close fds in dealloc. In fact, you really should do this. But you should *also* provide an explicit close method and use it. The close in dealloc will just function as a failsafe. This is because your object's lifetime may be much longer than you want it to be due to things like autorelease pools, so you want scarce resources to be under explicit control. This is much more important in a GC environment than in the manual environment, however. Yes, I saw, that observations of notifications can be understood as a kind of memory management. But you can generalize this argumentation – and then it becomes definetly wrong. In this sense KVO is a kind of memory management, too. Today I would never deregister a KVO-observer in -dealloc as I did it some years ago. 2) You shouldn't clean up *external* resources *only* in dealloc. For example, if you have an object that keeps a temporary file around, then only deleting it in dealloc is a bad idea. This is because, as you're probably aware, there's no guarantee that your objects get deallocated before your application terminates. But again, it's fine to do this kind of cleanup in dealloc as a failsafe, just don't have it be the *only* place it happens. What you don't want to do is make dealloc part of an RAII (Resources Acquisition is Initialization) pattern, Yes, that's it. In the past I handled – internal! – ressources very often this way. I stopped doing so. GC was just the initial thinking: Hey, you are doing something in a method for memory managemt, which has no relation to memory management. As I said, I never have had problems with this approach in woking code. But I do not like it anymore for design reasons. or do long running computations there, No, there is no performance issue in my mind. It's simply design. or things like that. But cleaning up external references to your object before you disappear is a good thing to do there. I'll continue thinking about this … Cheers, Amin 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/negm-awad%40cocoading.de This email sent to [EMAIL PROTECTED] Amin Negm-Awad [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: NSString Question
You haven't mentioned whether you're deliberately avoiding NSFileHandle for some reason. Are you aware of it? It has methods to seek and read. You can get the bytes from the resulting NSData object. On Aug 18, 2008, at 10:54 AM, Dave wrote: [thePropertiesInfoPtr-mNameString initWithCharacters: myStringBufferPtr length:myStringSize]; It is best practice to do alloc and init at the same time, instead of doing init separately as you're doing here. Init methods may return a different object than you started with, especially if you instantiate what's called a class cluster, which NSString is. If you split the alloc and init, you can fall into this trap: NSString *s = [NSString alloc]; // returns an object [s initWithBlahBlahBlah...]; // returns a *different* object, // and s is actually invalid You should do NSString *s = [[NSString alloc] initWithBlahBlahBlah...]; --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 [EMAIL PROTECTED]
Re: NSString Question
On Aug 18, 2008, at 10:54 AM, Dave wrote: thePropertiesInfoPtr pointer to a C Structure that contains the following member: NSString* mNameString; As a general note, by mixing structs and objects you're opening the door to nasty memory management bugs. I'd recommend going with objects for everything -- create a class instead of using the struct, learn how to apply the standard Cocoa memory management techniques, and use existing classes like NSFileHandle and NSData. Here's the Bible on memory management: http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Tasks/MemoryManagementRules.html --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 [EMAIL PROTECTED]
Re: NSString Question
On Aug 18, 2008, at 10:54 , Dave wrote: Hi, I'm tring to create an NSString object from data contained within a file. The following code attempts to do this. The data is read from the file OK and all the size information etc. is OK. Here is a code snippet: myOSStatus = [self ReadUInt32LEFromPosition: myCurrentFilePosition + 28 IntPtr:myBufferSize]; myStringSize = (myBufferSize / 2) + 1; myStringBufferPtr = malloc(myBufferSize + 2); bzero(myStringBufferPtr,myBufferSize + 2); myOSStatus = [self ReadFromPosition: myCurrentFilePosition + 40 ForSize: myBufferSize BufferPtr:myStringBufferPtr]; [thePropertiesInfoPtr-mNameString initWithCharacters: myStringBufferPtr length:myStringSize]; - thePropertiesInfoPtr pointer to a C Structure that contains the following member: NSString* mNameString; When the initWithCharacters method is called, the variables are setup as follows: myBufferSize = 54 myStringSize = 28 myStringBufferPtr is a pointer the following: 41 00 42 00 43 00 44 00 45 00 46 00 47 00 48 00 49 00 4A 00 4B 00 4C 00 4D 00 4D 00 4E 00 4F 00 50 00 51 00 52 00 53 00 54 00 55 00 56 00 57 00 58 00 59 00 5A 00 00 00 But I get an Access Error when I run it. Could someone tell me what I am doing wrong and how I can correct it? Did you allocate your string first? [[thePropertiesInfoPtr-mNameString alloc] initWithCharacters:myStringBufferPtr length:myStringSize]; If you haven't allocated your mNameString variable, chance are it points to 0x00 and that is why you are getting an access violation... smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: document based app, custom ibaction
I've connected a simple button to the First Responder. I was able to select the action that I've created in my MyDocument class. When I run the program and press the button nothing happens. The function was only containing an NSLog statement to check if it worked. Am I missing anything? Op 18 aug 2008, om 19:12 heeft Sherm Pendley het volgende geschreven: On Mon, Aug 18, 2008 at 9:52 AM, Bart Beulen [EMAIL PROTECTED] wrote: However I would like to add a button in my document which is connected to some code, to process the data in the array (etc count up data in columns). I was trying to do this by adding an IBAction function to the MyDocument.h en MyDocument.m files. The problem is that I do not know how to connect the button from my GUI to this action (normally I can ctrl-drag from the button to the object, but I guess this works different for document based apps? Connect it to the First Responder icon in IB. That will route the action message through the responder chain, one element of which is the currently-active document. Details: http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/chapter_2_section_6.html sherm-- -- Cocoa programming in Perl: http://camelbones.sourceforge.net ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Clearing a Memory Buffer?
Dave wrote: I'm fairly new to Cocoa and was wondering if there are OS functions to Copy and Clear/Fill Memory available? I've tried searching for obvious names like MemoryZero, ZeroMemory, CopyMemory etc. but can't seem to find anything. If you want to fill an existing buffer with a specific byte value, memset() is your friend. If you want to allocate a new buffer cleared to 00, calloc(). ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Right place to unobserve notifications in a document
On Aug 18, 2008, at 12:49 PM, Negm-Awad Amin wrote: Am Mo,18.08.2008 um 18:18 schrieb Andy Lee: -- but in this case I think -dealloc is not only okay, but sometimes the only correct place to unregister a notification. Suppose an invariant of your design is that an object should receive notifications as long as, and only as long as, the object exists. If you unregister too soon, you may have an alive object that fails to get a notification. This is little bit a circular argumentation: I need it the whole lifetime, so i manage it the whole lifetime. Why do you need it until the instance becomes deconstructed? It's only circular in that I specifically selected a class of situations where it makes the most sense. :) I think this is the right pattern: 1. Construct and init the object 2. Let them work (register observations, handling threads, $whatever … ) 3. Stop them 4. Deconstruct them So there are 4 steps, not 2. This pattern is fine and necessary in many cases, but there are also plenty of cases where it is not viable. For example, it may not be clear when the object can stop listening for notifications. It may literally be when all other objects are done with it, i.e., when its retain count goes to zero, and in a dynamic system you may have no way of knowing which will be the last object to release your object. IMO imposing a start-stop paradigm on every class that wants to register interest in notifications -- and engineering every class so that your object can't possibly be released until it is stopped -- is just as much a design error as putting functional work in - dealloc. I would encourage you to reconsider. In the cases where you do have a start-stop paradigm, you should put a stop in -dealloc anyway, as Michael argued. I think it's okay to unregister in -dealloc because conceptually it's related to releasing your ivars. You're explicitly dissolving a relationship between the object being dealloced and some other object -- a relationship you have to manually manage in the absence of garbage collection. In this case it seems to be ok. Maybe this is the reason for the weak reference. The weak reference is to avoid retain cycles (the same reason why delegates are not retained). With GC turned on, retain cycles are not a problem so you don't have to worry about weak references to self, just as you don't have to bother releasing strong references to ivars. In the absence of GC, you have to break connections manually, and that's all this is. In fact, you should also break delegate connections to self in the same place, for the same reason. (Hm, I'm not sure whether I'm doing this in my own code -- I'd better check.) You mentioned KVO in another reply. I haven't used KVO, so I'd be interested if anyone has a response to your counterexample. --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 [EMAIL PROTECTED]
Re: NSString Question
On Mon, Aug 18, 2008 at 7:54 AM, Dave [EMAIL PROTECTED] wrote: myOSStatus = [self ReadUInt32LEFromPosition: myCurrentFilePosition + 28 IntPtr:myBufferSize]; myOSStatus = [self ReadFromPosition: myCurrentFilePosition + 40 ForSize: myBufferSize BufferPtr:myStringBufferPtr]; Best to avoid using capital letters for the start of methods and parameter names (hard to read otherwise especially when mixed with Cocoa API). Review... http://developer.apple.com/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingMethods.html -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 [EMAIL PROTECTED]
Re: CATiledLayer documentation
On Aug 18, 2008, at 10:54 AM, Houdah - ML Pierre Bernard wrote: Unfortunately, the sample code left me confused. Seems to me that your drawing method always does the same thing. I find no notion of tiling. Obviously there is: when I set a breakpoint on the drawing method I can clearly see the view being drawn bit by bit. I just don't understand how it works. Actually, thats the intended model. When a tiled layer calls on its delegate's -drawLayer:inContext: (or its own -drawInContext:) method, the context has already been transformed and clipped to capture what is necessary for the tile that its drawing. This allows for a model where you don't have to be concerned with the tiling if you don't want to be. If you do want to be concerned with the tiles, then you can use CGContextGetClipBoundingBox() to determine the tile that you are being asked to draw. If your using the level of detail as well, you can either use that same clip box (carefully) to deduce the scale, or use CGContextGetCTM() to get the current transform matrix and use that to deduce the scale (although this relies on certain assumptions about the CTM that will be applied). Of course, I would have hoped for an example with multiple image source containing tiles. Noted. :). -- David Duncan Apple DTS Animation and Printing ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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]
Problem with fileAttributesAtPath
Hi guys, I am trying to get fileAttributesAtPath using this code: (files contains the path to the directory that was enumerated ) while(object = [dirEnumerator nextObject]) { //First We craft the whole path for a single object NSString *fullPath = [files stringByAppendingString:object]; NSLog(@%@,fullPath); //Log the full path just to be sure it's correct if(!fullPath) { NSLog(@Error when appending strings); } //Try to obtain fileAttributes NSDictionary *fileAttributes = [manager fileAttributesAtPath:fullPath traverseLink:NO]; if( fileAttributes != nil) { NSString *filetype = [fileAttributes objectForKey:NSFileType]; NSLog(@%@,filetype); } if(!fileAttributes) { NSLog(@it's nill); } } The thing is that my fileAttributes it's always = nil so I always get it's nill on the console. Could anyone point me at what I'm doing wrong ??? Thanks!! :) -- -Nicolas Goles ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Problem with fileAttributesAtPath
If you're using 10.5 you can try the method: -(NSDictionary *)attributesOfItemAtPath:(NSString *)path error: (NSError **)error This way you will get a description of what is failing from the NSError object. You can use it like this: NSError *theError; NSDictionary *fileAttributes = [manager attributesOfItemAtPath:fullPath error:theError]; if( fileAttributes != nil ) { // do your things } else { NSLog(@Error retrieving file attributes for %@: %@, fullPath, [theError localizedDescription]); } That should help you track down what might be going wrong at least On Aug 18, 2008, at 15:24 , Nicolas Goles wrote: Hi guys, I am trying to get fileAttributesAtPath using this code: (files contains the path to the directory that was enumerated ) while(object = [dirEnumerator nextObject]) { //First We craft the whole path for a single object NSString *fullPath = [files stringByAppendingString:object]; NSLog(@%@,fullPath); //Log the full path just to be sure it's correct if(!fullPath) { NSLog(@Error when appending strings); } //Try to obtain fileAttributes NSDictionary *fileAttributes = [manager fileAttributesAtPath:fullPath traverseLink:NO]; if( fileAttributes != nil) { NSString *filetype = [fileAttributes objectForKey:NSFileType]; NSLog(@%@,filetype); } if(!fileAttributes) { NSLog(@it's nill); } } The thing is that my fileAttributes it's always = nil so I always get it's nill on the console. Could anyone point me at what I'm doing wrong ??? Thanks!! :) -- -Nicolas Goles ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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.coco %40gmail.com This email sent to [EMAIL PROTECTED] smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Problem with fileAttributesAtPath
--- On Mon, 8/18/08, Nicolas Goles [EMAIL PROTECTED] wrote: NSDictionary *fileAttributes = [manager fileAttributesAtPath:fullPath traverseLink:NO]; if( fileAttributes != nil) { NSString *filetype = [fileAttributes objectForKey:NSFileType]; NSLog(@%@,filetype); } if(!fileAttributes) { NSLog(@it's nill); } } The thing is that my fileAttributes it's always = nil so I always get it's nill on the console. 1. Are you sure that manager == [NSFileManager defaultManager]? I would just write the call to NSFileManager explicitly. 2. Are you sure that [[NSFileManager defaultManager] fileExistsAtPath:fullPath] == YES? Like perhaps there's somehow a shell expansion character like a tilde sneaking in there that NSFileManager doesn't deal with? Cheers, Chuck ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSString Question
On Aug 18, 2008, at 12:28 PM, Jason Coco wrote: [[thePropertiesInfoPtr-mNameString alloc] initWithCharacters:myStringBufferPtr length:myStringSize]; Um, that's nonsensical. I think you meant: thePropertiesInfoPtr-mNameString = [[NSString alloc] initWithCharacters:myStringBufferPtr length:myStringSize]; 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 [EMAIL PROTECTED]
Re: Problem with fileAttributesAtPath
On Aug 18, 2008, at 2:24 PM, Nicolas Goles wrote: //Try to obtain fileAttributes NSDictionary *fileAttributes = [manager fileAttributesAtPath:fullPath traverseLink:NO]; The thing is that my fileAttributes it's always = nil so I always get it's nill on the console. Could anyone point me at what I'm doing wrong ??? Is manager nil? -Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSString Question
On Aug 18, 2008, at 15:49 , Ken Thomases wrote: On Aug 18, 2008, at 12:28 PM, Jason Coco wrote: [[thePropertiesInfoPtr-mNameString alloc] initWithCharacters:myStringBufferPtr length:myStringSize]; Um, that's nonsensical. I think you meant: thePropertiesInfoPtr-mNameString = [[NSString alloc] initWithCharacters:myStringBufferPtr length:myStringSize]; Oh yes, yes I did... sorry about that, Dave! Not enough sleep last night, not enough caffeine this morning :) Jason smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: CATiledLayer documentation
Hi Pierre, The sample code from the book is concerned with the bounding box and the zoom level. As David discussed in his response (he was instrumental in me getting my head wrapped around the tiled layer, thx David!). You can get the code even if you don't have the book (just go to the book's site and click on code). Good luck! -bd- On Aug 18, 2008, at 11:54 AM, Houdah - ML Pierre Bernard wrote: Hi Bill! I had indeed found your sample code. Which actually happens to be the only sample code I could find. Unfortunately, the sample code left me confused. Seems to me that your drawing method always does the same thing. I find no notion of tiling. Obviously there is: when I set a breakpoint on the drawing method I can clearly see the view being drawn bit by bit. I just don't understand how it works. Of course, I would have hoped for an example with multiple image source containing tiles. I wanted to access the web site of your book. I was hoping for an eBook to purchase. The server however hasn't been responding all day. Best, Pierre Bernard Houdah Software s.à r.l. On 18 Aug 2008, at 19:16, Bill Dudney wrote: Hi, I have an example on my blog of using the CATiledLayer with a big pdf file and the CA book (I am the author) has an example of using image tiles. http://www.pragprog.com/titles/bdcora http://bill.dudney.net/roller/objc Good luck, -bd- On Aug 18, 2008, at 10:37 AM, Houdah - ML Pierre Bernard wrote: Hi! I would like to create a map view using several tile images: the map is made of tiles; tiles are available for various zoom levels. Seems like CATiledLayer seems the right thing to use. Problem is that I can't seem to find any documentation beyond a rehash of the header file. Is there any documentation? Is there sample code? Pierre ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/bdudney%40mac.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Audio Queue Services example?
You may get better responses from the coreaudio-api list On Aug 18, 2008, at 1:06 PM, John Zorko wrote: I need to play an MP3 stream from a server in ObjC, so i'm looking at the Audio Queue services API. I see examples of streaming from a file, but I don't know how to feed the queue when i'm streaming from a TCP port. Can someone point me to an example / tell me what API to call to feed the queue my MP3 data? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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]
Question about respondsToSelector
Does the id type have enough information for the respondsToSelector method to work. I have a class with an ivar of type id, and when I invoke the respondsToSelector method it fails when it should succeed. I am assuming it should work fine, because if I skip checking with the respondsToSelector method and just make the call, it executes the method. Can someone please tell me what I am doing wrong? Thanks, Carmen ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Question about respondsToSelector
On Aug 18, 2008, at 1:17 PM, Carmen Cerino Jr. wrote: Does the id type have enough information for the respondsToSelector method to work. I have a class with an ivar of type id, and when I invoke the respondsToSelector method it fails when it should succeed. I am assuming it should work fine, because if I skip checking with the respondsToSelector method and just make the call, it executes the method. Can someone please tell me what I am doing wrong? It should work just fine. This example... NSArray* theArray = [NSArray array]; id theId = theArray; idNSCopying* theCopyingId = (idNSCopying*) theArray; if ([theArray respondsToSelector:@selector(isEqualToArray:)]) { NSLog(@theArray responds to isEqualToArray:); } else { NSLog(@theArray DOES NOT respond to isEqualToArray:); } if ([theId respondsToSelector:@selector(isEqualToArray:)]) { NSLog(@theId responds to isEqualToArray:); } else { NSLog(@theId DOES NOT respond to isEqualToArray:); } if ([(id) theCopyingId respondsToSelector:@selector(isEqualToArray:)]) { NSLog(@theCopyingId responds to isEqualToArray:); } else { NSLog(@theCopyingId DOES NOT respond to isEqualToArray:); } ...displays this output: theArray responds to isEqualToArray: theId responds to isEqualToArray: theCopyingId responds to isEqualToArray: Note that special casting done to remove warnings. However, without the casting, output was the same. ___ Ricky A. Sharp mailto:[EMAIL PROTECTED] Instant Interactive(tm) http://www.instantinteractive.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Problem with fileAttributesAtPath
On Aug 18, 2008, at 1:24 PM, Nicolas Goles wrote: Hi guys, I am trying to get fileAttributesAtPath using this code: (files contains the path to the directory that was enumerated ) while(object = [dirEnumerator nextObject]) { //First We craft the whole path for a single object NSString *fullPath = [files stringByAppendingString:object]; Try NSString *fullPath = [files stringByAppendingPathComponent:object]; instead. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Question about respondsToSelector
On Aug 18, 2008, at 11:17 AM, Carmen Cerino Jr. wrote: Does the id type have enough information for the respondsToSelector method to work. I have a class with an ivar of type id, and when I invoke the respondsToSelector method it fails when it should succeed. I am assuming it should work fine, because if I skip checking with the respondsToSelector method and just make the call, it executes the method. Can someone please tell me what I am doing wrong? What code are you using with -respondsToSelector: and to invoke the selector? We need to see that in order to be able to say whether what you're doing will work. On background: -respondsToSelector: is a message like any other message in Objective-C. It's not an operation on a type; you're actually sending a message to the object in question, which will use the Objective-C runtime to answer the question that's asked. So the static type of the variable referencing the object it's sent to -- in your case, id -- doesn't have anything to do with how the actual message behaves. -- Chris ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Question about respondsToSelector
On Aug 18, 2008, at 11:17 AM, Carmen Cerino Jr. wrote: Does the id type have enough information for the respondsToSelector method to work. I have a class with an ivar of type id, and when I invoke the respondsToSelector method it fails when it should succeed. I am assuming it should work fine, because if I skip checking with the respondsToSelector method and just make the call, it executes the method. Can someone please tell me what I am doing wrong? Perhaps you've misspelled the name of the selector - just like you've done above with respondsToSelector: (note the trailing :). 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 [EMAIL PROTECTED]
Re: Question about respondsToSelector
On Aug 18, 2008, at 2:17 PM, Carmen Cerino Jr. wrote: Does the id type have enough information for the respondsToSelector method to work. It's not whether the id type has information. It's whether the object itself is able to respond to a message, and that depends on what class the object is an instance of. I have a class with an ivar of type id, and when I invoke the respondsToSelector method it fails when it should succeed. When you have a problem, try to explain what you expected to happen and what actually happened. What results would have constituted success? What actually happened that you are calling failure? A crash? An error message? A value displayed that you weren't expecting? What object were you sending the respondsToSelector message to? What selector were you passing? What was the actual object in the id variable at the time? I am assuming it should work fine, because if I skip checking with the respondsToSelector method and just make the call, it executes the method. Can someone please tell me what I am doing wrong? It would be help if you post your code and describe what you are trying to do. --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 [EMAIL PROTECTED]
Re: Question about respondsToSelector
Also: note that method names are case-sensitive, so @selector(doSomething) is not the same as @selector(doSomeThing). Also, if the method you are referring to takes an argument, make sure you aren't forgetting the colon at the end. The name of the method contains all its colons; @selector(doSomething) is different from @selector(doSomething:). --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 [EMAIL PROTECTED]
Re: Using Flex/Lex in a Cocoa project
to avoid the splitting problem (c 128) ? %c : \\u%04x, c); On Sat, Aug 16, 2008 at 7:43 AM, Michael Ash [EMAIL PROTECTED] wrote: On Fri, Aug 15, 2008 at 10:53 PM, John Joyce [EMAIL PROTECTED] wrote: Right now, I'm toying with using Flex/Lex in a Cocoa project. Unfortunately, I don't see a reliable or easy way to handle NSStrings correctly all the time with Flex. Does anybody have any suggestions for such text handling and reliable unicode aware regexes? I'm seriously not interested in implementing such details in C with Flex. Flex is fast and cool for that, but if it's going to be stupidly difficult to use reliably with other languages on a mac, it's not a good idea for me. Depending on exactly what you need, unicode awareness can be fairly straightforward. Commonly, unicode in regexes is only needed to pass through undifferentiated blobs of text, with ASCII delimiters. For example, imagine parsing a CSV file which potentially has unicode text inside the quotes. For this case, you can convert the file to UTF-8, and then constructs like . will accept them. All non-ASCII characters in UTF-8 are represented as bytes 128-255, so if you just pass those through then you'll be fine. But be aware of some potential problem areas: - Each non-ASCII character will be more than one byte, and flex will think of it as more than one character. Write your regexes accordingly. In particular, avoid length limits on runs of arbitrary characters, and avoid using non-ASCII characters directly in your regex. - It's very difficult to split UTF-8 strings correctly. If you encounter a run of non-ASCII characters, ensure that you follow that run through the end, until you get back to ASCII. Don't have a regex that stops in the middle of it and then expects your code to be able to do something useful with it. - If you need to do something with non-ASCII characters besides read them in one side and write them out the other, for example doing something special with all accented characters, then Flex is probably not the right answer. Besides this it ought to be pretty straightforward. Since Flex just passes your code straight through to the compiler, you can write Objective-C in the actions (as long as you compile the result as Objective-C, of course!), convert the text from UTF-8 back to an NSString, and take things from there. 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/openspecies%40gmail.com This email sent to [EMAIL PROTECTED] -- -mmw ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Using Flex/Lex in a Cocoa project
On Aug 18, 2008, at 3:40 PM, mm w wrote: to avoid the splitting problem (c 128) ? %c : \\u%04x, c); I'm not sure what this solves. Per Michael's e-mail below, this is indeed a difficult problem. UTF-8 is just a particular scheme to store Unicode strings. Operating on individual bytes in such streams will most likely not make any sense. What I would do is pick some normalized form and operate on that data. For a recent feature at my day job, we normalized all input CSV files to UTF-16BE. We were able to handle all of our customer data so far. The final solution still isn't 100% Unicode-savvy (e.g. it does crap-out with surrogate pairs), but we have unit tests to expose/ document such limitations. And, customer data doesn't yet have such things. On Sat, Aug 16, 2008 at 7:43 AM, Michael Ash [EMAIL PROTECTED] wrote: - It's very difficult to split UTF-8 strings correctly. If you encounter a run of non-ASCII characters, ensure that you follow that run through the end, until you get back to ASCII. Don't have a regex that stops in the middle of it and then expects your code to be able to do something useful with it. ___ Ricky A. Sharp mailto:[EMAIL PROTECTED] Instant Interactive(tm) http://www.instantinteractive.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Using Flex/Lex in a Cocoa project
if you knew flex you could understand On Mon, Aug 18, 2008 at 1:55 PM, Ricky Sharp [EMAIL PROTECTED] wrote: On Aug 18, 2008, at 3:40 PM, mm w wrote: to avoid the splitting problem (c 128) ? %c : \\u%04x, c); I'm not sure what this solves. Per Michael's e-mail below, this is indeed a difficult problem. UTF-8 is just a particular scheme to store Unicode strings. Operating on individual bytes in such streams will most likely not make any sense. What I would do is pick some normalized form and operate on that data. For a recent feature at my day job, we normalized all input CSV files to UTF-16BE. We were able to handle all of our customer data so far. The final solution still isn't 100% Unicode-savvy (e.g. it does crap-out with surrogate pairs), but we have unit tests to expose/document such limitations. And, customer data doesn't yet have such things. On Sat, Aug 16, 2008 at 7:43 AM, Michael Ash [EMAIL PROTECTED] wrote: - It's very difficult to split UTF-8 strings correctly. If you encounter a run of non-ASCII characters, ensure that you follow that run through the end, until you get back to ASCII. Don't have a regex that stops in the middle of it and then expects your code to be able to do something useful with it. ___ Ricky A. Sharp mailto:[EMAIL PROTECTED] Instant Interactive(tm) http://www.instantinteractive.com -- -mmw ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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]
MultiTouch.framework Beta Program
Hi everyone, Maybe some of you have already seen our video (http://www.youtube.com/watch?v=skZCBvWVu8A ) on YouTube. In this video we use an iPhone as mobile substitution for a multi-touch table, so you can develop and test multi-touch applications at any location. On the desktop side we use our Cocoa multi-touch framework, which let's you develop multi-touch apps in Objective-C in a familiar programming environment. Since the beta version of our multi-touch framework is almost ready, we are now accepting applications for a private beta. If you know how to code in Objective-C with Cocoa, own an iPhone or iPod touch and would like to try out our framework before it is officially released, please write an email to stefan.hafeneger[AT]rwth-aachen.de with your contact details and your programming background. Please use MultiTouch.framework Beta Application as subject line since the emails will be filtered. If you got any questions concerning the beta program or the framework itself please visit our website (http://www.multitouchframework.com) or write me an email. With best wishes, Stefan smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Seeking Developer in San Carlos CA
Hi, We're looking for an OS X software engineer. Luidia is in San Carlos California. We make interactive display systems. We are profitable, small and fun. Cool hardware, interesting software. Mostly Cocoa and Obj-C, with some Carbon and C++ mixed in. Check out our website, and the job description, here: www.luidia.com Please respond to [EMAIL PROTECTED] You can download our latest software to play with. I'm cross posting this to a few lists so I apologize if you see this more than once. Thanks, Tracy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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]
Including frameworks in your app bundle
I've been searching, but I can't find the documentation explaining how to include frameworks in your app bundle (third-party frameworks, for example), so that your user does not have to install these frameworks. Could someone point me at the correct documentation/build settings? Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Including frameworks in your app bundle
example FRAMEWORK = MyFoo PREFIX = @executable_path/../Frameworks gcc -Wl,-single_module \ $(OBJS) \ $(LDFLAGS) \ -compatibility_version 1.0.0 \ -current_version 1.0.0 \ -install_name $(PREFIX)/$(FRAMEWORK).framework/Versions/$(VERSION)/$(FRAMEWORK) \ -dynamiclib \ -o $(FRAMEWORK) export your -F path and link your executable against the framework, you can also deploy OS libs / home ecetera On Mon, Aug 18, 2008 at 4:59 PM, Nick Pilch [EMAIL PROTECTED] wrote: I've been searching, but I can't find the documentation explaining how to include frameworks in your app bundle (third-party frameworks, for example), so that your user does not have to install these frameworks. Could someone point me at the correct documentation/build settings? 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/openspecies%40gmail.com This email sent to [EMAIL PROTECTED] -- -mmw ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Including frameworks in your app bundle
On Aug 18, 2008, at 19:59 , Nick Pilch wrote: I've been searching, but I can't find the documentation explaining how to include frameworks in your app bundle (third-party frameworks, for example), so that your user does not have to install these frameworks. Could someone point me at the correct documentation/build settings? Thanks. This is probably better for the XCode group, but check out this document: http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html It explains what you need to do to embed frameworks in your application. HTH, J smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Removing Observers
On 19 Aug 2008, at 4:23 am, Ryan Brown wrote: What is the best way to remove a KVO observer if you aren't sure if the object already has an observer registered? The right answer is to avoid this unsureness (is that a word?). When I first started using KVO I too thought you could unregister regardless - if it was registered it will unregister, if it wasn't it does nothing. Unfortunately it doesn't work - Cocoa is very fussy about this, and throws exceptions when you try to do things this way with KVO. In addition, each observer has a separate connection so each must be disconnected individually - there is no disconnect all available. KVO is not like ordinary notifications. The point is that observees should not know or care about their observers. Once you stop trying to let observees control their observers your problems will ease considerably. Instead, observers are entirely responsible for their own actions - observing an object and unobserving it later. The main problem usually is the need to unobserve before the observee is deallocated out from under it. There's no one true way to do this, but just organise your code so that the need doesn't arise. For example a controller that deletes an object can send a about to delete x message before it does so that any observers can disconnect from x, or the deletion of an object is handled through a wrapper method that removes the observers. Typically if you look at where and why you are observing an object, a simple approach to managing its observers is usually straightforward. I must admit though that getting it right can be tricky especially if you're trying to fit KVO into an existing model that wasn't built with it in mind. 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 [EMAIL PROTECTED]
Re: Using Flex/Lex in a Cocoa project
On Aug 18, 2008, at 7:01 PM, [EMAIL PROTECTED] wrote: to avoid the splitting problem (c 128) ? %c : \\u%04x, c); Not quite sure what this is doing. I see it's checking for ASCII range if ( c 128 ) The conditional is obvious, but what's the other doing exactly? returning a char if it is ASCII, it seems, and then some sort of escaped version if it is beyond ASCII range...? Particularly there, I'm not sure what that results in. Basically, I only need to do anything based on characters that are in ASCII now, but I'd like to allow other ranges in the text files without worry. Browsing around, I've seen where basically, everyone is hoping somebody else will modernize lex and yacc with a clever algorithm that reduces the overhead. Personally, I think that in many cases, this should be no problem with the speed and capability of contemporary computers, but it could still be a drag. I have been looking at simply building an NSString of the same length with ranges of non-ASCII subbed out with some other character, just to do the lexing, then apply the results of the lex to the original NSString. For speed, it may even make sense to simply have two NSStrings going, one that is the real thing, the other that auto-substitutes anything non-ASCII. For this, my question to all is, what ASCII character would be good for the substitution without messing up the regexes? I'm considering some the unused control characters in the lower ranges, but I'm a little scared to see what will happen... Any suggestions on this idea? Cheers, JJ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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: Using Flex/Lex in a Cocoa project
On Aug 18, 2008, at 8:01 PM, John Joyce wrote: On Aug 18, 2008, at 7:01 PM, [EMAIL PROTECTED] wrote: to avoid the splitting problem (c 128) ? %c : \\u%04x, c); Not quite sure what this is doing. I see it's checking for ASCII range if ( c 128 ) The conditional is obvious, but what's the other doing exactly? returning a char if it is ASCII, it seems, and then some sort of escaped version if it is beyond ASCII range...? Particularly there, I'm not sure what that results in. That was my question too. If operating on a UTF-8 stream, this is going to do all kinds of weird stuff. For example, for the input string LATIN SMALL LETTER E WITH ACUTE (U +00E9), you'll have a UTF-8 byte sequence of 0xC3 0xA9. But the above will turn that UTF-8 sequence of bytes into this string: \u00C3\u00A9 This string now represents: LATIN CAPITAL LETTER A WITH TILDE (U+00C3) followed by COPYRIGHT SIGN (U+00A9) ___ Ricky A. Sharp mailto:[EMAIL PROTECTED] Instant Interactive(tm) http://www.instantinteractive.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Using Flex/Lex in a Cocoa project
On Aug 18, 2008, at 8:12 PM, Ricky Sharp wrote: On Aug 18, 2008, at 8:01 PM, John Joyce wrote: On Aug 18, 2008, at 7:01 PM, [EMAIL PROTECTED] wrote: to avoid the splitting problem (c 128) ? %c : \\u%04x, c); Not quite sure what this is doing. I see it's checking for ASCII range if ( c 128 ) The conditional is obvious, but what's the other doing exactly? returning a char if it is ASCII, it seems, and then some sort of escaped version if it is beyond ASCII range...? Particularly there, I'm not sure what that results in. That was my question too. If operating on a UTF-8 stream, this is going to do all kinds of weird stuff. For example, for the input string LATIN SMALL LETTER E WITH ACUTE (U +00E9), you'll have a UTF-8 byte sequence of 0xC3 0xA9. But the above will turn that UTF-8 sequence of bytes into this string: \u00C3\u00A9 This string now represents: LATIN CAPITAL LETTER A WITH TILDE (U+00C3) followed by COPYRIGHT SIGN (U+00A9) ___ Ricky A. Sharp mailto:[EMAIL PROTECTED] I wonder if it wouldn't make sense to just start trying to build some new form of flex in Objective-C... so that it uses NSString and NSMutable string ? I'm looking at the Flex source code now... in true GNU fashion, it is well documented, but somewhat terse 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 [EMAIL PROTECTED]
Re: Using Flex/Lex in a Cocoa project
On 19 Aug 2008, at 11:53 am, John Joyce wrote: I wonder if it wouldn't make sense to just start trying to build some new form of flex in Objective-C... so that it uses NSString and NSMutable string ? I'm looking at the Flex source code now... in true GNU fashion, it is well documented, but somewhat terse C... And you know about NSScanner, right? 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 [EMAIL PROTECTED]
How to write a string to a file
I know it sounds like a basic question, but I've looked and it doesn't seem as obvious to me as it should. I want to write out data to a file to describe my tree structure. I'd like to have a method which appends a string to the end of a text file. I don't really want to store everything in memory and write out one big string because it might get quite large. How are you supposed to do this in Cocoa? Why isn't it more obvious? I've looked in NSString, NSData, NSFileHandle, NSOutputStream, but I don't see a simple way to append a string to a file. Can it really be this hard? NSString doesn't have a method to append to a file, nor a stream, nor NSData. And the other classes don't have a method to accept a string. Thanks ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: How to write a string to a file
On Aug 18, 2008, at 8:00 PM, David wrote: I know it sounds like a basic question, but I've looked and it doesn't seem as obvious to me as it should. I want to write out data to a file to describe my tree structure. I'd like to have a method which appends a string to the end of a text file. I don't really want to store everything in memory and write out one big string because it might get quite large. How are you supposed to do this in Cocoa? Why isn't it more obvious? I've looked in NSString, NSData, NSFileHandle, NSOutputStream, but I don't see a simple way to append a string to a file. Can it really be this hard? NSString doesn't have a method to append to a file, nor a stream, nor NSData. And the other classes don't have a method to accept a string. You were pretty close to a solution, I think. Here's how I'd do it (typed in Mail, may not compile, etc.): NSString *string = @string; NSFileHandle *fh = [NSFileHandle fileHandleForWritingAtPath:pathToFile]; [fh seekToEndOfFile]; [fh writeData:[string dataUsingEncoding:NSUTF8StringEncoding]]; [fh closeFile]; You could easily wrap this up in an NSString category if needed. -- Adam smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: How to write a string to a file
On Aug 18, 2008, at 10:00 PM, David wrote: I know it sounds like a basic question, but I've looked and it doesn't seem as obvious to me as it should. I want to write out data to a file to describe my tree structure. I'd like to have a method which appends a string to the end of a text file. I don't really want to store everything in memory and write out one big string because it might get quite large. How are you supposed to do this in Cocoa? Why isn't it more obvious? I've looked in NSString, NSData, NSFileHandle, NSOutputStream, but I don't see a simple way to append a string to a file. Can it really be this hard? NSString doesn't have a method to append to a file, nor a stream, nor NSData. And the other classes don't have a method to accept a string. Any attempt to store a string raises the question of how the string should be represented. That is, what encoding it should be written in. That question is not something the framework can decide on its own. You need to decide that. Once you do, you can obtain an NSData from an NSString with your desired encoding (-[NSString dataUsingEncoding:]). Once you've got an NSData, you can append it to a file using NSFileHandle. You need to seek to the end of the file before writing. Use something like: [fh seekToEndOfFile]; [fh writeData:[myString dataUsingEncoding: NSUTF8StringEncoding]]; 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 [EMAIL PROTECTED]
Re: How to write a string to a file
Thanks for the quick responses. Why isn't this already in NSString?I found an old reference saying to use [filehandle writeData:[nsstring dataUsingEncoding:...]] This seems obtuse. I have been using Cocoa for 6 months and it is not seeming any more consistent nor powerful than when I started. I find Cocoa to be inconsistent with random pockets of powerful features with many areas of spotty coverage of basic methods that I'd expect to be present. Some issues: NSString includes lots of methods to work with paths, URLs, etc. This breaks encapsulation. It does not seem to be good design for NSString to have this unique function dealing with paths. That should be in another class. Basic methods should exist somewhere for writing primitive types to a file. NSString writeToFile seems like an odd method. Why just this one means to write in this class? Why such an emphasis on atomic, which seems like such a complex uncommon algorithm? Why is there no option to append to a file? Similarly, NSFileHandle and NSOutputStream could have methods to write primitive types, or at least NSString. NSOutputStream provides the following method, - (NSInteger)write:(const uint8_t *)*buffer* maxLength:(NSUInteger)*length* Why doesn't it use NSData? What's the point of having the NSData construct if it isn't even used? I could go on, but I should stop. The method name makeKeyAndOrderFront amazes me on NSWindow. It took me way too long to find that. It is my current winner for least discoverable name. On Mon, Aug 18, 2008 at 11:00 PM, David [EMAIL PROTECTED] wrote: I know it sounds like a basic question, but I've looked and it doesn't seem as obvious to me as it should. I want to write out data to a file to describe my tree structure. I'd like to have a method which appends a string to the end of a text file. I don't really want to store everything in memory and write out one big string because it might get quite large. How are you supposed to do this in Cocoa? Why isn't it more obvious? I've looked in NSString, NSData, NSFileHandle, NSOutputStream, but I don't see a simple way to append a string to a file. Can it really be this hard? NSString doesn't have a method to append to a file, nor a stream, nor NSData. And the other classes don't have a method to accept a string. Thanks ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Removing Observers
On 19/08/2008, at 10:16 AM, Graham Cox wrote: The point is that observees should not know or care about their observers. Once you stop trying to let observees control their observers your problems will ease considerably. Instead, observers are entirely responsible for their own actions - observing an object and unobserving it later. The main problem usually is the need to unobserve before the observee is deallocated out from under it. There's no one true way to do this, but just organise your code so that the need doesn't arise. For example a controller that deletes an object can send a about to delete x message before it does so that any observers can disconnect from x, or the deletion of an object is handled through a wrapper method that removes the observers. Typically if you look at where and why you are observing an object, a simple approach to managing its observers is usually straightforward. I must admit though that getting it right can be tricky especially if you're trying to fit KVO into an existing model that wasn't built with it in mind. I have quite a few observers that persist as long as the document is open and one thing I've found useful is to post a notification when the document is going away, which tells all the observers that are instantiated in that document to remove themselves as observers. I agree that this is an annoying problem and I wish that Apple had implemented this with weak references as they have with NotificationCenter observers. Maybe they have for Snow Leopard, I haven't checked. -- 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 [EMAIL PROTECTED]
Re: Using Flex/Lex in a Cocoa project
On Mon, Aug 18, 2008 at 4:55 PM, Ricky Sharp [EMAIL PROTECTED] wrote: On Aug 18, 2008, at 3:40 PM, mm w wrote: to avoid the splitting problem (c 128) ? %c : \\u%04x, c); I'm not sure what this solves. Per Michael's e-mail below, this is indeed a difficult problem. UTF-8 is just a particular scheme to store Unicode strings. Operating on individual bytes in such streams will most likely not make any sense. What I would do is pick some normalized form and operate on that data. For a recent feature at my day job, we normalized all input CSV files to UTF-16BE. We were able to handle all of our customer data so far. The final solution still isn't 100% Unicode-savvy (e.g. it does crap-out with surrogate pairs), but we have unit tests to expose/document such limitations. And, customer data doesn't yet have such things. Note that depending on what kind of results you want, even if all of your data is within the BMP, this *still* won't save you. As a really basic example, consider a simple, obvious character like é. (That's an e with an acute accent on it if you're having unicode trouble in your e-mail client.) That can be represented as two separate unicode code points, a plain old ASCII e followed by a combining accent mark. If you should happen to split the string on the accent mark, such that the e goes into the first half and the combining accent mark goes into the second half, you get a really unintuitive result. What appears to the user to be a single character gets suddenly blown in two. Worse, if you happen to insert a string in the middle, you could end up applying that acute accent to some *other* letter instead. And if you think this is bad, you should see how Unicode deals with Korean. If you're using NSString, you can find good places to split using the -rangeOfComposedCharacterSequenceAtIndex: method. I believe that it will also deal with surrogate pairs, not only normal composed character sequences. Ultimately if you're doing any manipulation of Unicode, some large amount of knowledge about Unicode needs to be in the system somewhere. If your code is running on a Mac then you can use the knowledge that NSString has about Unicode to help out, sometimes. But alas, due to how Unicode is designed, there's simply no way to safely manipulate strings beyond very basic operations like concatenation unless you either make the code know a lot about Unicode or place overly strong constraints on the system, such as only splitting on line breaks or carriage returns (or commas). Yeah, the situation kind of sucks, but it's what we're stuck with. Thankfully Foundation and CoreFoundation do a lot to hide the messy, ugly details from us. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: How to write a string to a file
On Mon, Aug 18, 2008 at 11:28 PM, David [EMAIL PROTECTED] wrote: Thanks for the quick responses. Why isn't this already in NSString?I found an old reference saying to use [filehandle writeData:[nsstring dataUsingEncoding:...]] This seems obtuse. I have been using Cocoa for 6 months and it is not seeming any more consistent nor powerful than when I started. I find Cocoa to be inconsistent with random pockets of powerful features with many areas of spotty coverage of basic methods that I'd expect to be present. Some issues: NSString includes lots of methods to work with paths, URLs, etc. This breaks encapsulation. It does not seem to be good design for NSString to have this unique function dealing with paths. That should be in another class. Basic methods should exist somewhere for writing primitive types to a file. NSString writeToFile seems like an odd method. Why just this one means to write in this class? Why such an emphasis on atomic, which seems like such a complex uncommon algorithm? Why is there no option to append to a file? Similarly, NSFileHandle and NSOutputStream could have methods to write primitive types, or at least NSString. NSOutputStream provides the following method, - (NSInteger)write:(const uint8_t *)*buffer* maxLength:(NSUInteger)*length* Why doesn't it use NSData? What's the point of having the NSData construct if it isn't even used? I could go on, but I should stop. The method name makeKeyAndOrderFront amazes me on NSWindow. It took me way too long to find that. It is my current winner for least discoverable name. If there are things you're unsatisfied with, you'll get much better results filing bugs on them at bugreport.apple.com rather than complaining to the list. The people who read the list generally aren't in a position to fix these things, and when they are they still generally can't do anything about it unless people file bugs. That said, I should assure you that Cocoa gets a lot more powerful and sensible when you learn more of it. The learning curve is difficult because it's such an integrated system. But what that means is that at some point you reach critical mass and it will suddenly make a great deal more sense. Many of the things you point out are entirely legitimate (NSStream should definitely work with NSData objects!) but ultimately, in the grand scheme of things, they aren't all that significant. Mike ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: How to write a string to a file
On Aug 18, 2008, at 10:59 PM, David [EMAIL PROTECTED] wrote: Thanks for the quick responses. Why isn't this already in NSString?I found an old reference saying to use [filehandle writeData:[nsstring dataUsingEncoding:...]] This seems obtuse. I have been using Cocoa for 6 months and it is not seeming any more consistent nor powerful than when I started. Funny, I find that the more I learn about Cocoa, the more consistent it is. I find Cocoa to be inconsistent with random pockets of powerful features with many areas of spotty coverage of basic methods that I'd expect to be present. They usually are - but the terminology is the hard part. OS X uses terminology that - while very consistent in itself - is different than UNIX or Windows many times. Some issues: NSString includes lots of methods to work with paths, URLs, etc. This breaks encapsulation. It does not seem to be good design for NSString to have this unique function dealing with paths. That should be in another class. Paths are strings - so that makes sense. Dealing with paths is a very common thing and its not technically part of NSString - its a category of NSString that Apple wrote. I find it very helpful. Basic methods should exist somewhere for writing primitive types to a file. They do. Its in NSCoder. Or use NSData to take any primitive type and turn it into a byte stream. Then use NSFileHandle to write it. NSString writeToFile seems like an odd method. Why just this one means to write in this class? Why such an emphasis on atomic, which seems like such a complex uncommon algorithm? Why is there no option to append to a file? writeToFile is available in LOTS of classes. I just did a API search and it came up with a couple screenfuls. Similarly, NSFileHandle and NSOutputStream could have methods to write primitive types, or at least NSString. They handle bytes. Use NSData to convert it to bytes. Why is this hard or wrong? NSOutputStream provides the following method, - (NSInteger)write:(const uint8_t *)*buffer* maxLength: (NSUInteger)*length* Why doesn't it use NSData? What's the point of having the NSData construct if it isn't even used? I could go on, but I should stop. The method name makeKeyAndOrderFront amazes me on NSWindow. It took me way too long to find that. It is my current winner for least discoverable name. Its a terminology issue. Mac OS has had that same terminology for many many many years. Look - I've been doing Windows development since 2000 in C++ as well as a little in .NET. I also did some original OS 7/8 development way back when in Pascal - years ago. I spent a year lurking on this group starting early 2007 to get an idea of the main questions and issues Cocoa devs had as well as learning Obj-C and learning why things are done a certain way. That helped me a lot as it helped gel a ton of concepts and bits of terminology that when I finally did dive into Cocoa full time 4-5 months ago it felt natural. Since then I've come across many many times when I couldn't find the answer to something simple - only to find that my terminology was wrong and bam - it was there. It does help that I have an experienced Apple dev on my team too that I can go to when I can't seem to find what I'm looking for. But this very same question hit me last week that you had. It took me all of 30 minutes to find the answer in the Apple docs because of its consistency. I attribute that to taking that year to really learn the way OS X thinks. I consider myself past the hump, but still on a journey of learning and so hopefully my two cents will give hope and maybe some help :) Alex Kac - President and Founder Web Information Solutions, Inc. I am not young enough to know everything. --Oscar Wilde ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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 write a string to a file
On Aug 18, 2008, at 10:28 PM, David wrote: Why isn't this already in NSString? I would sooner suggest removing -writeToFile:... from NSString than adding -appendToFile:. At some point you get a many-to-many explosion of combinations (NString, NSData, NSArray, NSDictionary, NSValue, NSNumber, etc.) times (NSFileHandle, NSStream, NSPort, etc.). Much better to have a many-to-one-plus-one-to-many design. I would guess that things like - writeToFile: are a legacy from early days which now can't be removed easily. NSString includes lots of methods to work with paths, URLs, etc. This breaks encapsulation. It does not seem to be good design for NSString to have this unique function dealing with paths. That should be in another class. Actually, those methods are not in the NSString class. They're in a category on that class, NSString(NSStringPathExtensions) in NSPathUtilities.h. So, I don't think it breaks encapsulation. Basic methods should exist somewhere for writing primitive types to a file. Agreed. However, part of the answer to your concerns is that Objective-C is still C and you can use all of the C libraries and system calls. The main advantage of NSFileHandle over stdio is its asynchronous capabilities and integration with run loops. Also, if your data is most easily obtained in an NSData. If you don't need those capabilities, consider using stdio or another alternative that better matches your needs. Also, don't forget that you can extend NSFileHandle with whatever methods you like using categories. NSOutputStream provides the following method, - (NSInteger)write:(const uint8_t *)*buffer* maxLength:(NSUInteger) *length* Why doesn't it use NSData? What's the point of having the NSData construct if it isn't even used? It probably should have a method accepting an NSData. However, NSData does have -bytes and -length methods, which makes invoking the above method trivial if you have an NSData. And, of course, the above method is useful if you have a non-object type to write to the stream. You don't need to wrap it in an NSData. 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 [EMAIL PROTECTED]
Shared NSTextView
I am developing a custom view, sort of a simple graphic editor, where the user can draw graphic boxes of different size. Each box should display its own attributed string bounded by its own size, and when the user double-clicks any box, he becomes able to edit the box's text in-place. I have read the docs and have a general understanding of the text system components: NSTextStorage, NSLayoutManager, NSTextContainer and NSTextView. However I wonder if some instances of these can be shared across different graphic boxes for better efficiency? I could go the simple and dull way and create a separate instance of NSTextView for each box, but I am afraid this could be a waste of resources, because layout manager is costy. Also, most of time I only need to display text in boxes, not to edit it. I thought it could be smarter to create a single shared instance of NSTextView per custom view, and re-attach it to different boxes when the user double-clicks a box. The rest of time I'd use NSTextStorage and NSTextContainer to just draw the string. Is this a good idea? In this case, what object instances should each graphic box have of its own? My guess is that each graphic box should have its own instances of NSTextStorage and NSTextContainer, but I am not sure what about NSLayoutManager? Can it be shared too, or it's going to be inefficient? How do I reconnect the shared components from a box to another box? Thanks. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSView confusion
I have tried everything I can think of and have tried the documentation I can find and I still can not figure out what is going on or what to do about it. I have an app that contains multiple NSView's which are all visible at the same time. They are all sub-classes of NSView but not of any of the others. Each has its initialize, initWithRect and drawRect methods invoked as it should. With the exception of the 1st one I defined, the workhorse view, no methods implemented in any of the others and declared in the respective .h files are visible to any of the other views at compile time. I import the appropriate .h files and invoke the method via [view method... and the compiler reports that no such method can be found. Yet if I invoke the method via [view performSelector:... at execution time it works just fine. I have no idea why the compile time recognition fails. Can someone explain to me what is going on and what I can do about it? Should there be a view hierarchy? If so, how structured? Also, how does one synchronize events with the update of the various views? I can instruct each view what to draw and it draws it just fine (I use lockFocus, etc. when drawing is external to drawRect) and the updated view is seen _eventually_ but I can not synchronize subsequent activity to happen after the appropriate display is seen. How can I accomplish this synchronization? And how can I force a view to update? Invoking [view display] has no effect on forcing the display toshow the latest update. Thanks for any help you can provide. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. 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 write a string to a file
On Aug 18, 2008, at 11:28 PM, David wrote: Thanks for the quick responses. Why isn't this already in NSString?I found an old reference saying to use [filehandle writeData:[nsstring dataUsingEncoding:...]] This seems obtuse. I have been using Cocoa for 6 months and it is not seeming any more consistent nor powerful than when I started. I find Cocoa to be inconsistent with random pockets of powerful features with many areas of spotty coverage of basic methods that I'd expect to be present. To a degree, I sympathize. You could certainly argue that a method like [myString appendToPath:myPath usingEncoding:NSUTF8StringEncoding] is useful and obvious enough that it should have been built into NSString in the first place. I think reasonable minds could disagree, but you could make the case (and, as Michael suggested, you can file a bug report requesting the method; I believe Apple has added convenience methods like this from time to time). On the other hand: first, I think any API designer has to draw the line somewhere, especially with a class as widely used as a string class; when do you stop adding convenience methods? Second, as others have pointed out, Objective-C at least gives you the option to add this behavior yourself, via a category. Third, I think it's easy to find fault with any complex API that does things differently than you're used to. Sometimes this is due to a legitimately crappy API, and sometimes you just have to be a little more willing to go with the flow if you want to be successful on that platform, and while I can't promise this (I'm always reluctant to make statements like you will see the light), you *might* even be surprised to find it makes sense. Cocoa isn't perfect, but it isn't just Cocoa. Back in the early 90's, I tried ParcPlace Smalltalk and was stunned a how crude the windowing APIs were -- at PARC of all places, the birthplace of the GUI. Today, as a Java programmer, I think it's odd that you need a utility class to sort an array instead of just telling the array to sort itself, and I can never remember all the combinations of Buffers, Writers, and Streams I need for various kinds of I/O. And it's been many moons since I wrote a UI in Java, but I thought it was pretty crude then too. So nobody's perfect. That said, one of the things Cocoa developers like is actually its *consistency* -- the grammatical consistency of its naming conventions, the consistent application of a few design patterns, and so forth. Some issues: NSString includes lots of methods to work with paths, URLs, etc. This breaks encapsulation. No it doesn't. These methods do not reveal implementation details or allow other objects to muck with NSString internals. It does not seem to be good design for NSString to have this unique function dealing with paths. That should be in another class. You could say the same thing about file operations. Path operations are common enough, with enough annoying edge cases, that I'd think you'd be the first to welcome them in NSString. I could go on, but I should stop. The method name makeKeyAndOrderFront amazes me on NSWindow. It took me way too long to find that. It is my current winner for least discoverable name. The name makes perfect sense to me *now*, but if I must admit others before you have also gone hunting for that method. --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 [EMAIL PROTECTED]
Re: NSView confusion
On Aug 18, 2008, at 7:02 PM, Charlie Dickman wrote: I import the appropriate .h files and invoke the method via [view method... and the compiler reports that no such method can be found. Yet if I invoke the method via [view performSelector:... at execution time it works just fine. When you say [view method...] what is view declared as? Is it declared as an NSView or as an instance of your NSView subclass? --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 [EMAIL PROTECTED]
Re: Shared NSTextView
You can share an instance of NSTextStorage and NSLayoutManager with multiple NstextContainer+NSTextViews only if you are displaying same text in all those textViews. But as in your case you will have to use a separate set of above classes for each textView, that means you cannot share the layout manager as it belongs to a single textStorage. Have a look at the following documentation to get a general idea bout the same http://developer.apple.com/documentation/Cocoa/Conceptual/TextArchitecture/Concepts/CommonConfigs.html#/ /apple_ref/doc/uid/2840 -Chaitanya On 19-Aug-08, at 12:46 AM, Oleg Krupnov wrote: I am developing a custom view, sort of a simple graphic editor, where the user can draw graphic boxes of different size. Each box should display its own attributed string bounded by its own size, and when the user double-clicks any box, he becomes able to edit the box's text in-place. I have read the docs and have a general understanding of the text system components: NSTextStorage, NSLayoutManager, NSTextContainer and NSTextView. However I wonder if some instances of these can be shared across different graphic boxes for better efficiency? I could go the simple and dull way and create a separate instance of NSTextView for each box, but I am afraid this could be a waste of resources, because layout manager is costy. Also, most of time I only need to display text in boxes, not to edit it. I thought it could be smarter to create a single shared instance of NSTextView per custom view, and re-attach it to different boxes when the user double-clicks a box. The rest of time I'd use NSTextStorage and NSTextContainer to just draw the string. Is this a good idea? In this case, what object instances should each graphic box have of its own? My guess is that each graphic box should have its own instances of NSTextStorage and NSTextContainer, but I am not sure what about NSLayoutManager? Can it be shared too, or it's going to be inefficient? How do I reconnect the shared components from a box to another box? 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/chaitanya%40expersis.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Shared NSTextView
On 19 Aug 2008, at 3:23 pm, chaitanya pandit wrote: But as in your case you will have to use a separate set of above classes for each textView, that means you cannot share the layout manager as it belongs to a single textStorage. Not strictly true, because while the LM is associated with the text storage, you can switch it on the fly. Whether this is faster or slower than having a separate instance would need to be measured, but it definitely works. 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 [EMAIL PROTECTED]