Re: Core data fetch and multithreading

2010-11-22 Thread Quincey Morris
On Nov 21, 2010, at 23:14, vincent habchi wrote:

 I intended to lock, fetch the entity, read the corresponding attribute, and 
 unlock. That's all I've to do. On the main thread, I lock when I mutate the 
 set, then unlock. That's all in one place, so it's not so difficult to figure 
 out.

*That's* not difficult to figure out, but that doesn't make it correct or 
complete. What if Core Data implementation within the lock-protected code does 
a performSelector:...afterDelay:... to make something happen later?

 The problem is that I need some kind of real time behavior. Having two MOC 
 implies saving each time there is a mutation. And since the mutating code is 
 tied to NSColorPanel in continuous mode, there can be many mutations as long 
 as the user moves the color cursor until he has found the correct hue. The 
 cycle goes like this:
 
 User picks color - modify the set (on the main thread) - redraw CALayer in 
 a GCD queue - read the set (in the GCD queue) - displays.
 
 On the other hand, I could create a private pool of color outside Core Data 
 and somehow insert it only when the user acknowledges its choice. That would 
 mean copy the Core Data set, and then later replace it by the modified 
 version. But since this set can hold several thousand elements, this looks an 
 unnecessary waste of memory to me. Or I could have a separate memory-only 
 persistent store with its own MOCs. But, once again, it seems unreasonably 
 complex for the goal.

On Nov 21, 2010, at 22:26, vincent habchi wrote:

 At that point, there are, I think, two possibilities:
 
 1. Use a single MOC and its provided mutex for accessing shared ressources 
 (but this is strongly discouraged);
 
 2. Create a private pool of memory in which you duplicate new objects until 
 they are saved.

[I'm quoting you from the other thread.]

I think maybe you have more design options here. For example, you can [in 
principle, I think] multithread with a single MOC without locks if you pass 
ownership of the MOC around between threads that make changes, so that 
ownership serializes access. That requires the ownership passing to be thread 
safe, and you already have [I think] the perfect mechanism for that: GCD. You'd 
probably also want to break down your background operations so that enumeration 
of the relationship doesn't take place within a single GCD block execution, but 
where each block execution is one iteration of the enumeration. (Isn't that 
more GCD-like anyway?)

If you follow an approach like that, you can create a second MOC for read-only 
access, for purposes such as concurrent updating of the UI, without any need to 
merge contexts -- you can just throw away the read-only context when it's out 
of date. Actually, you can have as many read-only contexts as you need. The 
primary MOC accumulates all the changes no matter how produced, and that's the 
one that's saved when the document is saved.

Of course, the specific nature of your application might make such an approach 
infeasible, but I'm just throwing out an example of what I referred to earlier 
as additional design work. The problem with straight-ahead locking is that it 
often tends to be micro-synchronization (same as atomicity), which can fail at 
the macro level. Far better to analyze the problem and devise a solution via a 
global strategy.

Finally, when struggling with Core Data like this, it's worthwhile to 
repeatedly ask yourself if Core Data is the correct technology to use. Just 
because a solution to your application's problem can be describe in functional 
Core Data terms, that doesn't necessarily mean that Core Data is the best (or 
even a good) actual solution.

FWIW, which may not be much.


___

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

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

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

This email sent to arch...@mail-archive.com


How to avoid multiple clicks on a push button

2010-11-22 Thread Abhijeet Singh
Hi,I am working on a user interface. There is only one window in my application 
with Back and Next buttons on it. On Next / Back button click my application 
performs some task and the current view is swapped with another view in the 
window. It works fine until somebody clicks Next (or Back) button twice in 
succession like a double click. The event is fired 2 times and it messes up the 
whole functionality of my application. I tried controlling this behavior by 
disabling the buttons as soon as they are clicked but it doesn't help. Still 
the event is fired multiple times. Is there any way i can control this behavior 
of the push buttons. Please helpRegardsAbhijeetDear cocoadev ! Get Yourself 
a cool, short @in.com Email ID now!
___

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

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

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

This email sent to arch...@mail-archive.com


Asking an outline/table view to send it's setObjectValue:... message

2010-11-22 Thread Thomas Davie
Hi,

I'm writing a custom cell at the moment that's used in an outline view, it's 
object value changes sometimes when the outline view doesn't expect it to 
(which seems to be only on mouse down or end editing).  Is there some way I can 
force the outline view to send it's - (void)outlineView:(NSOutlineView 
*)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn 
*)tableColumn byItem:(id)item message?

Thanks

Tom Davie___

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

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

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

This email sent to arch...@mail-archive.com


Re: How to avoid multiple clicks on a push button

2010-11-22 Thread Mike Abdullah
Tell us more. In what way does this mess up the whole functionality of the 
application?

On 22 Nov 2010, at 09:54, Abhijeet Singh wrote:

 Hi,I am working on a user interface. There is only one window in my 
 application with Back and Next buttons on it. On Next / Back button click my 
 application performs some task and the current view is swapped with another 
 view in the window. It works fine until somebody clicks Next (or Back) button 
 twice in succession like a double click. The event is fired 2 times and it 
 messes up the whole functionality of my application. I tried controlling this 
 behavior by disabling the buttons as soon as they are clicked but it doesn't 
 help. Still the event is fired multiple times. Is there any way i can control 
 this behavior of the push buttons. Please helpRegardsAbhijeet
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Subclasses, protocols and properties - compiler warning

2010-11-22 Thread Jonny Taylor
 I am encountering what I believe to be a spurious compiler warning. I wonder 
 whether this is a clue that I am doing something differently to how I 
 should do it. The problem comes if I define a protocol containing a 
 property and then define that property in a base class that does NOT conform 
 to the (whole) protocol. When I subclass that base class, I get warnings 
 about how the property is not defined.
 
  // I find myself writing @dynamic genericProperty here to shut up the 
 compiler warning
  // that reads warning: property 'genericProperty' requires method 
 '-genericProperty' to be defined - use @synthesize, @dynamic or provide a 
 method implementation
 
 It is my understanding that this is one of the reasons why @dynamic exists. 
 i.e. I believe that you are already doing the Right Thing.
 
 From the docs
 
 You use the @dynamic keyword to tell the compiler that you will fulfill the 
 API contract implied by a property either by providing method implementations 
 directly or at runtime using other mechanisms such as dynamic loading of code 
 or dynamic method resolution.   It suppresses the warnings that the compiler 
 would otherwise generate if it can’t find suitable implementations. You 
 should only use it if you know that the methods will be available at runtime.
 
 Well you know the method will exist at run time since you know your class is 
 a subclass of a class that implements it.

OK fair enough, thanks for replying. It's good to have a second opinion confirm 
it! I just found it a bit odd because the compiler should very easily be able 
to tell that the method does exist.
Jonny___

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

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

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

This email sent to arch...@mail-archive.com


Re: Core data fetch and multithreading

2010-11-22 Thread vincent habchi
Quincey:

I am a bit in a hurry, so I will answer quickly:

 I think maybe you have more design options here. For example, you can [in 
 principle, I think] multithread with a single MOC without locks if you pass 
 ownership of the MOC around between threads that make changes, so that 
 ownership serializes access. That requires the ownership passing to be thread 
 safe, and you already have [I think] the 

