Re: CFRunLoopRef to NSRunLoop: how?

2014-11-21 Thread ChanMaxthon
Given that Apple's Foundation does not support getting NSRunLoop from CFRunLoopRef, Cocotron designed CFRunLoop using toll-free bridging from NSRunLoop and GNUstep have a NSRunLoopFromCFRunLoop() (and GNUstep have some some NSRunLoop extensions allowing implementing this mess without fussing

Re: Singleton or class methods?

2014-09-13 Thread ChanMaxthon
Why not use straight C functions? Sent from my iPad On Sep 13, 2014, at 20:45, Trygve Inda cocoa...@xericdesign.com wrote: I have a project that involves several different targets. Included in all this is a set of related utility methods that need to be used by different sections of the

Re: diff tool on iOS?

2014-08-13 Thread ChanMaxthon
I think you can embed code from BSD diff in your program. That is plain C and you just need to call it using your Objective-C code. Alternatively you can look into the implementation of BSD diff or GNU diffutils and rewrite it using Objective-C or Swift for your project. Sent from my iPad On

Re: Smarter NSTimer?

2014-07-01 Thread ChanMaxthon
You can emulate this by adding up time differences between rendering frames. When the framerate-driven accumulator reaches a certain value fire your action, and accumulate only when conditions are met. Sent from my iPad On Jul 2, 2014, at 02:21, William Squires wsqui...@satx.rr.com wrote:

Re: How does a UIButton perform a segue?

2014-06-25 Thread ChanMaxthon
Something like this: id cell = button; for(; cell ![cell isKindOfClass:[UITableViewCell class]]; cell = [cell superview]); When this loop exits you get either the cell or nil indicating that the button is not inside a cell. Sent from my iPhone On Jun 26, 2014, at 7:18, Quincey Morris

Re: How does a UIButton perform a segue?

2014-06-25 Thread ChanMaxthon
Yes. However you may want to use code that looked better. My code is a little bit obfuscated. Sent from my iPhone On Jun 26, 2014, at 7:46, Rick Mann rm...@latencyzero.com wrote: Yeah, maybe that's not an unreasonable way to do it. Thanks. On Jun 25, 2014, at 16:40 , ChanMaxthon xcvi

Re: Text System Locks Up - Can't Find Reason

2014-06-11 Thread ChanMaxthon
I believe this involves Cocoa Bindings. I used to load lots of text into iOS app using Storyboards and it worked smoothly. Sent from my iPhone On Jun 12, 2014, at 6:53, Seth Willits sli...@araelium.com wrote: I have two sample projects: one works fine, one does not. Both read a large

Re: Text System Locks Up - Can't Find Reason

2014-06-11 Thread ChanMaxthon
Bindings or not, somebody is listening to the text view when created in xib. That makes some significant dispatching overhead. Sent from my iPhone On Jun 12, 2014, at 8:08, Seth Willits sli...@araelium.com wrote: On Jun 11, 2014, at 5:02 PM, ChanMaxthon xcvi...@me.com wrote: I believe

Re: Text System Locks Up - Can't Find Reason

2014-06-11 Thread ChanMaxthon
Is editing involved? If not I would render it into HTML and let WebKit render it. Sent from my iPhone On Jun 12, 2014, at 8:41, Seth Willits sli...@araelium.com wrote: On Jun 11, 2014, at 5:11 PM, ChanMaxthon xcvi...@me.com wrote: Bindings or not, somebody is listening to the text view

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

2014-05-16 Thread ChanMaxthon
so I didn't have to mess around with it. On 15 May, 2014, at 7:46 pm, ChanMaxthon xcvi...@me.com wrote: Eh screw the OS X/iOS crypto libraries... I would just embed my own copy of OpenSSL or GNUTLS myself. (My toolkit library have already included GNU MP, the library GNUTLS is based

Re: debugging unrecognized selector

2014-05-16 Thread ChanMaxthon
Strings does not have CGColor methods so it is not caught. Try break on [NSObject doesNotRecognizeSelector:] Sent from my iPhone On May 16, 2014, at 4:01 PM, Torsten Curdt tcu...@vafer.org wrote: I am seeing a crash in an iOS app and while I can reproduce it I am still struggling to find

Re: where to put persistent storage for command-line app

2014-05-16 Thread ChanMaxthon
If you wish to follow UNIX standards, store generated files in a sub directory in /var/lib (global files) or dot-files in user home directory. NeXTSTEP use /Library/Application Support for globals and ~/Library/Application Support for user-specific. Sent from my iPhone On May 16, 2014, at

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

