Re: Deadlock during NSCache flush

2013-10-21 Thread Maxthon Chan
:07 PM, Maxthon Chan wrote: > >> If your app is called Hammersmith, you can retain/autorelease it in your >> [CBLDatabase dealloc] or [CBLCache dealloc] > > It’s not my app, it’s a customer’s that uses my library. But the CBL classes > are part of my library, yes. > >

Re: Deadlock during NSCache flush

2013-10-21 Thread Maxthon Chan
Sent pull request. https://github.com/couchbase/couchbase-lite-ios/pull/165 On Oct 22, 2013, at 13:14, Jens Alfke wrote: > > On Oct 21, 2013, at 8:07 PM, Maxthon Chan wrote: > >> If your app is called Hammersmith, you can retain/autorelease it in your >> [CBLDatabase

Re: I can't use man command to find c api manuals in Mavericks GM

2013-10-22 Thread Maxthon Chan
Well you need Xcode and maybe the Command Line Tools package. On Oct 22, 2013, at 16:56, li shunnian wrote: > Dear list, > > After I updated to Mavericks GM, I can not use man command to find the > manuals of the C api. > Can anyone tell me how to solve this problem? > > Regards, > Li Shunnia

Re: Arc: Switch case is in protected scope

2013-10-22 Thread Maxthon Chan
As I said, either ARC or C++ objects with constructors and destructors requires compiler to insert code into the beginning and ending of the current scope (For C++, it is calls to constructors and destructors; for Objective-C ARC, it is ARC release/autorelease function calls.). As a rule of thum

Re: I can't use man command to find c api manuals in Mavericks GM

2013-10-22 Thread Maxthon Chan
gt;>> On Oct 22, 2013, at 2:19 AM, Maxthon Chan wrote: >>> >>> Well you need Xcode and maybe the Command Line Tools package. >> >> Yes, when I installed to Mavericks GM and put on the latest Xcode, a lot of >> my man pages for C APIs went away. There

Re: Deadlock during NSCache flush

2013-10-22 Thread Maxthon Chan
Despite ARC banned retain/release/autorelease functions, there are still alternatives there in the form of C functions: From CoreFoundation : CFRetain() = retain CFRelease() = release CGBridgingRelease() = autorelease From LLVM’s requirements to runtime for ARC to work, as prototyped in GNUstep’

Re: Deadlock during NSCache flush

2013-10-23 Thread Maxthon Chan
I forgot to zero out the variable after cache is handed to the current autorelease pool (after objc_autorelease(objc_retain(_cache));) so it did not work. On Oct 23, 2013, at 16:07, Andreas Grosam wrote: > You may try the following, which is probably a hack: > > In the dealloc method of the D

Re: Deadlock during NSCache flush

2013-10-23 Thread Maxthon Chan
There are still situations that you may want a little touch-up so from time to time a manual call to these is still needed. On Oct 24, 2013, at 2:01, Greg Parker wrote: > On Oct 22, 2013, at 7:33 PM, Maxthon Chan wrote: >> Despite ARC banned retain/release/autorelease functions,

Re: Deadlock during NSCache flush

2013-10-23 Thread Maxthon Chan
). Calls to those functions are what I have to do to make the decoder work. On Oct 24, 2013, at 13:22, Chris Hanson wrote: > What Greg says on this topic is authoritative. > > -- Chris > > Sent from my iPad > >> On Oct 23, 2013, at 4:35 PM, Maxthon Chan wrote

Re: Deadlock during NSCache flush

2013-10-24 Thread Maxthon Chan
18:04, Greg Parker wrote: > On Oct 23, 2013, at 10:57 PM, Maxthon Chan wrote: >> Situation: I am writing a custom decoder that decodes objects from >> JSON-based archives. My objects gets released prematurely, hence a manual >> retain is asked for. >> >> I need t

Re: Deadlock during NSCache flush

2013-10-24 Thread Maxthon Chan
That does not work with GNUstep build system. With that system, I can only control ARC status on a per-target basis, and I cannot guarantee the non-existence of CoreFoundation on a GNUstep system. On Oct 24, 2013, at 18:23, Greg Parker wrote: > On Oct 24, 2013, at 3:10 AM, Maxthon Chan wr