What do you mean exactly? Could you elaborate just a little bit?

 Finally, when struggling with Core Data like this, it's worthwhile to 
 repeatedly ask yourself if Core Data is the correct technology to use. Just 
 because a solution to your application's problem can be describe in 
 functional Core Data terms, that doesn't necessarily mean that Core Data is 
 the best (or even a good) actual solution.

Well, since I may deal with sets of more than 100,000 entities, Core Data is 
appealing because of its embedded SQLite code. Fetching through CD is certainly 
way faster than the blind solution which would involve enumerate each candidate 
at each operation…

 FWIW, which may not be much.

I *very much* appreciate your help and the time you take to answer.

Cheers!
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSTextView auto_refcount_underflow_error during spell check

2010-11-22 Thread jonat...@mugginsoft.com
I have an NSTextView instance on OS X 10.6.3 that persistently logs the 
following error
auto_refcount_underflow_error

Breaking on this reveals that the underflow occurs on thread 4 in 
NSTextCheckingOperation.
I haven't seen this behaviour before with NSTextView so I am pretty certain 
that a misconfiguration is the cause.

The NSTextView instance is subclassed and is not instantiated from a nib (the 
codebase began life as Smultron).
Spelling implementation is that of a standard NSTextView and auto spell 
checking is not activated.

on thread 4

#0  0x96bfe133 in auto_refcount_underflow_error
#1  0x96c0a1ba in Auto::Zone::dec_refcount_small_medium
#2  0x96c0b79d in Auto::Zone::block_decrement_refcount
#3  0x96bf57f7 in auto_zone_release
#4  0x9811ce4f in _CFRelease
#5  0x98139c08 in CFMakeCollectable
#6  0x9768cca0 in -[NSDateCheckingResult 
initWithRange:date:timeZone:duration:referenceDate:underlyingResult:]
#7  0x95f63e64 in checkDataDetectors
#8  0x95f60168 in NSSpellCheckerCheckString
#9  0x95f87fdc in -[NSTextCheckingOperation main]
#10 0x975002d8 in -[__NSOperationInternal start]
#11 0x974fff65 in startOperations_block_invoke_2
#12 0x956871e4 in _dispatch_call_block_and_release
#13 0x956794b2 in _dispatch_worker_thread2
#14 0x95678f41 in _pthread_wqthread
#15 0x95678d86 in start_wqthread

Regards

Jonathan Mitchell

Developer
Mugginsoft LLP
http://www.mugginsoft.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 arch...@mail-archive.com


Re: Asking an outline/table view to send it's setObjectValue:... message

2010-11-22 Thread Keary Suska
On Nov 22, 2010, at 4:09 AM, Thomas Davie wrote:

 I'm writing a custom cell at the moment that's used in an outline view, it's 
 object value changes sometimes when the outline view doesn't expect it to 
 (which seems to be only on mouse down or end editing).  Is there some way I 
 can force the outline view to send it's - (void)outlineView:(NSOutlineView 
 *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn 
 *)tableColumn byItem:(id)item message?

Have you tried reloadItem: or setNeedsDisplayInRect: ?

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business

___

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

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

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

This email sent to arch...@mail-archive.com


Re: unit test exit's abnormally with code 5

2010-11-22 Thread Shane
Still trying to get my unit tests to build. I have an app project
which includes unit tests as well, and it depends on another dylib
project. They're all built with GCC_ENABLE_OBJC_GC as unsupported.
AFAIK, that's off. So everything ought to be turned of with respect to
GC. And according to the output below … seems my OBJC_DISABLE_GC is
set. I have a Run Script in the Run Script build phase that looks like
this …

---
OBJC_DISABLE_GC=YES
export OBJC_DISABLE_GC
# Run the unit tests in this test bundle.
${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests
---

But when I build my unit test, I am not seeing the environment
variable listed in the output of the Run custom shell script 'Run
Script' output. So it doesn't seem to be seen during a build.

Anyone have thoughts?

Here's the output when trying to build unit tests if this helps ...
---
PhaseScriptExecution Run Script
/Users/napolitano/Projects/test/shared_builds/test.build/Release/UnitTests.build/Script-9D233EDB128F30B900CE8F0D.sh
cd /Users/napolitano/Projects/test/demo
setenv ACTION build
setenv ALTERNATE_GROUP staff
setenv ALTERNATE_MODE u+w,go-w,a+rX
setenv ALTERNATE_OWNER napolitano
setenv ALWAYS_SEARCH_USER_PATHS YES
setenv APPLE_INTERNAL_DEVELOPER_DIR /AppleInternal/Developer
setenv APPLE_INTERNAL_DIR /AppleInternal
setenv APPLE_INTERNAL_DOCUMENTATION_DIR /AppleInternal/Documentation
setenv APPLE_INTERNAL_LIBRARY_DIR /AppleInternal/Library
setenv APPLE_INTERNAL_TOOLS /AppleInternal/Developer/Tools
setenv APPLY_RULES_IN_COPY_FILES NO
setenv ARCHS x86_64 i386 ppc

… (truncated this output, just env vars w/ no mention of
OBJC_DISABLE_GC env var)

/Developer/Tools/RunPlatformUnitTests.include:419: note: Running tests
for architecture 'x86_64' (GC OFF)
objc[11391]: GC: forcing GC OFF because OBJC_DISABLE_GC is set
2010-11-20 21:05:57.978 otest-x86_64[11391:903] The test bundle at
/Users/napolitano/Projects/test/demo/build/Release/UnitTests.octest
could not be loaded because its Objective-C runtime information does
not match the runtime information required by the test rig.  This is
likely because the test rig is being run with Objective-C garbage
collection disabled, but the test bundle requires Objective-C garbage
collection.  To enable Objective-C garbage collection for the test
rig, run it in an environment without the OBJC_DISABLE_GC environment
variable.
2010-11-20 21:05:57.987 otest-x86_64[11392:203] *** NSTask: Task
create for path
'/Users/napolitano/Projects/test/demo/build/Release/UnitTests.octest/Contents/MacOS/UnitTests'
failed: 22, Invalid argument.  Terminating temporary process.
/Developer/Tools/RunPlatformUnitTests.include:451: error: Test rig
'/Developer/Tools/otest' exited abnormally with code 5 (it may have
crashed).
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Core data fetch and multithreading

2010-11-22 Thread Hunter Hillegas
I think someone somewhere told me that if you create a MOC on the main thread, 
there's some special runloop integration that is included, hence one of the 
reasons it's important to not create one on the main thread and then pass it 
around.

This is also important to keep in mind re: NSOperation, since it's init is 
called on the main thread.

http://www.duckrowing.com/2010/03/11/using-core-data-on-multiple-threads/

On Nov 22, 2010, at 12:16 AM, Quincey Morris wrote:

 I think maybe you have more design options here. For example, you can [in 
 principle, I think] multithread with a single MOC without locks if you pass 
 ownership of the MOC around between threads that make changes, so that 
 ownership serializes access. That requires the ownership passing to be thread 
 safe, and you already have [I think] the perfect mechanism for that: GCD. 
 You'd probably also want to break down your background operations so that 
 enumeration of the relationship doesn't take place within a single GCD block 
 execution, but where each block execution is one iteration of the 
 enumeration. (Isn't that more GCD-like anyway?)

___

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

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

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

This email sent to arch...@mail-archive.com


[NSDate] Bug in dateByAddingTimeInterval: on Mac OS X 10.5

2010-11-22 Thread Stephane Sudre
According to the NSDate.h header:

- (id)dateByAddingTimeInterval:(NSTimeInterval)ti
AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;

Problem is when I run the following code on Mac OS X 10.5 on a
PowerMac G5, I get the result listed below.

#import Foundation/Foundation.h

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

NSLog(@dateByAddingTimeInterval: %@,[[NSDate date]
dateByAddingTimeInterval:24*60*60]);

NSLog(@addTimeInterval: %@,[[NSDate date] addTimeInterval:24*60*60]);
[pool drain];
return 0;
}


$ ./TestAPIDate
2010-11-22 16:59:15.900 TestAPIDate[4192:10b]
dateByAddingTimeInterval: 2020-10-13 09:58:31 +0200
2010-11-22 16:59:15.901 TestAPIDate[4192:10b] addTimeInterval:
2010-11-23 16:59:15 +0100

So it looks like this API is broken on Mac OS X 10.5 and should not be
said to be available for Mac OS X 10.5 in the 10.5 SDK Headers.

Am I missing something obvious? (I will file a bug report later if I'm
not missing anything).
___

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

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

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

This email sent to arch...@mail-archive.com


Re: [NSDate] Bug in dateByAddingTimeInterval: on Mac OS X 10.5

2010-11-22 Thread Jeff Johnson
Hi Stephane.

I believe that the header is mistaken. According to the documentation, 
dateByAddingTimeInterval: is Available in Mac OS X v10.6 and later.

http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/Reference/Reference.html#//apple_ref/occ/instm/NSDate/dateByAddingTimeInterval:

However, I should note that the method does not seem to exist in either the 
10.5 SDK for Xcode 3.2.4 or the 10.5 System headers. It only exists in the 10.6 
SDK and the 10.6 System headers, where it has the incorrect availability macro.

-Jeff


On Nov 22, 2010, at 10:05 AM, Stephane Sudre wrote:

 According to the NSDate.h header:
 
 - (id)dateByAddingTimeInterval:(NSTimeInterval)ti
 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
 
 Problem is when I run the following code on Mac OS X 10.5 on a
 PowerMac G5, I get the result listed below.
 
 #import Foundation/Foundation.h
 
 int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
 
NSLog(@dateByAddingTimeInterval: %@,[[NSDate date]
 dateByAddingTimeInterval:24*60*60]);
   
NSLog(@addTimeInterval: %@,[[NSDate date] addTimeInterval:24*60*60]);
[pool drain];
return 0;
 }
 
 
 $ ./TestAPIDate
 2010-11-22 16:59:15.900 TestAPIDate[4192:10b]
 dateByAddingTimeInterval: 2020-10-13 09:58:31 +0200
 2010-11-22 16:59:15.901 TestAPIDate[4192:10b] addTimeInterval:
 2010-11-23 16:59:15 +0100
 
 So it looks like this API is broken on Mac OS X 10.5 and should not be
 said to be available for Mac OS X 10.5 in the 10.5 SDK Headers.
 
 Am I missing something obvious? (I will file a bug report later if I'm
 not missing anything).