2014-05-16 Thread ChanMaxthon
Keychain is okay, I just cannot bear the crypto libraries. Sent from my iPhone On May 17, 2014, at 1:08 AM, Jens Alfke j...@mooseyard.com wrote: On May 16, 2014, at 12:37 AM, ChanMaxthon xcvi...@me.com wrote: I got fed up by Apple already and found a little BSD-licensed CXX crypto

Re: debugging unrecognized selector

2014-05-16 Thread ChanMaxthon
I believe the intention of the slider is that it won't drop you to stack frames that does not have your code (and show you with assembler) but it can be troublesome. When LLDB break your program at signal your program could have already progressed past where the exception happened and already

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

2014-05-15 Thread ChanMaxthon
Eh screw the OS X/iOS crypto libraries... I would just embed my own copy of OpenSSL or GNUTLS myself. (My toolkit library have already included GNU MP, the library GNUTLS is based on) Or if I really have the time reimplement RSA algorithms and key generation using Acceleration.framework Sent

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

2014-05-15 Thread ChanMaxthon
* Correction: GNUTLS depends on GNU MP which is already included. Sent from my iPad On May 15, 2014, at 7:46 PM, ChanMaxthon xcvi...@me.com wrote: Eh screw the OS X/iOS crypto libraries... I would just embed my own copy of OpenSSL or GNUTLS myself. (My toolkit library have already included

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

2014-05-13 Thread ChanMaxthon
There are many good container formats for asymmetric keys and public keys can be handled in plain. Good formats to use: Certificate Signing Request, self-signed certificate, PGP, some form of archive formats can also be used like tar(1) or ar(1). You can also integrate this key exchange into

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

2014-05-13 Thread ChanMaxthon
Rounding stuff up, there are two broadly-implemented systems: PKCS and PGP. If you are using PKCS system, you need to operate a CA that your app trusts. Your server issue issue new keys as certificates signed by your CA. Clients provide keys using CSR which is confirmed when signed by the

Re: Problem posting to this list?

2014-05-11 Thread ChanMaxthon
I have caught two too-much-bounce alerts and it started to smell like deliberate attackers. Sent from my iPhone On May 12, 2014, at 8:41 AM, Quincey Morris quinceymor...@rivergatesoftware.com wrote: On May 11, 2014, at 17:30 , William Squires wsqui...@satx.rr.com wrote: I'm getting a

Re: Problem with distributed objects in GUI cocoa apps

2014-04-30 Thread ChanMaxthon
If you are targeting at remote procedure calling across Internet I have a library CGIJSONObjects that wraps REST-style JSON-based HTTP remote calls into objects. Server side language is not important. I used it to interface a server using Java servlets. Sent from my iPhone On May 1, 2014, at

Re: copy and mutableCopy

2014-04-27 Thread ChanMaxthon
I am not sure if Apple libraries COW but I know GNUstep uses COW on their NSData, NSDictionary and NSArray (and that and a different NSObject layout in their implementation of some classes are the reason why their libraries are faster than Apple's) Simplest way is to copy NSData sand watch for

Re: copy and mutableCopy

2014-04-27 Thread ChanMaxthon
What object are you talking about? NSData have -bytes method and others would require you drop to CF code (or probably impossible) Check for methods with return internal pointer attribute or fast iteration protocols. If you need fine tuned control over that you may need to drop to C or use

Re: copy and mutableCopy

2014-04-27 Thread ChanMaxthon
You know you can mmap(2) COW pages if kernel or hardware supports it right? GNUstep used COW implemented by sharing pointers (no kernel or hardware support needed) which is obvious, Apple can implement COW by using COW pages (kernel or hardware supported) COW pages cannot be told apart from

Re: ARC Retain Cycles

2014-04-26 Thread ChanMaxthon
I think that tight loop may be one thing, the appropriate scoping of variables is another. When writing loops I tend to use lots of local variables that is alloc/init'd and that will give clang an extreme good idea about what is going on when the loop folds and variables all go out of scope. I

Re: GCD killed my performance

2014-04-26 Thread ChanMaxthon
Since you are interfacing with database maybe you can use a little transaction interface which is its own thread and run loop. That may be able to cut down your amount of syscalls. That is, not using GCD but old fashioned NSThread, NSRunLoop (and CFRunLoop) and NSCondition. OS X implemented

Re: GCD killed my performance

2014-04-26 Thread ChanMaxthon
You can write your own dispatch queue by using a CFRunLoopSource and add an NSCondition to it when you need it to be synchronous (implementing dispatch_sync) Sent from my iPad On Apr 27, 2014, at 4:55 AM, Quincey Morris quinceymor...@rivergatesoftware.com wrote: On Apr 26, 2014, at 12:02

Re: GCD killed my performance

2014-04-26 Thread ChanMaxthon
on HTTP. Sent from my iPad On Apr 27, 2014, at 5:36 AM, Jens Alfke j...@mooseyard.com wrote: On Apr 26, 2014, at 2:10 PM, ChanMaxthon xcvi...@me.com wrote: Since you are interfacing with database maybe you can use a little transaction interface which is its own thread and run loop

Re: GCD killed my performance

2014-04-26 Thread ChanMaxthon
, Jens Alfke j...@mooseyard.com wrote: On Apr 26, 2014, at 2:10 PM, ChanMaxthon xcvi...@me.com wrote: Since you are interfacing with database maybe you can use a little transaction interface which is its own thread and run loop. That may be able to cut down your amount of syscalls

Re: Fast NSArray compare

2014-04-15 Thread ChanMaxthon
To keep your NSSet you can store it as an array. There are conversion methods like -[NSSet array] and +[NSSet setWithContentsOfArray:]. Also, you can try to determine if your code is running on SSD. SSD can be iterated in parallel and GCD will help a little when parallelizing the search. Sent

Re: Fast NSArray compare

2014-04-15 Thread ChanMaxthon
Another wild thought, how about drop one layer lower to POSIX and use a little bit of OpenCL? For every directory with content paths C[0..i] and the list of restricted paths R[0..j] construct a matrix (using OpenCL) M[0..i, 0..j] where M[i, j]=strcmp(C[i], R[j]) (strcmp() itself can be OpenCL

Re: Excessive open gui graphics files on Mavericks

2014-04-08 Thread ChanMaxthon
The SQLite DB thing is just like a tar archive, and if you dare to you can even include a cramfs driver in your code and consolidate all your resources into one optionally encrypted cramfs image. Every file archiving method that allows in-memory expansion works, and my personal recommendation

Re: Best solution for game loop on OSX?

2013-12-16 Thread ChanMaxthon
My personal preference is GCD dispatching from your graphics rendering loop. Sent from my iPhone On 2013年12月14日, at 5:57, Alex Hall mehg...@gmail.com wrote: Hello list, I am attempting to use OpenAL to move a sound source around. To do so smoothly, though, will require a loop, so I can

Re: Getting true 32-bit integers with NSNumber?

2013-12-02 Thread ChanMaxthon
You can check what type int32_t (or uint32_t) is typedef'd to and use that corresponding type on your intended platform. Sort of like: - (int32_t) int32Value { if (!strcmp(@encode(int32_t), @encode(int)) return [self intValue]; else if (!strcmp(@encode(int32_t), @encode(long))

Re: Getting true 32-bit integers with NSNumber?

2013-12-02 Thread ChanMaxthon
I am just making an example and a point - check what (u)int32_t or (u)int64_t is typedef'd to and return that type. Sent from my iPhone On 2013年12月2日, at 18:27, Kyle Sluder k...@ksluder.com wrote: On Dec 2, 2013, at 1:54 AM, ChanMaxthon xcvi...@me.com wrote: You can check what type int32_t

Re: Getting true 32-bit integers with NSNumber?

2013-12-02 Thread ChanMaxthon
. Sent from my iPhone On 2013年12月2日, at 18:27, Kyle Sluder k...@ksluder.com wrote: On Dec 2, 2013, at 1:54 AM, ChanMaxthon xcvi...@me.com wrote: You can check what type int32_t (or uint32_t) is typedef'd to and use that corresponding type on your intended platform. Sort of like: - (int32_t

Re: Fast hash of NSData?

2013-12-02 Thread ChanMaxthon
What is wrong with a good ol' SHA-512? Sent from my iPhone On 2013年12月2日, at 21:50, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: Assuming that a typical image has 243.3 k Bytes, or 1 993 221 bits. And that a hash has 64 bits. Then there are 2^1 993 221 different images, and 2^64 hash

Re: Fast hash of NSData?

2013-12-02 Thread ChanMaxthon
, ChanMaxthon xcvi...@me.com wrote: What is wrong with a good ol' SHA-512? Way too slow. ―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

Re: Fast hash of NSData?

2013-12-02 Thread ChanMaxthon
:25 pm, ChanMaxthon xcvi...@me.com wrote: What is wrong with a good ol' SHA-512? Way too slow. —Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact

Re: Arc: Switch case is in protected scope

2013-10-22 Thread ChanMaxthon
Just put a set of braces after every case: and it should be okay. A set of braces here actually sets up a mini stack frame that makes ARC work. Sent from my iPhone On 2013年10月22日, at 15:41, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: Converting to Arc (Xcode 5.0). This works fine

Re: Helping Arc with: PerformSelector may cause a leak because its selector is unknown

2013-10-22 Thread ChanMaxthon
I suggest against NSInvocation. I will just throw in a direct call to objc_msgSend. Sent from my iPhone On 2013年10月22日, at 15:33, Igor Elland igor.ell...@me.com wrote: This certainly helps: at least I get a clean compile. But telling the compiler about the type of selector to expect would be

Re: Arc: Switch case is in protected scope

2013-10-22 Thread ChanMaxthon
This problem comes from C variable scopes regarding braces. For most cases it is just fine but for switch() all cases are in the same scope, jumping around. ARC inserts code at beginning and end of scopes (mini stack frames here) so if a new ARC variable is defined in switch() it gets confused.

Re: Helping Arc with: PerformSelector may cause a leak because its selector is unknown

2013-10-22 Thread ChanMaxthon
Giving a mini performance boost. NSInvocation is utterly slow (multiple memory allocations asking for syscalls, and a chain of function calls including at least two objc_msgSends to invoke a method.) but good for IMP caching performSelector methods are slightly slower than direct calls since

Re: Arc: Switch case is in protected scope

2013-10-22 Thread ChanMaxthon
...@mdenkmann.de wrote: On 22 Oct 2013, at 14:48, ChanMaxthon xcvi...@me.com wrote: Just put a set of braces after every case: and it should be okay. A set of braces here actually sets up a mini stack frame that makes ARC work. 非常感谢 Works perfectly now. (I still would like to know

Re: Arc: Switch case is in protected scope

2013-10-22 Thread ChanMaxthon
ARC have more insertion points - beginning of scope retaining all passed-in arguments or used objects, call point creating objects, and end of scope (auto)releasing objects. A missed retain causes race issues, a missed (auto)release leaks objects and an extra release makes dangling pointers,

Re: Arc: Switch case is in protected scope

2013-10-22 Thread ChanMaxthon
, ChanMaxthon xcvi...@me.com wrote: ARC have more insertion points - beginning of scope retaining all passed-in arguments or used objects, call point creating objects, and end of scope (auto)releasing objects. OK, and it's the ones at call points that cause problems in switch cases, correct

Re: Deadlock during NSCache flush

2013-10-21 Thread ChanMaxthon
Can you just manually retain it before cleaning, and manually release it afterwards? You can use CFRetain()/CFRelease() for that, or use runtime functions objc_retain() and objc_release(). The latter two is not documented by Apple per sé, but it is documented by LLVM as requirements of ARC.

Re: 3rd party executable in iOS project

2013-10-21 Thread ChanMaxthon
Despite NSTask is missing in runtime, your day can still be saved by: 1) You can use the NSTask implementation from GNUstep, an LGPL-licensed library. 2) You can still use classic UNIX function calls to pipe/fork/dup2/exec Sent from my iPhone On 2013年10月22日, at 9:37, Daniel DeCovnick

Re: C functions

2013-10-18 Thread ChanMaxthon
Try add this line: extern void foo(void); Sent from my iPhone On 2013年10月19日, at 1:21, Charles Srstka cocoa...@charlessoft.com wrote: On Oct 18, 2013, at 6:15 AM, Dmitry Markman dmark...@me.com wrote: I don't thinks strip remove info used by dynamic linker Thus dlsym should work As

Re: C functions

2013-10-18 Thread ChanMaxthon
I think I know why it did not work: strip command can remove debug symbols, or unused functions as well. Sent from my iPhone On 2013年10月19日, at 7:53, Charles Srstka cocoa...@charlessoft.com wrote: On Oct 18, 2013, at 6:42 PM, ChanMaxthon xcvi...@me.com wrote: Try add this line: extern

Re: C functions

2013-10-17 Thread ChanMaxthon
need to be loaded by another process, usually are. Charles On Oct 17, 2013, at 10:51 PM, ChanMaxthon xcvi...@me.com wrote: Then, problem, how did Core Foundation bundle loading work? Sent from my iPhone On 2013年10月18日, at 11:49, Charles Srstka cocoa...@charlessoft.com wrote: On Oct

Re: collection of applications

2013-10-11 Thread ChanMaxthon
Seem to me that you are considering making an enterprise single sign-on portal. Of course you can combine everything into a single app, but a more graceful solution can exist. Just to correct a misunderstanding, iOS dyld can load dynamic libraries if carried as part of the application bundle