Re: Deadlock during NSCache flush

2013-10-24 Thread Maxthon Chan
Quite difficult as they emulated platform defines well, and I cannot reliably detect either GNUSTEP or __LINUX__ flags. On Oct 24, 2013, at 18:30, Graham Cox wrote: > > On 24/10/2013, at 12:10 PM, Maxthon Chan wrote: > >> Neither is appropriate in my situation > > &

Re: Deadlock during NSCache flush

2013-10-24 Thread Maxthon Chan
And by the way, why not? It is well documented in LLVM documentations that those functions are required to be identical to the corresponding methods. Are you refusing your own dogfood, Apple? On Oct 24, 2013, at 18:23, Greg Parker wrote: > On Oct 24, 2013, at 3:10 AM, Maxthon Chan wr

Re: operatingSystemVersionString replacement

2013-10-24 Thread Maxthon Chan
You can use uname(3) (on sone other system it is listed as uname(2)) - that is the most classic UNIX way of telling a system from another. On Oct 25, 2013, at 11:49, Gerriet M. Denkmann wrote: > The documentation tells me that NSProcessInfo operatingSystemVersionString > "is human readable, lo

Re: operatingSystemVersionString replacement

2013-10-24 Thread Maxthon Chan
that is publicly available was 3.3) On Oct 25, 2013, at 12:21, Gerriet M. Denkmann wrote: > > On 25 Oct 2013, at 10:53, Maxthon Chan wrote: > >> You can use uname(3) (on sone other system it is listed as uname(2)) - that >> is the most classic UNIX way of telling a system fr

Re: operatingSystemVersionString replacement

2013-10-24 Thread Maxthon Chan
Well I prefer uname() as it is 1) POSIX standard, cross-platform method and 2) more fine grained as it tells minor versions apart. (e.g. I can tell Mavericks DP4 apart from Mavericks DP7 from Mavericks GM from App Store release of Mavericks from Mavericks 10.9.1) On Oct 25, 2013, at 13:29, Greg

Re: operatingSystemVersionString replacement

2013-10-25 Thread Maxthon Chan
24, 2013, at 10:36 PM, Maxthon Chan wrote: >> Well I prefer uname() as it is 1) POSIX standard, cross-platform method > > If you're already working around an OS bug then it should be acceptable to > use OS-specific means to do so. > > >> 2) more fine grained as

Re: API for volumes

2013-11-02 Thread Maxthon Chan
Your program sounds like a functional duplicate of TrueCrypt and you can look at their source code to find out how. Dist Utility seem like a wrapper of diskutil and hdiutil to me. On Nov 2, 2013, at 22:07, Luther Baker wrote: > I'd like to create a UI around mounting and dismounting Volumes, >

Re: toolbar icons and images

2013-11-11 Thread Maxthon Chan
What I stumbled upon is that you should use vector images in PDF format and the system will scale it for you. On Nov 10, 2013, at 16:57, Michael Starke wrote: > I did stumble upon the deprecation too, but now am unable to find it again. > What I do rememeber though is, that NSSegmentStyleTextu

Re: toolbar icons and images

2013-11-11 Thread Maxthon Chan
Well if that is the case, the SVG-to-NSImage (UIImage) code comes to use - just store always-being-one-pixel lines in SVG as 0-width paths. On Nov 12, 2013, at 10:22, Seth Willits wrote: > On Nov 11, 2013, at 4:44 PM, Maxthon Chan wrote: > >> What I stumbled upon is that yo

Re: Normalizing a path containing a symlink

2013-11-13 Thread Maxthon Chan
Alternatively, syscall readlink(2) and some C hack may come to help. On Nov 14, 2013, at 11:27, Rick Mann wrote: > In my iOS app, I create a directory in the user’s Documents directory, and > then later iterate the contents of that directory. The problem is that on > iOS, that directory has a

Re: Fonts on iOS