___

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

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

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

This email sent to arch...@mail-archive.com


Infinite Loop invoking super ?? -[NSDocument canCloseDocumentWithSelector:::]

2010-11-22 Thread Jerry Krinock
I received a strange crash report from a user.  User says it is not 
reproducible.  The way I read this, an infinite loop occurred in my 
NSPersistentDocument subclass of 
-canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo: when my code 
invoked super.  Here is the crash report.

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   libSystem.B.dylib   0x923020d2 tiny_malloc_from_free_list + 
5
1   libSystem.B.dylib   0x92301301 szone_malloc_should_clear + 
263
2   libSystem.B.dylib   0x923011a8 malloc_zone_malloc + 81
3   com.apple.CoreFoundation0x90750f27 _CFArrayReplaceValues + 2647
4   com.apple.Foundation0x92ebe4d7 -[NSCFArray 
insertObject:atIndex:] + 192
5   com.apple.Foundation0x92ebe40f -[NSCFArray addObject:] + 68
6   com.apple.CoreFoundation0x907b680c __NSArrayEnumerate + 1452
7   com.apple.CoreFoundation0x907b6011 -[NSArray 
enumerateObjectsUsingBlock:] + 49
8   com.apple.AppKit0x908f6aea -[NSObjectParameterBinder 
_updateObject:observedController:observedKeyPath:context:] + 189
9   com.apple.AppKit0x908f6a25 -[NSObjectParameterBinder 
_observeValueForKeyPath:ofObject:context:] + 82
10  com.apple.Foundation0x92ee3714 NSKeyValueNotifyObserver + 
372
11  com.apple.Foundation0x92ee31b3 NSKeyValueDidChange + 377
12  com.apple.Foundation0x92ec79ea 
-[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 127
13  com.mycompany.MyPrivateFramework0x000f04f6 0x6000 + 959734
14  com.mycompany.MyPrivateFramework0x000fa9d0 0x6000 + 1001936
15  com.mycompany.MyPrivateFramework0x000faa14 0x6000 + 1002004
16  com.apple.AppKit0x90c68f2f -[NSDocumentController 
_closeDocumentsStartingWith:shouldClose:closeAllContext:] + 65
17  com.mycompany.MyPrivateFramework0x000fa97e 0x6000 + 1001854
18  com.mycompany.MyPrivateFramework0x000fa97e 0x6000 + 1001854
19  com.mycompany.MyPrivateFramework0x000fa97e 0x6000 + 1001854
…
snip out identical lines
…
509 com.mycompany.MyPrivateFramework0x000fa97e 0x6000 + 1001854
510 com.mycompany.MyPrivateFramework0x000fa97e 0x6000 + 1001854
511 com.mycompany.MyPrivateFramework0x000fa97e 0x6000 + 1001854

I believe that lines 0-12 simply show the innocent methods which happened to be 
executing when the stack limit was blown, and that the actual problem is the 
infinite loop in lines 13-511.

GDB says that the address 0x000fa97e 0x6000 is the line invoking super, at the 
end of my implementation shown below, as noted in the comment.  And I believe 
it, because according to the user's story, the crash did occur when he closed a 
document, and also, in typical infinite loop behavior, it took more than a few 
seconds for the crash dialog to appear.

How can there be an infinite loop invoking super in a method?  Looks like it 
was re-invoking itself instead of invoking super.

Jerry

- (void)canCloseDocumentWithDelegate:(id)delegate
 shouldCloseSelector:(SEL)shouldCloseSelector
 contextInfo:(void *)contextInfo {
   if ([[[self macster] autosaveUponClose] boolValue]) {
// User has checked ON the 'autosave upon close' option
// From the user's account, and my examination of his data, I believe
// that this branch did *not* execute prior to the crash.  I'm
// just including it for completeness

// This code was taken from the second-last post in this thread:
// 
http://www.cocoabuilder.com/archive/cocoa/153196-customizing-save-behavior-in-docbased-apps.html?q=%22Don't+Save%22+save+automatically#153196

// Only do this if the document has been previously saved
if ([self fileURL]) {
NSError* error ;
BOOL ok =[[self managedObjectContext] save:error] ;
if (!ok) {
[self alertError:error] ;
}

// Clear change count to prevent the super call from invoking save 
dialog
[self updateChangeCount:NSChangeCleared] ;
}
}

BOOL closeNow = YES ;

if (NSApp  !m_skipAskExportDuringNextClose) {
// From the user's account, and my examination of his data, I believe
// that this branch did *not* execute prior to the crash.  I'm
// just including it for completeness
 
   NSMutableArray* unexportedActiveExporters = [[NSMutableArray alloc] 
init] ;
for (Exporter* exporter in [[self macster] activeExportersOrdered]) {
if ([exporter isActive]) {
if ([[exporter ixportCount] integerValue] == 0) {
[unexportedActiveExporters addObject:exporter] ;
break ;
}
}
}
if ([unexportedActiveExporters count]  0) {
NSString* and = [NSString localize:@andEndList] ;

Re: Loading NSManagedObjects across NSManagedObjectContexts in an unsaved NSPersistentDocument

2010-11-22 Thread Dave Zwerdling
Hello again;
Well, I ran some debugging and I determined that ALL I needed was an initial 
save.  After that, all the core data stores are up-to-date, and faults result 
in actual fetched data.

So, although kind of kludgy, I accepted the Initial Save behavior à la 
Garageband, where the user is required to save the document at the document's 
creation.  I resolved this by adding the following code to my 
NSPersistentDocument subclass.

The code which results in the following behavior:
1) The main document window is displayed
2) The document ensures there is actually a persistent store backing the PSC.  
If there is, then no further action.
3) If there is no persistent store, prompt the user to save the document.  This 
should only occur if the document has never been saved. If the document was 
successfully saved, no further action.
4) If the document was not successfully saved, close the document.

