Re: Event loop expiration date insight
I'm handling some mouse dragging tasks modally by implementing my own modal event loop using [NSApp nextEventMatchingMask:untilDate:inMode:dequeue:]. I'm wondering what is the usual correct thing to pass for the 'untilDate' parameter. For a long time I've been using [NSDate distantFuture], but the documentation of this method says that by passing nil it uses [NSDate distantPast], which implies perhaps that this is a more usual default. In thinking about this I realise I don't I am running manually a runloop in a command line utility that loads XML data through an URL. I use the current date for the time parameter like this: while (_WMSenCours) { [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0]]; } where the flag _WMSenCours goes false when I received a message of data completion. I suspect if you pass a date that is either in the past or present, the runloop is performed only once and exits whether it detects or no an incoming event. If you specify “distant future”, you will be stuck in the runloop until an event occurs. Which, in most cases, should not make any difference except for debugging purposes. Vincent ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Event loop expiration date insight
On Oct 30, 2012, at 9:58 PM, Graham Cox graham@bigpond.com wrote: I'm wondering what is the usual correct thing to pass for the 'untilDate' parameter. For a long time I've been using [NSDate distantFuture], but the documentation of this method says that by passing nil it uses [NSDate distantPast], which implies perhaps that this is a more usual default. In thinking about this I realise I don't really understand what this parameter is doing, especially when 'distantPast' is specified - does that mean do not wait at all for any events and only return one if it's already queued? If the date is in the past then the method returns immediately. If there is a matching event in the queue then it will be returned. I've changed this to pass nil and my mouse dragging works as normal. This is generally not recommended. Using nil instead of -distantFuture may use more CPU and power while the drag is in progress. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: createDirectoryAtPath:withIntermediateDirectories:attributes:error: Returns NO when it exists
On 30.10.2012, at 19:17, Quincey Morris wrote: On Oct 30, 2012, at 10:39 , Sean McBride s...@rogue-research.com wrote: Note that in my experience YES is returned if the directory exists. It's also worth consulting the header file comments: createDirectoryAtPath:withIntermediateDirectories:attributes:error: creates a directory at the specified path. If you pass 'NO' for createIntermediates, the directory must not exist at the time this call is made. Passing 'YES' for 'createIntermediates' will create any necessary intermediate directories. This method returns YES if all directories specified in 'path' were created and attributes were set. […] This method returns NO if a failure occurs at any stage of the operation. There's a certain inscrutability to this, but it seems to suggest that passing 'YES' for createIntermediates will allow the directory to already exist (in effect, the directory is created as one of the intermediates), while passing 'NO' requires the directory not to exist. Thanks for the hint to consult the headers. IMO, this clears it up -- and it works now as expected when parameter `createIntermediates` is set to `YES`. The need to consult the headers seems to become a standard task. But with clang's symbol lookup, it's a quite comfortable. ;) Andreas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Programmatically providing default value for new core data attribute?
Hi. I've added a simple attribute to my model that should be a concatenation of a handful of other attributes, run through some code. I don't suppose there's any way to do the lightweight migration but tell it, here's a method to call to get the default value of this property? I looked at doing a mapping model, but even that just has me build the value in there; no apparent way to run it through my code. Given that, I can let lightweight migration do its thing, then post-process it, but I don't see a way to determine that lightweight migration ran when I opened the store. Any suggestions? Will -isConfiguration:compatibleWithStoreMetadata: tell me a lightweight migration-capable change is incompatible? Thanks, -- Rick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
printing Utf8
I print strings like: NSString *s = @ร่วมรส; fprintf(stderr, %s\n, [ s UTF8String]); and usually it just works. But sometimes it does not and I get garbage like: ร่ว\340\270\241รส Converting these numbers to hex one gets: 0xe0 0xb8 0xa1 which is the Utf8-code for THAI CHARACTER MO MA. So why does it not print (as it should): ร่วมรส ? This is not really reproducible, but happens in about 3% of all lines. Known error, or my mistake? Or some well meant attempt to prevent any form of indecency appearing on my screen (ร่วมรส = copulate)? Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: printing Utf8
On Oct 31, 2012, at 9:41 AM, Gerriet M. Denkmann wrote: I print strings like: NSString *s = @ร่วมรส; fprintf(stderr, %s\n, [ s UTF8String]); and usually it just works. But sometimes it does not and I get garbage like: ร่ว\340\270\241รส Converting these numbers to hex one gets: 0xe0 0xb8 0xa1 which is the Utf8-code for THAI CHARACTER MO MA. So why does it not print (as it should): ร่วมรส ? This is not really reproducible, but happens in about 3% of all lines. Known error, or my mistake? I have a couple of guesses: * A bug in Terminal.app. Does it happen in other terminal apps like iTerm (if you've tried)? I assume it is never the case that the octal escape sequences get written out to file, if you redirect stderr. Is that correct? (That is, I don't think your program is actually writing out the octal sequence. I think it's just a display issue.) * Perhaps there's an issue with the stdio buffer breaking the sequence of UTF-8 code units for a code point into two separate writes. In your example code, that wouldn't happen because a) you're writing short lines and b) stderr is unbuffered by default. However, if your real code that exhibits the problem might be fully buffered (or line buffered if you're writing lines long enough to exceed the buffer size), then this might happen. If the sequence does get split into multiple writes, that still shouldn't be a problem unless the program receiving the data doesn't handle that case. So, this would really just be a specific explanation of a possible Terminal bug. Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: printing Utf8
hi- On Oct 31, 2012, at 10:41 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: NSString *s = @ร่วมรส; Not supported. The compiler should be issuing a warning. You need to escape the characters using a UTF encoding. thanks!- -lance ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: printing Utf8
On Oct 31, 2012, at 10:17 AM, lbland wrote: On Oct 31, 2012, at 10:41 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: NSString *s = @ร่วมรส; Not supported. The compiler should be issuing a warning. You need to escape the characters using a UTF encoding. That's not true. The compiler has supported UTF-8 source encoding for quite a while now. Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: printing Utf8
Le 31 oct. 2012 à 16:17, lbland lbl...@vvi.com a écrit : hi- On Oct 31, 2012, at 10:41 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: NSString *s = @ร่วมรส; Not supported. The compiler should be issuing a warning. You need to escape the characters using a UTF encoding. I never had any problem including UTF8 chars in NSStrings, like arrows, math symbols or other weird glyphs. My guess is either a glitch in Terminal or the shell you use (stty pass8, etc.). Does it happen with NSLog? In general, I think it is much better to use NSLog rather than fprintf (stderr, …). Vincent ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: printing Utf8
On 31 Oct 2012, at 22:15, Ken Thomases k...@codeweavers.com wrote: On Oct 31, 2012, at 9:41 AM, Gerriet M. Denkmann wrote: I print strings like: NSString *s = @ร่วมรส; fprintf(stderr, %s\n, [ s UTF8String]); and usually it just works. But sometimes it does not and I get garbage like: ร่ว\340\270\241รส Converting these numbers to hex one gets: 0xe0 0xb8 0xa1 which is the Utf8-code for THAI CHARACTER MO MA. So why does it not print (as it should): ร่วมรส ? This is not really reproducible, but happens in about 3% of all lines. Known error, or my mistake? I have a couple of guesses: * A bug in Terminal.app. Does it happen in other terminal apps like iTerm (if you've tried)? No, have not. Not even used Terminal. The stuff appears in one of the many panes of Xcode. I assume it is never the case that the octal escape sequences get written out to file, if you redirect stderr. Is that correct? (That is, I don't think your program is actually writing out the octal sequence. I think it's just a display issue.) I don't do anything at all with stderr. Maybe Xcode does. Another thing: same problem happens (occasionally) with NSLog() also in this Xcode output-pane. Printing about 5000 chars (= 15000 Utf-8 bytes) there are 8 such glitches. If somebody cuts my output into 1024 byte chunks, there will be 15 of these. If there is a 2 in 3 chance of getting the border just wrong (cutting a 3-byte Utf-char into 2 invalid parts) there will be 10 glitches. Fits with the actual number of 8. Guess your explanation sounds rather probable. Kind regards, Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Programmatically providing default value for new core data attribute?
[resent to list-serve] You can create a subclass of NSEntityMigrationPolicy, then specify this class in the Custom Policy for that entity in your mapping model. During migration, the createDestinationInstancesForSourceInstance method of your migration policy class will be called, and can fill in the value for the new attribute. Note that the object you will get to work with will be a generic NSManagedObject, and not any subclass you have defined for that entity. So if you need your subclass methods, or if you need to access other entities, and not just the one you are handed, you will need to do that AFTER migration has completed. Dave On 2012-10-31, at 5:44 AM, Rick Mann rm...@latencyzero.com wrote: Hi. I've added a simple attribute to my model that should be a concatenation of a handful of other attributes, run through some code. I don't suppose there's any way to do the lightweight migration but tell it, here's a method to call to get the default value of this property? I looked at doing a mapping model, but even that just has me build the value in there; no apparent way to run it through my code. Given that, I can let lightweight migration do its thing, then post-process it, but I don't see a way to determine that lightweight migration ran when I opened the store. Any suggestions? Will -isConfiguration:compatibleWithStoreMetadata: tell me a lightweight migration-capable change is incompatible? It tells you whether or not a migration is needed (lightweight or otherwise). Thanks, -- Rick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/dave.fernandes%40utoronto.ca This email sent to dave.fernan...@utoronto.ca ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Drawing customized window
Forgot to add, the slowness on 10.7/10.8 can be seen in Activity monitor during video playback (I am playing a QTMovie onto QTMovieLayer). While QuickTime player takes 30%, my app takes up to 100% of the CPU power to play the same video.. That's where I checked the app using Instruments - I am getting 30-40% of time spent in QuickTime decoding functions, and the rest of the time - deep inside RunLoop... It is slow like that only on Lion and Moutain Lion. As soon as comment out this methods swizzling (that lets me to draw a customized window NSThemeFrame), the performance increases significantly.. Why might this happen? 2012/10/31 Nick eveningn...@gmail.com Hello I am attempting to create an application with custom looking windows (similar to new iCalendar on mountain lion, or QuickTime player). I am targeting systems from Snow Leopard to Mountain Lion. So far I've been customizing the window using the idea described at http://parmanoir.com/Custom_NSThemeFrame (basically I set the window to be Textured, and swizzle the draw Rect method of the [[window contentView] superview] (which is an instance of NSThemeFrame), then draw some nice gradient in that new drawRect implementation, and a custom gradiented toolbar. The advantage of this method is that I do not have to bother with resizing (even the resizing mark in the bottom right corner is drawn automatically) and manually drawing titlebar buttons (albeit they have a gray shadow, despite i need a black one). Another advantage is that NSToolbar works normally with it, and looks nicely with this customly drawn theme frame. This works fine on Leopard and Snow Leopard, but not on Lion/Mountain Lion. Somehow, the application becomes very slow there (Instruments says that the application spends a whole bunch of time in some timer event somewhere deep in the AppKit, even though I do not use any timers in my app). Apart from the windows, on Lion/ML the sheets and the panels get this custom drawn background with a titlebar. I am wondering if anyone created customized windows like this or reverse engineered this NSThemeFrame? Maybe there are any articles on the internet that I have missed (actually the link I gave in the beginning is the only one I have found on this topic). Somehow Apple's iCalendar works pretty fast on 10.7, while my app doesn't.. If there's no way to fix this for 10.7/10.8, I guess I will have to draw my windows from scratch using NSBorderlessWindowMask, but I think it is very difficult to completely mimic the original window's behavior: borderless windows do not support NSToolBar (i.e., I have to create my own one from scratch), on different OS the windows look/behave differently (10.6 - large titlebar buttons, resizing only using right-bottom corner, while 10.7 and 10.8 - small titlebar buttons, resizing using any edge), etc.. Thank you, Nicolas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Drawing customized window
On Oct 31, 2012, at 8:50 AM, Nick eveningn...@gmail.com wrote: I am wondering if anyone created customized windows like this or reverse engineered this NSThemeFrame? Chrome does tricks like this; there’s some really ugly code to hack the window frame drawing to support its custom tabs. It’s been a while since I was in that code so I don’t remember exactly what file to look in, though. All I can suggest is to check out the Chromium sources and start grepping for likely keywords like NSThemeFrame (or NSGrayFrame IIRC). —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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: printing Utf8
Le 31 oct. 2012 à 16:31, Ken Thomases k...@codeweavers.com a écrit : On Oct 31, 2012, at 10:17 AM, lbland wrote: On Oct 31, 2012, at 10:41 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: NSString *s = @ร่วมรส; Not supported. The compiler should be issuing a warning. You need to escape the characters using a UTF encoding. That's not true. The compiler has supported UTF-8 source encoding for quite a while now. Not only it supports UTF-8 sources, but more important, it supports unicode NS/CFString literals. Such string will not be encoded using UTF-8 (as will be a C string literal), but as an UTF-16 NSString. -- Jean-Daniel ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: App rejection due to app-sandboxing invalid entitlement
On Oct 26, 2012, at 10:35 PM, Martin Hewitson martin.hewit...@aei.mpg.de wrote: So, the story's not over. I resubmitted and the app was reviewed quickly, but rejected again with the same rejection note. So, what now? Not sure how to figure out my error, other than to pay for DTS... Out of curiosity, when you resubmitted, did you also provide a detailed description for why you were using the entitlements you requested? I suspect they're using an automated system that tells them to reject. That would prompt them to look at the description the developer provided to see if they made a case for what they're doing. Cheers, Curt - Curt Clifton, PhD Software Engineer The Omni Group www.curtclifton.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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: printing Utf8
On 31 Oct 2012, at 22:15, Ken Thomases k...@codeweavers.com wrote: On Oct 31, 2012, at 9:41 AM, Gerriet M. Denkmann wrote: I print strings like: NSString *s = @ร่วมรส; fprintf(stderr, %s\n, [ s UTF8String]); and usually it just works. But sometimes it does not and I get garbage like: ร่ว\340\270\241รส Converting these numbers to hex one gets: 0xe0 0xb8 0xa1 which is the Utf8-code for THAI CHARACTER MO MA. So why does it not print (as it should): ร่วมรส ? When I run this in Xcode for a few times, I get sometimes good output, but sometimes not. Bad output looks like: 2012-11-01 01:56:29.971 Writing[76838:303] strlen 1027 ห\340\270\253 Did run 10 times, got the bad output 3 times. Did run 20 times in Terminal - never got bad output. #import Foundation/Foundation.h int main(int argc, const char * argv[]) { #define REPEAT 7 // exactly one of these should be defined #define EINSx // no silly output here #define ZWEIx #define DREIx #define VIER @autoreleasepool { NSMutableString *mu = [ NSMutableString string ]; #ifdef EINS #define NBR 1023 // #endif #ifdef ZWEI #define NBR 511// 511 → strlen 1023 for 2 bytes #endif #ifdef DREI #define NBR 342// 342 → strlen 1027 for 3 bytes #endif #ifdef VIER #define NBR 256// 256 → strlen 1025 for 4 bytes #endif for ( NSUInteger i = 0; i NBR; i++ ) { #ifdef EINS [ mu appendString: @a ]; // 1 byte #endif #ifdef ZWEI [ mu appendString: @§ ]; // 2 bytes SECTION SIGN #endif #ifdef DREI [ mu appendString: @ห ]; // 3 bytes #endif #ifdef VIER [ mu appendString: @ ]; // 4 bytes BICYCLIST #endif }; [ mu appendString: @\n ]; const char *a = [ mu UTF8String ]; NSLog(@strlen %lu, strlen(a)); for( NSUInteger i = 0; i REPEAT; i++ ) fprintf(stderr,%2lu %s, i, a); } return 0; } ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Drawing customized window
On Oct 31, 2012, at 8:50 AM, Nick eveningn...@gmail.com wrote: Hello I am attempting to create an application with custom looking windows (similar to new iCalendar on mountain lion, or QuickTime player). I am targeting systems from Snow Leopard to Mountain Lion. So far I've been customizing the window using the idea described at http://parmanoir.com/Custom_NSThemeFrame (basically I set the window to be Textured, and swizzle the drawRect method of the [[window contentView] superview] (which is an instance of NSThemeFrame), then draw some nice gradient in that new drawRect implementation, and a custom gradiented toolbar. The advantage of this method is that I do not have to bother with resizing (even the resizing mark in the bottom right corner is drawn automatically) and manually drawing titlebar buttons (albeit they have a gray shadow, despite i need a black one). Another advantage is that NSToolbar works normally with it, and looks nicely with this customly drawn theme frame. Don't swizzle the theme frame drawRect: -- that won't always work (as you noticed) and isn't supported. This works fine on Leopard and Snow Leopard, but not on Lion/Mountain Lion. Somehow, the application becomes very slow there (Instruments says that the application spends a whole bunch of time in some timer event somewhere deep in the AppKit, even though I do not use any timers in my app). Apart from the windows, on Lion/ML the sheets and the panels get this custom drawn background with a titlebar. I am wondering if anyone created customized windows like this or reverse engineered this NSThemeFrame? Maybe there are any articles on the internet that I have missed (actually the link I gave in the beginning is the only one I have found on this topic). Somehow Apple's iCalendar works pretty fast on 10.7, while my app doesn't.. Calendar uses the public API of setBackgroundColor: on the window, and sets it to a pattern color. That is it. corbin If there's no way to fix this for 10.7/10.8, I guess I will have to draw my windows from scratch using NSBorderlessWindowMask, but I think it is very difficult to completely mimic the original window's behavior: borderless windows do not support NSToolBar (i.e., I have to create my own one from scratch), on different OS the windows look/behave differently (10.6 - large titlebar buttons, resizing only using right-bottom corner, while 10.7 and 10.8 - small titlebar buttons, resizing using any edge), etc.. Thank you, Nicolas ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/corbind%40apple.com This email sent to corb...@apple.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: printing Utf8
On Oct 31, 2012, at 2:42 PM, Gerriet M. Denkmann wrote: When I run this in Xcode for a few times, I get sometimes good output, but sometimes not. Bad output looks like: 2012-11-01 01:56:29.971 Writing[76838:303] strlen 1027 ห\340\270\253 Did run 10 times, got the bad output 3 times. Did run 20 times in Terminal - never got bad output. It seems it's a bug in Xcode. Whereas I earlier wrote in terms of the write buffer, it occurs to that that's probably not it. Rather, it's probably just the chance of how the kernel satisfies Xcode's read of its pseudo-terminal device and then how Xcode handles reads of incomplete UTF-8 sequences. That is, there's no particular guarantee that Xcode reads data in the same size chunks as your program (or stdio) is writing it. The size of the chunks that Xcode reads is somewhat arbitrary, although presumably there's an upper limit based on the buffer size that Xcode is passing to the kernel as well as the kernel's internal buffer for the pty device. Apparently, Xcode treats each buffer as though it were a standalone UTF-8-encoded string. If the read happens to split a multi-byte UTF-8 sequence, then the partial sequence is determined to be invalid UTF-8 and is output as octal escapes. Then, the next buffer looks like it starts with an invalid sequence, too. What it should do is keep the tail end of the buffer, the part which looked like an invalid sequence (up to 3 bytes), and prepend that to the next buffer it reads before trying to interpret that as UTF-8. Anyway, it is not a bug in your code nor Cocoa's UTF-8 encoding. Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: printing Utf8
I ran into something similar in my own work, but my solution may not fit your needs. printf() won't work reliably for you. My conjecture is that printf buffers its work byte-by-byte, and if an encoded character falls across a buffer boundary, the two parts are output as escaped-decimal, because each looks like a broken encoding in isolation. The way I solved it was to use -[NSString writeToFile:atomically:encoding:error:]. Obviously, that may not be an easy substitution for you, but unlike stdio, NSString knows about Unicode all the way down. Or, as you say, the buffering problem may be with Xcode. In fact, that's more likely. — F On 31 Oct 2012, at 9:41 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: I print strings like: NSString *s = @ร่วมรส; fprintf(stderr, %s\n, [ s UTF8String]); and usually it just works. But sometimes it does not and I get garbage like: ร่ว\340\270\241รส Converting these numbers to hex one gets: 0xe0 0xb8 0xa1 which is the Utf8-code for THAI CHARACTER MO MA. So why does it not print (as it should): ร่วมรส ? This is not really reproducible, but happens in about 3% of all lines. Known error, or my mistake? Or some well meant attempt to prevent any form of indecency appearing on my screen (ร่วมรส = copulate)? Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/fritza%40manoverboard.org This email sent to fri...@manoverboard.org ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Event loop expiration date insight
On 31/10/2012, at 5:56 PM, Greg Parker gpar...@apple.com wrote: If the date is in the past then the method returns immediately. If there is a matching event in the queue then it will be returned. I've changed this to pass nil and my mouse dragging works as normal. This is generally not recommended. Using nil instead of -distantFuture may use more CPU and power while the drag is in progress. OK, thanks, that is clearer now - distantFuture it is then. Any comment about how it could be possible to receive several mouseUps in series, even though I'm dequeuing the event? --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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Drawing customized window
Thanks Corbin, it works great (unfortunately I can't draw the gradient depending on the window size (so it's always white on top and black on bottom, no matter how high the window is, for example), but I guess that still gives possibilities for skinning).. I will join the Iain's question.. Is it possible to somehow alter the color of the title text? Or at least set the title to @, and draw manually NSAttributedString in that title area? 2012/11/1 iain i...@sleepfive.com Hi Corbin, sorry for semi-hijacking the thread On Wed, Oct 31, 2012 at 8:17 PM, Corbin Dunn corb...@apple.com wrote: I am wondering if anyone created customized windows like this or reverse engineered this NSThemeFrame? Maybe there are any articles on the internet that I have missed (actually the link I gave in the beginning is the only one I have found on this topic). Somehow Apple's iCalendar works pretty fast on 10.7, while my app doesn't.. Calendar uses the public API of setBackgroundColor: on the window, and sets it to a pattern color. That is it. When you use setBackgroundColor: on the window, is there a way to get the titlebar text to draw in a different colour? When you set the background to a dark colour, the titlebar text is still drawn dark with a light highlight so it looks quite bad. thanks, iain ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Programmatically providing default value for new core data attribute?
On 2012 Oct 31, at 02:44, Rick Mann rm...@latencyzero.com wrote: Will -isConfiguration:compatibleWithStoreMetadata: tell me a lightweight migration-capable change is incompatible? I think all it does is compare UUIDs or hashes, so the answer is no. I looked at doing a mapping model, but even that just has me build the value in there; no apparent way to run it through my code. Any suggestions? You put this code in a subclass of NSMigrationPolicy. It is not difficult, and a useful thing to learn. I prefer non-lightweight migration, because migrating users' data is risky. When I write the expressions and/or code myself, I can understand, probe, and test it fully. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Getting rid of primitive accessor warnings
I'm not sure what's going on here. But I've got an iOS project that declares (but does not define) some primitiveFoo methods in my NSManagedObject subclass, and an OS X project that does so as well. However, the iOS project doesn't emit any warnings, while the OS X project does. PartDefinition.mm:45:17: Incomplete implementation PartDefinition.mm:36:1: Method definition for 'primitivePins' not found Also, when I generated the NSManagedObject subclass from the model, it didn't generate the primitive accessor declarations the way older Xcodes did. Am I doing something wrong? -- Rick ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: App rejection due to app-sandboxing invalid entitlement
I did include a description on the resubmit. Seems it didn't help. I wrote: I'm using this entitlement to allow the app to send documents by mail from within the app. On 10.8 I can use the new com.apple.security.scripting-targets but this isn't available on 10.7, so there I need to use the temporary exception together with the entry com.apple.mail. I'm really stuck on this now, so I'll probably fold and contact DTS. My guess is it will be something trivial, or a non-issue related to the way MAS does the review (automated). Clearly there can't be much wrong with the entitlements because they actually work. The app is sandboxed and can't send mails without the entitlements but can with them (tested on 10.7 and 10.8). Martin On Oct 31, 2012, at 08:35 PM, Curt Clifton curt.clif...@mac.com wrote: On Oct 26, 2012, at 10:35 PM, Martin Hewitson martin.hewit...@aei.mpg.de wrote: So, the story's not over. I resubmitted and the app was reviewed quickly, but rejected again with the same rejection note. So, what now? Not sure how to figure out my error, other than to pay for DTS... Out of curiosity, when you resubmitted, did you also provide a detailed description for why you were using the entitlements you requested? I suspect they're using an automated system that tells them to reject. That would prompt them to look at the description the developer provided to see if they made a case for what they're doing. Cheers, Curt - Curt Clifton, PhD Software Engineer The Omni Group www.curtclifton.net 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: ARC question
Every assignment will release the old one,so no leak. From My iPhone 在 2012-10-29,下午7:34,Mike Abdullah cocoa...@mikeabdullah.net 写道: On 29 Oct 2012, at 10:06, Vincent Habchi vi...@macports.org wrote: Hi folks, before aught else, all my thoughts to those of you in the Eastern coast that are preparing themselves for a bunch of bleak days… I’ve just a silly question (I know, I don’t post very often and I apologize for that): I need to convert a HTML style string, with “ escapes” to normal UTF-8. So I wrote this: -(NSString *)convertHTMLtoUTF8:(NSString *)aString { NSString * convertedString = [aString copy]; for (NSString * pattern in [HTMLtoUTF keyEnumerator]) { convertedString = [convertedString stringByReplacingOccurrencesOfString:pattern withString:HTMLtoUTF [pattern]]; } return convertedString; } where HTMLtoUTF is a dictionary of pairs {@…; : @corresponding_UTF8_char}. Now, my question is: is that scheme going to work correctly with ARC? Is it not going to leak each intermediate version of ‘convertedString’? The code is a fairly inefficient to start with, but no, it's not going to leak. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/bob.cromwell2012%40gmail.com This email sent to bob.cromwell2...@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Drawing customized window
Hi Corbin, sorry for semi-hijacking the thread On Wed, Oct 31, 2012 at 8:17 PM, Corbin Dunn corb...@apple.com wrote: I am wondering if anyone created customized windows like this or reverse engineered this NSThemeFrame? Maybe there are any articles on the internet that I have missed (actually the link I gave in the beginning is the only one I have found on this topic). Somehow Apple's iCalendar works pretty fast on 10.7, while my app doesn't.. Calendar uses the public API of setBackgroundColor: on the window, and sets it to a pattern color. That is it. When you use setBackgroundColor: on the window, is there a way to get the titlebar text to draw in a different colour? When you set the background to a dark colour, the titlebar text is still drawn dark with a light highlight so it looks quite bad. thanks, iain ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com