2013-11-20 Thread Maxthon Chan
You can carry a custom font in your application bundle. That will work for sure. On Nov 21, 2013, at 13:06, Gerriet M. Denkmann wrote: > The Thonburi font (default font for Thai) has some issues (since 10.9 / iOS > 7). > (E.g. writing ผฺ that is THAI CHARACTER PHO PHUNG + THAI CHARACTER PHINTHU

Re: Text messages

2013-11-22 Thread Maxthon Chan
You can launch a text message composing window on iOS with predefined contents, however the user will be able to edit the contents before sending, and general text messaging rules apply, and it may be sent as iMessage when appropriate. On OS X, you are out of luck. Sent from my iPad > On 2013年

Re: iOS screen physical size (or px density)

2013-11-26 Thread Maxthon Chan
Well you just need to detect the device and the numbers are constant: Screen information: iPhone 2G/3G/3GS, iPod touch 1G/2G/3G: 320x480px, 163dpi iPad mini 1G: 1024x768px, 163dpi iPhone 4/4S, iPod touch 4G: 640x960px, 326dpi iPhone 5/5C/5S, iPod touch 5G: 640x1136px, 326dpi iPad mini 2G: 2048x1

Re: iOS screen physical size (or px density)

2013-11-26 Thread Maxthon Chan
the mini came out, there > wasn't anything then and I don't want to do one of the version or device name > hacks. Is there yet an API point for this? " > > If there isn't a proper API point for it, then I'm not doing it. > > On 26 Nov, 2013, at

Re: iOS screen physical size (or px density)

2013-11-26 Thread Maxthon Chan
There is no reason for Apple to provide such an clearly redundant API point. Developers can somehow predict the new devices’ identifiers and the sizes are largely correctly guessed so a quick table look-up will work very well. On Nov 26, 2013, at 21:38, Igor Elland wrote: >> If there isn't a p

Re: iOS screen physical size (or px density)

2013-11-26 Thread Maxthon Chan
sed on what you think identifiers are or are going to be and to stick to > the API points there are. They also ask people file bug reports with use > cases about why one might need the physical device screen size, which I have > done. > > On 26 Nov, 2013, at 9:41 pm, Maxthon

Re: iOS screen physical size (or px density)

2013-11-26 Thread Maxthon Chan
So I think here is the equation: If you need precise device size, you have to rely on device model, for both built-in and external screens. To make that mapping possible, you need some method of reading the device model and search a database. Reading model number is easy for main device screen a

Re: iOS screen physical size (or px density)

2013-11-26 Thread Maxthon Chan
sy way around them, that normally leads to the most maintainable, > sustainable, code. > > On 26 Nov, 2013, at 10:16 pm, Maxthon Chan wrote: > >> Then why the hell in the five years of public iOS API, Apple always decided >> against a public API point for that? >>

Re: iOS screen physical size (or px density)

2013-11-26 Thread Maxthon Chan
I’d like to say just get rid of the old iPad-sized control design and embrace iPhone-sized controls with iPad-styled layout - they will look good on both iPad mini and iPhone since they have the same pixel (point) density and when regular iPads are used, despite being sub-optimal, the UX will no

Re: Localized time estimates?

2013-11-28 Thread Maxthon Chan
I’d usually go with this: MSSTR(NSLocalizedString(@“ui.approxTimeFormat”, nil), MSLocalizedTimeInterval(timeInterval)) In en_US it expands: ui.approxTimeFormat = “Approx. %@“ In zh_CN: ui.approxTimeFormat = “大约 %@后“ Note: MSSTR(...) is a macro expands to [NSString stringWithFormat:__VA_ARGS_

Re: Fast hash of NSData?

2013-12-02 Thread Maxthon Chan
If you are concerned with security, use SHA-512 (member of SHA-2 family, faster than SHA-1 on 64-bit systems) or Keccak (SHA-3, more secure) will be the best way as they are both proved secure (while SHA-1 is proved INSECURE) and if you want efficiency the XOR thing should suite well as it can b

Re: Fast hash of NSData?

2013-12-02 Thread Maxthon Chan
If you are indexing files, maybe a shorter hash (CRC32?), a sparse database file and mmap(2) can be your friend. You can bucket files by its CRC32 (very fast) values (hence the sparse database file that needed to be mmap(2)’d and when CRC32 collides (somewhat likely) then SHA-512 (Slower, but l

Re: iPad keyboards

2013-12-11 Thread Maxthon Chan
They simulated iOS 7 looks using iOS 6 SDK. It is not that difficult by using appearance proxy. On Dec 12, 2013, at 13:26, Rick Mann wrote: > Why does the Google Hangouts app on iPad, on iOS 7, have a nice-looking iOS-6 > style keyboard? Other UI in the app looks like iOS 7 UI. > > Hangouts:

Re: iPad keyboards

2013-12-11 Thread Maxthon Chan
:44, Rick Mann wrote: > I'm running iOS 7. You're saying they styled their own keyboard to look like > the iOS 6 keyboard? It's a pretty good imitation. > > On Dec 11, 2013, at 21:29 , Maxthon Chan wrote: > >> They simulated iOS 7 looks using iOS 6 SDK. I

Re: iPad keyboards

2013-12-11 Thread Maxthon Chan
> In general, not everything works perfectly in iOS6 compatibility mode - so be > sure and do some testing ... but for instance, it allows my existing app > released May 2013 to continue to function and run on iOS7 devices without > requiring an updated binary from me. > > &g

Re: iPad keyboards

2013-12-11 Thread Maxthon Chan
eral, not everything works perfectly in iOS6 compatibility mode - so >> be sure and do some testing ... but for instance, it allows my existing app >> released May 2013 to continue to function and run on iOS7 devices without >> requiring an updated binary from me. >> >&

Re: iPad keyboards

2013-12-11 Thread Maxthon Chan
different implementations to support different server interfaces, either Apache FastCGI or ohttpd bundle interface. On Dec 12, 2013, at 15:20, Greg Parker wrote: > On Dec 11, 2013, at 10:46 PM, Maxthon Chan wrote: >> Bad example - you should use the example between NeXTSTEP/Mach and OS X, >

Re: iPad keyboards

2013-12-12 Thread Maxthon Chan
Seem to me that Xcode 4.6.3 and iOS 6 SDK is still working, from my friends. On Dec 12, 2013, at 15:25, Maxthon Chan wrote: > Well on OS X Mavericks I have > /System/Library/Frameworks/Foundation.framework/Version/C/Foundation - and I > can assume tat versions A are from NeXTSTEP

Re: iPad keyboards

2013-12-16 Thread Maxthon Chan
If you run a stock iOS 6 app on iOS 7 you get most of the UI in iOS 6 style. As what I said, UIAlertView is not in your app but SpringBoard.app so that will still get the iOS 7 look, for SpringBoard.app is linked against iOS 7 SDK. If you are styling iOS 6 app in the fashion of iOS 7 app you can

Re: iPad keyboards

2013-12-16 Thread Maxthon Chan
/copy/paste bubble is probably in backboardd. On Dec 13, 2013, at 13:14, Rick Mann wrote: > > On Dec 12, 2013, at 21:11 , Maxthon Chan wrote: > >> If you run a stock iOS 6 app on iOS 7 you get most of the UI in iOS 6 style. >> As what I said, UIAlertView is not in your app b

Re: NSArray firstObject?

2013-12-22 Thread Maxthon Chan
Yes. This method is there since 10.6 so you can safely call it. using latest header or category on it. On Dec 23, 2013, at 1:49, Seth Willits wrote: > On Dec 22, 2013, at 9:31 AM, Trygve Inda wrote: > >> Available in OS X v10.6 and later. >> >> This seems to be an error in the docs as the me

Re: 6.1.6 for iPhones?

2014-02-22 Thread Maxthon Chan
No. Either they are like iPhone 3G or iPad 1 which has been thrown off the iOS 6 train on the first place, or they are like iPhone 4 and iPad 2 get carried over to iOS 7. On Feb 23, 2014, at 10:58, Rick Mann wrote: > There's an update to iOS 6.1 for iPod Touch 4th gen and iPhone 3GS, but none

Re: deprecated BIGNUM replaced by what?

2014-02-26 Thread Maxthon Chan
That NSDecimalNumber is essentially the 128-bit quadruple-percision float number, in an non-IEEE-754 fashion. You can still use OpenSSL, either ignore the deprecation or compile and carry your own copy. Apple deprecated it because OpenSSL API isn’t stable enough. Alternatively, you can use othe

Re: VC# vs. ObjC and partial abstract classes

2014-03-19 Thread Maxthon Chan
You can emulate this behaviour somehow by not implementing the methods that is abstract, and prevent instantiation by introspecting and throwing exceptions in -init;. Definitely non-trivial but works. On Mar 19, 2014, at 23:43, William Squires wrote: > > On Mar 18, 2014, at 9:29 PM, Luther Ba

Re: Accessing self in a C static function within an implementation definition

2014-04-07 Thread Maxthon Chan
No, you can’t. There is no way to accomplish that. If that is event-based callbacks, try use delegation and/or target-action. On Apr 7, 2014, at 18:00, jonat...@mugginsoft.com wrote: > I have a function like macro: > > #define DBDispatchMonoEvent(KLASS, NAME) \ > do { \ >[DBManagedEvent dis

Re: NSOperation subclass with abstract class?

2014-04-07 Thread Maxthon Chan
If in doubt, use protocols. @protocol MyProtocol @property NSString *data1; // … @end Then reference the objects as id objects (or NSOperation) On Apr 7, 2014, at 22:17, Trygve Inda wrote: > Hi have three different NSOperation subclasses: > > MyOperationA : NSOperation > MyOperationB : NS

Re: To find if a file is fragmented

2014-04-08 Thread Maxthon Chan
Concerning if a file is fragmented is sort of useless, I think. Modern filesystem APIs does not even expose details of that, and the only way I now how to find out about that, is to roll your own HFS+ driver (or whatever filesystem you are concerning) and access raw bock devices (e.g. /dev/disk0

Re: Excessive open gui graphics files on Mavericks

2014-04-08 Thread Maxthon Chan
You can avoidd this by consolidating all your resource files into one big archive file that is expanded in-memory into NSData files. I still vaguely remember a library that parses tar file into a dictionary of NSData objects. You can use that library to consolidate all your resources into one si

Re: Excessive open gui graphics files on Mavericks

2014-04-09 Thread Maxthon Chan
I’d recommend cramfs as it is a real filesystem that is optimised to be expanded in-memory. On Apr 9, 2014, at 14:42, Charles Srstka wrote: > On Apr 9, 2014, at 12:32 AM, John Joyce > wrote: > >> Sure. Core Data would work just as well as binary blobs. >> Base64 would work in plists / xml /

Re: Excessive open gui graphics files on Mavericks

2014-04-09 Thread Maxthon Chan
AM, Maxthon Chan wrote: > >> I’d recommend cramfs as it is a real filesystem that is optimised to be >> expanded in-memory. > > Not complicated enough. I'd recommend encrypting the whole thing with an > AES-256 key which is encrypted using elliptical-curve cryptogra

Re: Excessive open gui graphics files on Mavericks

2014-04-09 Thread Maxthon Chan
cramps features decompression in-memory in place and to avoid copying data you can put uncompressed TIFF in it. cramfs decompresses into NSData objects in-place and can be taken up directly by NSImage/UIImage/CGImage/CIImage object. cramfs variant that is based on zlib makes that image a equival

Re: Excessive open gui graphics files on Mavericks

2014-04-11 Thread Maxthon Chan
ably hard to get an answer to this, so I may be talking through my > hat: > > Does this involve linking libcramfs.a into the binary you distribute? Have > you published the source of your app? > > — F > > > On 10 Apr 2014, at 2:16 AM, Michael Watson wrote: >

Re: Navigation Design question

2014-04-13 Thread Maxthon Chan
You can add a category on UIViewController, do some detection and swizzle -[UIViewController viewWillAppear:] method. On Apr 14, 2014, at 5:55, Luther Baker wrote: > Hello all, > > I've run into an issue a few times and I'd like to see if someone has a > good design suggestion to address my pr

Re: copy and mutableCopy

2014-04-27 Thread Maxthon Chan
Immutables copied are just retained and returned, and mutableCopied are COW. Mutables copied generates COW. That would be the fastest way implementing that. * COW = copy on write On Apr 27, 2014, at 17:06, John McCall wrote: > On Apr 27, 2014, at 2:00 AM, Dave wrote: >> A long time back, I r

Re: Share and store RSA - public key in java server and vice versa

2014-05-13 Thread Maxthon Chan
I am not exactly familiar with using RSA but as long as the format is followed I believe whatever mechanism here is okay. Also if I didn’t made it wrong DER certificates are text files. Try to dump the NSData and try your Android device if it can directly recognise it. On May 13, 2014, at 22:20

Re: Share and store RSA - public key in java server and vice versa

2014-05-13 Thread Maxthon Chan
, 2014, at 8:55 AM, Maxthon Chan wrote: > >> I am not exactly familiar with using RSA but as long as the format is >> followed I believe whatever mechanism here is okay. > > This is actually kind of problematic. There are a number of formats for > encoding public keys,

Re: Share and store RSA - public key in java server and vice versa

2014-05-13 Thread Maxthon Chan
: > > On May 13, 2014, at 9:33 AM, Maxthon Chan wrote: > >> Whatever that is there is, for 100% sure, some form of standardised format >> that iOS, Android and your Java server will be able to deal with with higher >> level API. > > *hollow laugh* > > T

Re: Share and store RSA - public key in java server and vice versa

2014-05-13 Thread Maxthon Chan
Or if you don;t mind GNU, you have GNUTLS package that is just as good. GPG can be dissected and used if you understand how licensing works there. On May 14, 2014, at 0:56, Jens Alfke wrote: > > On May 13, 2014, at 9:33 AM, Maxthon Chan wrote: > >> Whatever that is there is

Re: Running a C compiler from within an app sandbox

2014-06-16 Thread Maxthon Chan
You are not allowed to run unsigned code from within the app sandbox. There are some way to circumvent this, but it will require you to call the compiler as a library. Look into lib clang any you will find out how to link clang into your app, and compile within your own program code. On Jun 17,

Re: Running a C compiler from within an app sandbox

2014-06-16 Thread Maxthon Chan
It is not the problem that they are not signed, but the problem that the fork(2) syscall is prevented from working in sandbox. Using the compiler as a library eliminated all the fork(2) calls. On Jun 17, 2014, at 9:33, SevenBits wrote: > On Jun 16, 2014, at 9:25 PM, Maxthon Chan wr

Re: NSCoding vs NSSecureCoding

2014-06-17 Thread Maxthon Chan
Personal suggestion, convert colors to strings (you can use any format, but I prefer #RRGGBB., drop the . for opaque color, which is compact and easily understood by humans) and images to PNG data (lossless), then archive. On Jun 17, 2014, at 17:30, Greg Weston wrote: > Sean McBride wo

Re: Color closest to color

2014-06-17 Thread Maxthon Chan
One easy-to-implement method: colour cube. Define a colour using its RGB values as a 3-tuple (r, g, b) and standard colours (ri, gi, bi) (where i = 0..n).The square distance between the given colour and a standard colour is (ri-r)^2+(gi-g)^2+(bi-b)^2. You can calculate square distances between

Re: Color closest to color

2014-06-17 Thread Maxthon Chan
Square rooting is slow, and not calculating square root do not throw off comparison. On Jun 17, 2014, at 21:14, Mills, Steve wrote: > On Jun 17, 2014, at 06:43:54, Maxthon Chan wrote: > >> One easy-to-implement method: colour cube. >> >> Define a colour using its RG

Re: Color closest to color

2014-06-17 Thread Maxthon Chan
I know, it is just sqared Euclidean distance is simplest to calculate. Sure you can, for example, add coefficients to the formula, to adjust. On Jun 17, 2014, at 21:22, Torsten Curdt wrote: > RGB is not perceptually uniform, hence the Euclidean distance is not quite > right. > Wikipedia and St

Re: Color closest to color

2014-06-17 Thread Maxthon Chan
Alternatively I have an idea based on HSB colours: difference in hue in radians raised to 4th power (or 6th) plus squared Euclidean distance of saturation and brightness. On Jun 17, 2014, at 21:22, Torsten Curdt wrote: > RGB is not perceptually uniform, hence the Euclidean distance is not qui

Re: Color closest to color

2014-06-17 Thread Maxthon Chan
nks everyone. I had thought there might be a pre-existing API that would > do this (I was half expecting to find a method defined for the NSColorList > class...), but I will implement the euclidean distance test myself... > Cheers > Jonny. > > On 17 Jun 2014, at 12:43, Maxthon Chan wro

<    1   2