Like I said, this seems to be below-par.  But I'm willing to accept it unless 
someone has a simpler/better implementation.
Dave

-(void) showWindows
{   
[super showWindows];

[self ensureSaved];
}

-(void) ensureSaved
{
if(self managedObjectContext] persistentStoreCoordinator] 
persistentStores] count] == 0)
{
[self saveDocumentWithDelegate:self 
didSaveSelector:@selector(document:didSave:contextInfo:) contextInfo:nil];
}
}

- (void)document:(NSDocument *)doc didSave:(BOOL)didSave contextInfo:(void  
*)contextInfo
{
if(doc == self)
{
if(! didSave)
{
[self close];
}
}
}___

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

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

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

This email sent to arch...@mail-archive.com


Re: Infinite Loop invoking super ?? -[NSDocument canCloseDocumentWithSelector:::]

2010-11-22 Thread Ken Thomases
On Nov 22, 2010, at 11:32 AM, Jerry Krinock wrote:

 How can there be an infinite loop invoking super in a method?  Looks like it 
 was re-invoking itself instead of invoking super.

Busted method or isa swizzling, maybe?  Or a memory smasher that messed up the 
dispatch table?

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Infinite Loop invoking super ?? -[NSDocument canCloseDocumentWithSelector:::]

2010-11-22 Thread Kyle Sluder
On Mon, Nov 22, 2010 at 10:31 AM, Ken Thomases k...@codeweavers.com wrote:
 On Nov 22, 2010, at 11:32 AM, Jerry Krinock wrote:

 How can there be an infinite loop invoking super in a method?  Looks like it 
 was re-invoking itself instead of invoking super.

 Busted method or isa swizzling, maybe?  Or a memory smasher that messed up 
 the dispatch table?

Or a superclass implementation that recurses based on an internal
status flag, and that flag got corrupted?

--Kyle Sluder
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Running JavaScript in iOS WebView.

2010-11-22 Thread Geoffrey Holden
Okay, I've verified that the page has loaded correctly (by running [webView 
stringByEvaluatingJavaScriptFromString:@document.body.innerHTML] to output 
the HTML of the loaded webview and then comparing it with the page loaded by 
the Mac version to ensure that they're the same.)

I've come to the conclusion that the problem is that the Javascript is taking 
longer than 10 seconds to complete.  This is a bit of a problem since the 
Javascript is sending user credentials to the server and the server takes a 
little over 10 seconds to service that request and send back (a rather large) 
packet of data - which then needs to be processed.  On the Mac, this takes a 
little under 10 seconds - on the iPhone it wouldn't surprise me if it took 
rather longer.

So my question is this - how can I override this 10 second limit, if only to 
test my theory (i.e. even if that isn't permitted in a shipping app, can I do 
it for debug purposes)?  Does anyone have any ideas for circumventing this 
problem (rewriting the HTML of the page is not, sadly, an option).  Or is it a 
case that there are some things that simply can't be done on iOS?

On 18 Nov 2010, at 15:53, Conrad Shultz wrote:

 What do you mean by load the page in a separate thread? My understanding is 
 that UIKit in general, and UIWebView in particular, is very thread unsafe. 
 
 Have you tested this all on a single thread? I know that you say it's 
 working, but threading issues can lead to bizarre breakage. 
 
 -Conrad
 
 On Nov 18, 2010, at 0:19, Geoffrey Holden 45rpmli...@googlemail.com wrote:
 
 No - this isn't in a secondary thread.  It does load the page in a separate 
 thread (in order to ensure that the UI doesn't lock up), but the code isn't 
 executed until the page has finished loading.  With regard to the load 
 thread, the code is identical to the code I used on the Mac - and I've been 
 able to confirm that this part of the code is executing correctly, and that 
 the page really has loaded correctly.
 
 Nice thought though.
 
 
 On 17 Nov 2010, at 22:07, Conrad Shultz wrote:
 
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 On 11/17/10 1:33 PM, Geoffrey Holden wrote:
 void SendDelegateMessage(NSInvocation*): delegate (webViewDidLayout:)
 failed to return after waiting 10 seconds. main run loop mode:
 GSEventReceiveRunLoopMode
 
 I have got webViewDidFinishLoad (that's where this code is called) -
 so it isn't that it's trying to run on nothing.
 
 If you have any ideas about what I could do to fix this, I'd be most
 interested to hear them!
 
 Hmm.  I haven't seen this myself, but are you by any chance trying to do
 this on a secondary thread?
 
 - -- 
 Conrad Shultz
 
 Synthetiq Solutions
 www.synthetiqsolutions.com
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.7 (Darwin)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
 
 iD8DBQFM5FIuaOlrz5+0JdURApjsAJ4uPKnHEFVUJkiJJb7gtLx9dVMnDQCfSi9O
 gMRqrPoelphoQuTmbPt4esc=
 =mRgF
 -END PGP 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 arch...@mail-archive.com


Re: Core data fetch and multithreading

2010-11-22 Thread Quincey Morris
On Nov 22, 2010, at 07:58, Hunter Hillegas wrote:

 I think someone somewhere told me that if you create a MOC on the main 
 thread, there's some special runloop integration that is included, hence one 
 of the reasons it's important to not create one on the main thread and then 
 pass it around.


Perhaps that's true, but it sounds like an urban myth. If it's true, the MOC 
locking approach can't work *at all* either -- because for the duration of the 
lock the MOC is in fact being used on a background thread. But the MOC locking 
approach *can* work, ergo ... etc ... QED.

On Nov 22, 2010, at 04:34, vincent habchi wrote:

 I think maybe you have more design options here. For example, you can [in 
 principle, I think] multithread with a single MOC without locks if you pass 
 ownership of the MOC around between threads that make changes, so that 
 ownership serializes access. That requires the ownership passing to be 
 thread safe, and you already have [I think] the 
 
 What do you mean exactly? Could you elaborate just a little bit?

It seems feasible to design your app so that when something non-UI-related 
needs to happen, you can dispatch the work as a GCD-based operation. For 
operations that need to modify the data, it's easy to just pass the main MOC as 
a parameter into the GCD block, isn't it? All you need to do is ensure that 
only one such MOC-using block can execute at once. That's easy too, using 
NSOperation to limit the queue to one executing operation at a time, or using a 
separate one-at-a-time queue for just the operations that modify data, or using 
operation dependencies -- isn't it? Secondarily, you'd want each operation to 
be short, if your main thread might need to wait for updates to complete, for 
UI reasons, so you probably don't want any big enumeration loops in a single 
block. Maybe you also need a way of prioritizing operations, so that an 
operation that the main thread is waiting on can execute ahead of true 
background operations in the queue.

Other than that there's no locking or thread synchronizing for you to code, 
because you're seamlessly using the locking/synchronizing that's built into the 
GCD and NSOperation mechanisms. In effect, Apple's done the heavy lifting for 
you.

This sort of thing would be especially attractive if you also have big 
background operations that *don't* modify the data (which I think you said you 
do). Those operations can run fully concurrently, because they can use their 
own MOC.


___

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

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

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

This email sent to arch...@mail-archive.com


Re: how to add a custom view (a pair of controls) to an NSToolbar in Interface Builder

2010-11-22 Thread Rua Haszard Morris
Any suggestions on how to do this?

I simply want to use a bunch of controls, grouped via a custom view, in a 
toolbar, such that the controls form a single toolbar item (for add/remove), 
but the individual controls respond to mouse, draw, etc as normal.

Is this not possible?

thanks
Rua HM.

On 18/11/2010, at 12:44 PM, Rua Haszard Morris wrote:

 I would like to add an item to my window's toolbar that is a custom view 
 containing other standard views. For example a popup button and a static text 
 field. If possible I would like to do this in interface builder, without 
 implementing NSToolbarDelegate.
 
 So to clarify..
 
 I have a window with a toolbar in an interface builder file.
 I want to put a popup button and static text on the toolbar as a single item 
 - I want them to be removeable/addable as a pair, and I want full control 
 over their layout within the toolbar item.
 I want to run the interface in IB using the Cocoa Simulator and see the popup 
 button and text draw.
 
 1 - Is this possible in Interface Builder? If so, can someone briefly outline 
 the steps?
 
 2 - If this is not possible in IB, how would this best  be implemented? If 
 this is the case, can this work alongside configuring the toolbar in IB, or 
 will the allowed items configured in IB be ignored at runtime? (This is why 
 I'd prefer to do this fully in IB).
 
 What I have tried:
 - new window NIB file
 - add a toolbar
 - add a custom view to the nib
 - add controls to the custom view - a button, textfield, etc, tweak layout to 
 taste
 - drag the custom view to the toolbar customise sheet (i.e. the allowed items 
 area)
 - it looks like the view content will appear - the buttons are drawn in the 
 allowed items area
 - drag the custom item to the toolbar (so it is in the default set) - oh no, 
 the buttons disappear
 - simulate the interface - oh no, still no buttons!
 
 I didn't find any confirmation that this is not possible in these previous 
 threads..
 http://www.mail-archive.com/cocoa-dev@lists.apple.com/msg35450.html
 http://www.cocoabuilder.com/archive/cocoa/282463-custom-view-in-toolbar.html
 
 thanks for the help
 Rua HM.
 
 --
 http://cartoonbeats.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/r.haszard%40adinstruments.com
 
 This email sent to r.hasz...@adinstruments.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 arch...@mail-archive.com


iPad: Distribution of documents

2010-11-22 Thread Phillip Mills
I'm working on an application that lets a user create 'documents' that will 
live in the app's Documents directory.  I'd like to distribute some sample 
documents that would be treated the same as anything the user creates, but 
haven't seen anything that suggests I can have XCode populate Documents as part 
of the installation package.  I also haven't seen anything that says I can't.  
:-)

It seems easy enough to stick them into the main bundle as resources and then 
copy them on a first execution.  OTOH, if there's a direct way of configuring 
this, I'd rather go with it.

(I think my main problem is that I don't actually know what the Cocoa/XCode 
documentation would call this kind of packaging detail even if it 
existed.)___

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

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

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

This email sent to arch...@mail-archive.com


Re: iPad: Distribution of documents

2010-11-22 Thread Hunter Hillegas
As far as I know, this is the way to go. For instance, it's a common thing with 
pre-populated Core Data databases that you are going to want to write to.

On Nov 22, 2010, at 3:16 PM, Phillip Mills wrote:

 It seems easy enough to stick them into the main bundle as resources and then 
 copy them on a first execution. 

___

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

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

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

This email sent to arch...@mail-archive.com


Re: how to add a custom view (a pair of controls) to an NSToolbar in Interface Builder

2010-11-22 Thread Graham Cox

On 23/11/2010, at 10:02 AM, Rua Haszard Morris wrote:

 Is this not possible?


Yes, it's possible. But your question is too open-ended. What have you tried, 
what doesn't perform as expected?

--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 arch...@mail-archive.com


NSView exitFullScreenModeWithOptions results in dimmed menus in document based app

2010-11-22 Thread Jon Gilkison
When I call exitFullScreenModeWithOptions in a document based app, the menu
items are permanently dimmed out.  I've tried making everything I can think
of firstResponder, but still dimmed out.

I tried a couple of alternate full screen methods, to see if I could get
around it, but I'm using a layer backed view and they didn't work or
flickered too bad.

Any pointers on where to look?

Thanks,

Jon.
___

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

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

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

This email sent to arch...@mail-archive.com


Re: how to add a custom view (a pair of controls) to an NSToolbar in Interface Builder

2010-11-22 Thread Rua Haszard Morris
What I have tried:
- new window NIB file
- add a toolbar
- add a custom view to the nib
- add controls to the custom view - a button, textfield, etc, tweak layout to 
taste
- drag the custom view to the toolbar customise sheet (i.e. the allowed items 
area)
- it looks like the view content will appear - the buttons are drawn in the 
allowed items area
- drag the custom item to the toolbar (so it is in the default set) - oh no, 
the buttons disappear
- simulate the interface - oh no, still no buttons!

Perhaps my first email was not concise enough...

thanks for the help
Rua HM.

On 23/11/2010, at 1:55 PM, Graham Cox wrote:

 
 On 23/11/2010, at 10:02 AM, Rua Haszard Morris wrote:
 
 Is this not possible?
 
 
 Yes, it's possible. But your question is too open-ended. What have you tried, 
 what doesn't perform as expected?
 
 --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 arch...@mail-archive.com


Help diagnosing networking/internet performance issues

2010-11-22 Thread Graham Cox
In working on some networking code, I've come across one test machine on our 
local net that has extremely slow performance. Like orders of magnitude slower 
than normal, on the same local network and using the same method (airport, 
through a single router) as other machines that work just fine. This problem 
seems to affect not just the code I'm working on but general stuff like web 
browsing, file copying*, etc. A restart doesn't help, a full shutdown and 
reboot seems to help if the machine is left off for a while (overnight works, 
but 2 minutes has no effect) but the speed soon drops to a crawl after five 
minutes or so. Switching to wired ethernet makes no difference. It's very 
bizarre.

Are there any diagnostic tools I can bring to bear to help figure out exactly 
where the problem is? It's probably a config file or something gone awry, but 
all the usual suspects (network settings, and so on) look fine.

* a test copy from another machine to the suspect machine of a 56MB file 
estimates it will take 2 hours. THAT 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 at cocoa-dev-admins(at)lists.apple.com

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

This email sent to arch...@mail-archive.com


Re: Help diagnosing networking/internet performance issues

2010-11-22 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 11/22/10 5:31 PM, Graham Cox wrote:
 In working on some networking code, I've come across one test machine
 on our local net that has extremely slow performance. Like orders of
 magnitude slower than normal, on the same local network and using the
 same method (airport, through a single router) as other machines that
 work just fine. This problem seems to affect not just the code I'm
 working on but general stuff like web browsing, file copying*, etc. A
 restart doesn't help, a full shutdown and reboot seems to help if the
 machine is left off for a while (overnight works, but 2 minutes has
 no effect) but the speed soon drops to a crawl after five minutes or
 so. Switching to wired ethernet makes no difference. It's very
 bizarre.
 
 Are there any diagnostic tools I can bring to bear to help figure out
 exactly where the problem is? It's probably a config file or
 something gone awry, but all the usual suspects (network settings,
 and so on) look fine.

Not exactly a Cocoa question, but since we've had a few questions
recently about how to intercept network stuff during Cocoa development,
the following comment I think might be of broader interest.

I would suggest you first analyze the traffic since you don't really
have any guesses as to what might be breaking.

Anything from DHCP confusion to bandwidth-consuming malware will be
revealed by a decent analyzer.

You can try using the built-in tcpdump, but Wireshark has a convenient
(if not entirely obvious) GUI.

(You probably did this already, but just in case it was overlooked, did
you disable wireless when testing wired?  I must say the overnight vs.
two minute shutdown is suggestive of a hardware issue, perhaps requiring
some capacitors to discharge.)

My interest is piqued... please contact me off-list if you want to
discuss further.


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFM6yJLaOlrz5+0JdURAj+wAJ0UlOxEtY6cDuEWhui8KhXqP8QvgwCggrg3
sPwNj4CNVZz9nhPR78eaC30=
=JULj
-END PGP 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 arch...@mail-archive.com


Obtaining all points on a line segment

2010-11-22 Thread Cody Garvin
Hi all,

I searched back through 2005 in the Cocoa Mailing List and didn't see any 
requests for this.

We need all the points on a line / arc / path on the screen. We need to do hit 
detection on stroked line, so we must know if the point is valid or not. 

I thought using CGPathContainsPoint would work, but it must be done on a closed 
path or it returns true on all points in the test area. 

I also tried NSBezierPath containsPath: and , but it returned the exact same 
things as the CGPath functions. 

Another idea I have, though not sure if it will work, is converting the drawing 
to NSBitmapImageRep and using colorAtX:y to test for a specific color to test 
for a point.

The downside of this approach is you must test all the points in a bounding 
box, and could get quite large if our line segment is complicated.

I'm surprised I haven't found a convenience method to return all the points in 
an outline.

Any help would be greatly appreciated.

- Cody___

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

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

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

This email sent to arch...@mail-archive.com


Odd problem with event taps when job is killed

2010-11-22 Thread George Nachman
Hi cocoa-dev,

I recently added an event tap to my program. Since doing that, there is a
strange behavior: when I kill my job (usually by making a change in Xcode
and pressing cmd-Enter, being prompted to kill the job, and selecting OK),
it will repeat back the last 10-20 keypresses as or after it dies. For
example, if I do this:

1. Start my program
2. Switch back to Xcode and type foo in some source file.
3. Cmd-enter in Xcode
4. A dialog asks if I want to kill the job, say yes.
5. A ghost types foo in whatever window the cursor happens to be in.

This is on 10.6.4 and Xcode 3.2.3. I register the event tap like this:

   machPortRef = CGEventTapCreate(kCGHIDEventTap,

   kCGHeadInsertEventTap,

   kCGEventTapOptionListenOnly,

   CGEventMaskBit(kCGEventKeyDown),

   (CGEventTapCallBack)OnTappedEvent,

   self);

if (machPortRef) {

CFRunLoopSourceRef eventSrc;


eventSrc = CFMachPortCreateRunLoopSource(NULL, machPortRef, 0);

if (eventSrc == NULL) {

DebugLog(@CFMachPortCreateRunLoopSource failed.);

} else {

// Get the CFRunLoop primitive for the Carbon Main Event
Loop, and add the new event souce

CFRunLoopAddSource(CFRunLoopGetCurrent(), eventSrc,
kCFRunLoopDefaultMode);

CFRelease(eventSrc);

}

}


Even if my handler does nothing, it still exhibits this behavior:

   static CGEventRef OnTappedEvent(CGEventTapProxy proxy, CGEventType type,
CGEventRef event, void *refcon)

{

return event;

}


I couldn't find reports of anyone else having this problem, which usually
means I did something wrong :). Any ideas on what could cause this?

Thanks,
George
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Help diagnosing networking/internet performance issues

2010-11-22 Thread Dave Keck
Perhaps the bandwidth has been limited using ipfw or a similar utility?
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Obtaining all points on a line segment

2010-11-22 Thread Dave DeLong
It seems to me that a simpler way to do this would be:

- get the endpoints of the line
- figure out the slope of the line
- If the slope is = 1, pull out the x coordinate of the test point.  If the 
slope is  1, use the y coordinate of the test point
- using the algebra that you learned when you were a teenager, figure out what 
the y (or x) coordinate should be for the value you pulled out in the previous 
step
- see if the point on the line is a reasonable distance away from the 
corresponding value in the test point.

Dave

On Nov 22, 2010, at 8:12 AM, Cody Garvin wrote:

 Hi all,
 
 I searched back through 2005 in the Cocoa Mailing List and didn't see any 
 requests for this.
 
 We need all the points on a line / arc / path on the screen. We need to do 
 hit detection on stroked line, so we must know if the point is valid or not. 
 
 I thought using CGPathContainsPoint would work, but it must be done on a 
 closed path or it returns true on all points in the test area. 
 
 I also tried NSBezierPath containsPath: and , but it returned the exact same 
 things as the CGPath functions. 
 
 Another idea I have, though not sure if it will work, is converting the 
 drawing to NSBitmapImageRep and using colorAtX:y to test for a specific color 
 to test for a point.
 
 The downside of this approach is you must test all the points in a bounding 
 box, and could get quite large if our line segment is complicated.
 
 I'm surprised I haven't found a convenience method to return all the points 
 in an outline.
 
 Any help would be greatly appreciated.
 
 - Cody___
 
 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/davedelong%40me.com
 
 This email sent to davedel...@me.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 arch...@mail-archive.com


Re: NSExpression is incorrect?

2010-11-22 Thread Dave DeLong
Thanks for this suggestion, Ben.  I ultimately went with a combination of this 
suggestion (dynamically determining associativity) and Ronald's suggestion 
(allowing the user to choose).  My parser will start with the associativity 
used by NSExpression, but provides a property to change it.

Thanks!

Dave

On Nov 21, 2010, at 3:33 AM, Ben Haller wrote:

  Another option would be to make your code mimic whatever NSExpression is 
 doing on that machine, by evaluating 2 ** 3 ** 2 (once, and caching the 
 result) and seeing whether it comes out as 64 or 512.  That way if/when Apple 
 fixes their bug, your code will seamlessly follow suit.
 
  Which of these alternatives is best depends upon how your code is going to 
 be used, of course.  Roland's suggestion of a compatibility switch seems 
 good; the behavior I suggest could be a third option for that switch.  Then 
 the user of the class can decide what they want to get.  Probably the best 
 default would be to use the correct (right associative) parsing, though, as 
 it seems unlikely that a whole lot of code specifically depends upon this bug 
 in NSExpression, so for most clients there is probably no need to propagate 
 the buggy behavior...
 
 Ben Haller
 McGill University
___

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

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

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

This email sent to arch...@mail-archive.com


Radio dial buttons [iOS]

2010-11-22 Thread Development
A while back I saw an app that had dials to adjust certain settings. 
I could have sworn there was example code related to it. Anyway. I'm wondering 
if any of you might know where I could look to find information on creating 
dials for iPhone/iPad. I've been googling for a bit and all I can come up with 
are button to make the phone dial a call.

I was thinking that I might be able to utilize the pan gesture for this but I 
cannot quite figure out how to know the direction the dial should rotate, 
especially if it crosses the center line.



April.___

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

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

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

This email sent to arch...@mail-archive.com


[ANN] DDMathParser

2010-11-22 Thread Dave DeLong
Hi everyone,

I thought it'd be fun to write a mathematical expression evaluator, a la Graham 
Cox's GCMathParser, but one that was extensible.  So I dusted off my parsing 
skills and wrote DDMathParser: https://github.com/davedelong/DDMathParser

It's an NSString = NSNumber expression evaluator, and its major feature is 
that you can define custom mathematical functions.  So if you really need to 
have a multiplyBy42() function, then you can quickly write one, register it, 
and use it.

You can use it very simply:

NSLog(@%@, [@1 + 2 numberByEvaluatingString]); //logs 3

Or very complexly:

DDMathParser * parser = [DDMathParser mathParserWithString:@2 ** 3 ** 
2];
[parser setPowerAssociativity:DDMathParserAssociativityRight];
DDExpression * e = [parser parsedExpression];
NSLog(@%@, [e evaluateWithSubstitutions:nil evaluator:nil]); //logs 
512

It supports pretty much all of the functions defined by NSExpression, plus many 
more (primarily trig functions: sin(), cos(), atanh(), etc).  And like I 
mentioned above, you can create new functions as well.

It supports variables of the same format used by NSPredicate/NSExpression 
($variable) for substituting in values during evaluation.

It has rudimentary support for simplifying expressions, and I'm currently 
working on support for translating an arbitrary DDExpression into an 
NSExpression and still having it work properly (even with custom functions).

The source code is available on my github page, and I'd appreciate any comments 
or feedback you might have.

https://github.com/davedelong/DDMathParser

Cheers,

Dave DeLong
___

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

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

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

This email sent to arch...@mail-archive.com


Re: Obtaining all points on a line segment

2010-11-22 Thread Graham Cox
Hit testing of lines/paths can basically be done in two ways:

a) mathematically, in that you determine whether a given point is close to a 
given line by calculation
b) graphically, in that you draw the line into some image and test the pixel 
drawn.

I've done quite a bit of work on this in the past in my DrawKit framework, and 
without a doubt approach (b) is by far the most versatile. For one thing it can 
deal with varying transparency, line widths, antialiasing and other stylistic 
variations you might dream up.

The general approach, which is due to Ken Ferry, is to create a bitmap just 1 
pixel by 1 pixel, having only an alpha channel. Using a suitable transform, you 
translate this bitmap (within a suitable context) to the point you're 
hit-testing, and draw the path you're testing into the context. If the path 
draws a non-tranparent pixel at the hit-test location, the 1-byte backing store 
of the bitmap will be changed. If it was not hit, it won't. This is very 
efficient as the graphics system doesn't waste time rendering to a bitmap that 
doesn't exist, and it uses a tiny amount of memory. It's easily fast enough for 
real-time hit testing (and it's also easy to refine such that when you are 
hit-testing as opposed to drawing the real path, you can take shortcuts such as 
using a coarser flatness value, rendering just one of several strokes, etc. You 
can also set up the test context/bitmap just once and reuse it for all tests so 
avoiding the overhead of creating this set of objects each time - you just need 
to clear the single alpha byte.).

Highly recommended.

--Graham







On 23/11/2010, at 3:12 AM, Cody Garvin wrote:

 Hi all,
 
 I searched back through 2005 in the Cocoa Mailing List and didn't see any 
 requests for this.
 
 We need all the points on a line / arc / path on the screen. We need to do 
 hit detection on stroked line, so we must know if the point is valid or not. 
 
 I thought using CGPathContainsPoint would work, but it must be done on a 
 closed path or it returns true on all points in the test area. 
 
 I also tried NSBezierPath containsPath: and , but it returned the exact same 
 things as the CGPath functions. 
 
 Another idea I have, though not sure if it will work, is converting the 
 drawing to NSBitmapImageRep and using colorAtX:y to test for a specific color 
 to test for a point.
 
 The downside of this approach is you must test all the points in a bounding 
 box, and could get quite large if our line segment is complicated.
 
 I'm surprised I haven't found a convenience method to return all the points 
 in an outline.
 
 Any help would be greatly appreciated.

___

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

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

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

This email sent to arch...@mail-archive.com


Re: [ANN] DDMathParser

2010-11-22 Thread Graham Cox
Ah, nice job! It's about time my crusty old code was updated but I'm just too 
busy...

--Graham


On 23/11/2010, at 3:41 PM, Dave DeLong wrote:

 Hi everyone,
 
 I thought it'd be fun to write a mathematical expression evaluator, a la 
 Graham Cox's GCMathParser, but one that was extensible.  So I dusted off my 
 parsing skills and wrote DDMathParser: 
 https://github.com/davedelong/DDMathParser
 
 It's an NSString = NSNumber expression evaluator, and its major feature is 
 that you can define custom mathematical functions.  So if you really need to 
 have a multiplyBy42() function, then you can quickly write one, register it, 
 and use it.
 
 You can use it very simply:
 
   NSLog(@%@, [@1 + 2 numberByEvaluatingString]); //logs 3
 
 Or very complexly:
 
   DDMathParser * parser = [DDMathParser mathParserWithString:@2 ** 3 ** 
 2];
   [parser setPowerAssociativity:DDMathParserAssociativityRight];
   DDExpression * e = [parser parsedExpression];
   NSLog(@%@, [e evaluateWithSubstitutions:nil evaluator:nil]); //logs 
 512
 
 It supports pretty much all of the functions defined by NSExpression, plus 
 many more (primarily trig functions: sin(), cos(), atanh(), etc).  And like I 
 mentioned above, you can create new functions as well.
 
 It supports variables of the same format used by NSPredicate/NSExpression 
 ($variable) for substituting in values during evaluation.
 
 It has rudimentary support for simplifying expressions, and I'm currently 
 working on support for translating an arbitrary DDExpression into an 
 NSExpression and still having it work properly (even with custom functions).
 
 The source code is available on my github page, and I'd appreciate any 
 comments or feedback you might have.
 
 https://github.com/davedelong/DDMathParser
 
 Cheers,
 
 Dave DeLong

___

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

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

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

This email sent to arch...@mail-archive.com


Re: Help diagnosing networking/internet performance issues

2010-11-22 Thread Graham Cox

On 23/11/2010, at 12:31 PM, Graham Cox wrote:

 In working on some networking code, I've come across one test machine on our 
 local net that has extremely slow performance.


OK, looks like my Airport hardware is up the swanee.

Cut a long story short - none of the suggested diagnostics turned up anything 
unusual, so I reinstalled the OS on a totally wiped disk. Still no joy over 
AirPort, but now wired ethernet is OK.

It's a new machine so it's going back to the store this afternoon. Thanks, and 
sorry for the off-topic noise.

--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 arch...@mail-archive.com


Objective-C Mind Map Libraries

2010-11-22 Thread Andrew McLaughlin
Hi guys (and gals),

I'm new to the Objective-C arena and am still getting my bearings. Besides the 
amazing set of libraries that Apple provides in the SDK, is there an open 
source repository elsewhere of Objective-C libraries that can be used in 
development? Specifically, I'm looking for a SourceForge or FreshMeat type of 
site that is searchable.

I have an app idea that will span, iPhone, iPod Touch, iPad and the Mac OS X 
Desktop that I would like to development. The main UI for this app will be a 
Mind Map structure. Nothing quite as crazy/fancy as what Tony Buzan and those 
folks are doing. Each node of the diagram will need to be clickable, editable 
and provide for some gestures (under Mac OS X Lion). I'd hate to roll my own if 
there is something already available.

Thanks,
Andrew
___

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

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

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

This email sent to arch...@mail-archive.com


NSDebug.h where?

2010-11-22 Thread Laurent Daudelin
Trying to access this header to check its content and I don't find it in the 
Foundation framework anymore for iOS. So, where is it now? All references I 
find while googling it refers to pages that were updated in 2002 and 2003, 
nothing recent.

Have I been sleeping all those years and missed it?

Thanks!

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://www.nemesys-soft.com/
Logiciels Nemesys Software  
laur...@nemesys-soft.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 arch...@mail-archive.com


Re: [ANN] DDMathParser

2010-11-22 Thread Carter Allen
Hey Dave,

I'm currently working on an app that loads expressions from plugin-like files, 
and currently we're having the expressions be written in JavaScript syntax and 
then using a WebView to evaluate the JavaScript. Obviously, this is less than 
ideal. I'm wondering if you think that DDMathParser is equal, greater, or 
lesser in raw mathematical capability (remember, everything has to be done 
based on an input string) than using JavaScript. If it's lesser, then perhaps 
there would be some way of having your class detect when it has hit an 
expression it can't figure out, and at that point pass the expression to WebKit.

Sincerely,
Carter Allen

On Nov 22, 2010, at 9:41 PM, Dave DeLong wrote:

 Hi everyone,
 
 I thought it'd be fun to write a mathematical expression evaluator, a la 
 Graham Cox's GCMathParser, but one that was extensible.  So I dusted off my 
 parsing skills and wrote DDMathParser: 
 https://github.com/davedelong/DDMathParser
 
 It's an NSString = NSNumber expression evaluator, and its major feature is 
 that you can define custom mathematical functions.  So if you really need to 
 have a multiplyBy42() function, then you can quickly write one, register it, 
 and use it.
 
 You can use it very simply:
 
   NSLog(@%@, [@1 + 2 numberByEvaluatingString]); //logs 3
 
 Or very complexly:
 
   DDMathParser * parser = [DDMathParser mathParserWithString:@2 ** 3 ** 
 2];
   [parser setPowerAssociativity:DDMathParserAssociativityRight];
   DDExpression * e = [parser parsedExpression];
   NSLog(@%@, [e evaluateWithSubstitutions:nil evaluator:nil]); //logs 
 512
 
 It supports pretty much all of the functions defined by NSExpression, plus 
 many more (primarily trig functions: sin(), cos(), atanh(), etc).  And like I 
 mentioned above, you can create new functions as well.
 
 It supports variables of the same format used by NSPredicate/NSExpression 
 ($variable) for substituting in values during evaluation.
 
 It has rudimentary support for simplifying expressions, and I'm currently 
 working on support for translating an arbitrary DDExpression into an 
 NSExpression and still having it work properly (even with custom functions).
 
 The source code is available on my github page, and I'd appreciate any 
 comments or feedback you might have.
 
 https://github.com/davedelong/DDMathParser
 
 Cheers,
 
 Dave DeLong
 ___
 
 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/lists%40cartera.me
 
 This email sent to li...@cartera.me

___

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

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

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

This email sent to arch...@mail-archive.com


Re: Core data fetch and multithreading

2010-11-22 Thread Chris Hanson
On Nov 21, 2010, at 11:47 AM, vincent habchi vi...@macports.org wrote:

 briefly speaking, I have a Core Data Entity bearing a to-many relationship 
 (therefore an NSSet * iVar). A dialog on the main thread can modify this set, 
 while it may be simultaneously enumerated on a background GCD thread. I have 
 therefore used the managed object context provided mutex to protect the 
 respective snippets.

Don't do this.  If you're using bindings or KVO at all in your main thread, you 
CANNOT lock your context every place you need to in order to make this safe. 
Furthermore, I suspect you may not be locking your context on the background 
thread because you're just reading - that's also incorrect.

Use a separate context on the background thread, attached to the same 
NSPersistentStoreCoordinator, and only pass managed object IDs between threads. 
Also, be sure to create your background thread's context on the thread or queue 
which you wish to use it; don't create one on the main thread and then pass it 
in to your background thread. (The reason for is is that a context can care 
about eg the run loop it's on. You don't want to use a context attached to the 
main thread's run loop from a background thread.)

This is pretty much the standard for Core Data multithreading: thread isolation 
of object graphs (as represented by contexts), passing only object IDs( and 
did-save notifications containing object IDs) between threads.

  -- 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 arch...@mail-archive.com


Re: Core data fetch and multithreading

2010-11-22 Thread Chris Hanson
On Nov 22, 2010, at 1:08 PM, Quincey Morris quinceymor...@earthlink.net wrote:

 On Nov 22, 2010, at 07:58, Hunter Hillegas wrote:
 
 I think someone somewhere told me that if you create a MOC on the main 
 thread, there's some special runloop integration that is included, hence one 
 of the reasons it's important to not create one on the main thread and then 
 pass it around.
 
 Perhaps that's true, but it sounds like an urban myth. If it's true, the MOC 
 locking approach can't work *at all* either -- because for the duration of 
 the lock the MOC is in fact being used on a background thread. But the MOC 
 locking approach *can* work, ergo ... etc ... QED.

You're right that context locking between a main-thread and non-main-thread use 
of a single context can't work; this isn't an urban myth. Context locking can 
only really work for contexts created on background threads, but you shouldn't 
need context locking anyway; just use one context per thread/queue and share 
the coordinator instead. Life will be much easier.

 It seems feasible to design your app so that when something non-UI-related 
 needs to happen, you can dispatch the work as a GCD-based operation.

All NSOperations are GCD operations. I generally recommend not using raw GCD 
in Cocoa code, instead preferring the higher level abstraction offered by 
NSOperation (which supports dependencies, priorities, cancellation, and so on). 
Using GCD doesn't even really get you much in terms of lines-of-code savings, 
especially once you start subclassing NSOperation and building your own 
abstractions atop it.

 For operations that need to modify the data, it's easy to just pass the main 
 MOC as a parameter into the GCD block, isn't it?

Don't do this; it isn't safe to just pass a main-thread context to a background 
thread. Instead, pass the persistent store coordinator and the IDs of any 
needed managed objects, and create a managed object context within your 
operation with.  Contexts are cheap, you can use them as scratch pads like this.

  -- 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 arch...@mail-archive.com