OK, break it down for me... (question about gzip)

2010-06-08 Thread Graham Cox
I need to be able to make a .gzip file from a FOLDER on my hard disk 
programatically.

I've searched the archives and Googled for it, and now I'm just confused. Some 
folk advocate linking to the library directly, other to invoke it via NSTask. 
Since it's a folder I need to compress, not in-memory data, the direct linking 
approach might not do it (then again it might, but I haven't been able to find 
out the right information about how I could do that). The NSTask approach might 
be simpler as it is easy to pass in the path to the folder to be compressed, 
but how do I find the correct, reliable launch path that will always work no 
matter how my app is being run? I'm sure that's simple (perhaps so simple it's 
taken for granted, which is why I have drawn a blank with finding any 
instructions as to how to do this).

So would some one break it down for me? I seem to be wasting too much time 
focusing on this trivial operation that is less than 1% of my object's 
functionality.

--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: OK, break it down for me... (question about gzip)

2010-06-08 Thread Stephen J. Butler
On Tue, Jun 8, 2010 at 1:04 AM, Graham Cox graham@bigpond.com wrote:
 I need to be able to make a .gzip file from a FOLDER on my hard disk 
 programatically.

a) You can't gzip a folder. That's why people tar the folders, then
gzip the tar file (or just use the 'z' option in tar).

b) In a working OS X system, the unix executables will always be where
they're supposed to be (ie: /bin, /sbin, /usr/bin, /usr/sbin, etc).
___

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: OK, break it down for me... (question about gzip)

2010-06-08 Thread Graham Cox
It has been pointed out to me off-list that I've been labouring under the 
misapprehension that gzip is equivalent to zip, which appears not to be the 
case. It might explain why it was hard to find relevant info.

So I need zip then... otherwise same discussion applies. I don't really care 
how I get there, I just need a folder transformed into a single file that is 
efficiently packed for transmission to a website. The format isn't really 
relevant, but transmission efficiency, and keeping the folder integrity, is.


--Graham


On 08/06/2010, at 4:04 PM, Graham Cox wrote:

 I need to be able to make a .gzip file from a FOLDER on my hard disk 
 programatically.
 
 I've searched the archives and Googled for it, and now I'm just confused. 
 Some folk advocate linking to the library directly, other to invoke it via 
 NSTask. Since it's a folder I need to compress, not in-memory data, the 
 direct linking approach might not do it (then again it might, but I haven't 
 been able to find out the right information about how I could do that). The 
 NSTask approach might be simpler as it is easy to pass in the path to the 
 folder to be compressed, but how do I find the correct, reliable launch path 
 that will always work no matter how my app is being run? I'm sure that's 
 simple (perhaps so simple it's taken for granted, which is why I have drawn a 
 blank with finding any instructions as to how to do this).
 
 So would some one break it down for me? I seem to be wasting too much time 
 focusing on this trivial operation that is less than 1% of my object's 
 functionality.
 
 --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: OK, break it down for me... (question about gzip)

2010-06-08 Thread John Joyce

On Jun 8, 2010, at 1:16 AM, Stephen J. Butler wrote:

 On Tue, Jun 8, 2010 at 1:04 AM, Graham Cox graham@bigpond.com wrote:
 I need to be able to make a .gzip file from a FOLDER on my hard disk 
 programatically.
 
 a) You can't gzip a folder. That's why people tar the folders, then
 gzip the tar file (or just use the 'z' option in tar).
 
 b) In a working OS X system, the unix executables will always be where
 they're supposed to be (ie: /bin, /sbin, /usr/bin, /usr/sbin, etc).

They can move from one version of the OS to another.
Not likely, but can happen. (10.5 and up there is a fairly unique Ruby 
installation unlike previous)
If you *really* want, you could run a prior NSTask on Unix command line tool

which

and that will let you locate the actual path of the command line tool you want 
to use. (pass that path to your next NSTask)

See 
man which 
for usage.

 ___
 
 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/jjoyce%40apple.com
 
 This email sent to jjo...@apple.com

___

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

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

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

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


Re: OK, break it down for me... (question about gzip)

2010-06-08 Thread Graham Cox

On 08/06/2010, at 4:16 PM, Stephen J. Butler wrote:

 b) In a working OS X system, the unix executables will always be where
 they're supposed to be (ie: /bin, /sbin, /usr/bin, /usr/sbin, etc).


Thanks Stephen, so given the four choices I looked at each and find zip in 
/usr/bin

The question is can I be sure it's there on every system, no matter how the 
user is logged in? i.e. can I hard-code the path? If not, what is a reliable 
way to find the location programmatically?

--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: OK, break it down for me... (question about gzip)

2010-06-08 Thread Graham Cox

On 08/06/2010, at 4:21 PM, John Joyce wrote:

 which
 
 and that will let you locate the actual path of the command line tool you 
 want to use. (pass that path to your next NSTask)


Ok... but doesn't that just displace the problem one step? How do I find the 
path to which without being able to run which reliably?

--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: OK, break it down for me... (question about gzip)

2010-06-08 Thread Kyle Sluder

On Jun 7, 2010, at 11:04 PM, Graham Cox graham@bigpond.com wrote:

I need to be able to make a .gzip file from a FOLDER on my hard disk  
programatically.


I would use ditto to produce the tarball, because it will produce the  
same results as the Finder.


--Kyle Sluder
(Sent from my hotel room at WWDC, where you should be too!)
___

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: OK, break it down for me... (question about gzip)

2010-06-08 Thread glaurent
On Tue 08/06/10 08:34, Graham Cox graham@bigpond.com wrote:
 
 On 08/06/2010, at 4:21 PM, John Joyce wrote:
 
  which
  
  and that will let you locate the actual path of the
 command line tool you want to use. (pass that path to your next
 NSTask)
 
 Ok... but doesn't that just displace the problem one step? How do I find
 the path to which without being able to run which
 reliably?

'which' is generally a shell built-in command, although it does also exist as a 
stand-alone binary in /usr/bin. What you're asking is actually more a Unix 
system programming question. In Unix you'd do a fork()/exec(), knowing that the 
$PATH environment variable will contain /usr/bin. In Cocoa, from what I gather, 
you use NSTask instead of fork()/exec(), and NSProcessInfo:environment to 
access/check $PATH. You probably don't need to bother with 'which', I assume 
that NSTask uses $PATH as well (correct me if I'm wrong).

-- 
Guillaume
http://telegraph-road.org


___

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

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

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

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


Re: OK, break it down for me... (question about gzip)

2010-06-08 Thread Alastair Houghton
On 8 Jun 2010, at 07:25, Graham Cox wrote:

 On 08/06/2010, at 4:16 PM, Stephen J. Butler wrote:
 
 b) In a working OS X system, the unix executables will always be where
 they're supposed to be (ie: /bin, /sbin, /usr/bin, /usr/sbin, etc).
 
 Thanks Stephen, so given the four choices I looked at each and find zip in 
 /usr/bin
 
 The question is can I be sure it's there on every system, no matter how the 
 user is logged in? i.e. can I hard-code the path?

Yes.  *Don't* as someone else suggested use the which (or /usr/bin/env, which 
would be better) to locate it, because if you do that you might pick up a 
version of zip that you haven't tested against (or some other program entirely 
that happens to have installed an executable called zip).  Hard-coding the 
path is the right thing to do.

Kind regards,

Alastair.

-- 
http://alastairs-place.net



___

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

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

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

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


Re: Scrolling Behavior of NSTextView

2010-06-08 Thread Paul Sanders
 Martin, I tried the  [NSTextView scrollRangeToVisible:] with 
 NSMakeRange(0,0) , but it is the same as to use [scrollPoint:] solely. Only 
 with
 [glyphRangeForTextContainer:] in prior the scroll-to-top works. I don't think 
 it is the problem of coordinate system flip-ness, because when using
 [scrollPoint:] without [glyphRangeForTextContainer:], the text view does not 
 always scroll to bottom, either, it just does not always scroll to top under
 certain window size and text length. And it seems not solely 
 [glyphRangeForTextContainer:] triggers the scroll-to-top because without 
 [scrollPoint:] the
 scrolling does not work, either.

I thank Martin is right though - the fact that the coordinate system is flipped 
means that it is not necessary to know the dimensions of the text in order to 
position point (0, 0) in the top-lefthand corner.  And just calling 
glyphRangeForTextContainer: on its own will not cause any scrolling.

 Another minor wired problem is the trick of using both 
 [glyphRangeForTextContainer:] and [scrollPoint:] works only when you 
 drag-drop a NSScrollView
 in IB and then set the embedded custom view as NSTextView. If an NSTextView 
 is dragged and dropped directly (and IB automatically embed it in a
 NSScrollView), the scroll-to-top does not work even with the trick (and I 
 haven't found a trick to make it work under such situation).

That would seem to point to some difference in the way the NSTextView is 
initialised by IB, although I'm not sure what.  Using a custom view is clearly 
undesirable as you cannot set the properties of the text view in IB that way.

You could try calling displayIfNeeded on the enclosing scroll view before 
calling scrollPoint:.  This ought to perform any necessary layout and maybe one 
or two other things.  It shouldn't cause any screen flash because the window 
will not be flushed until you return to the run loop.  You can get hold of the 
enclosing scroll view via [[myTextView superview] superview].

I also thought that Martin's idea of putting a breakpoint on [NSTextView 
scrollPoint:] might turn up something interesting.  You could also put a 
breakpoint on [NSTextView setBounds:] as that is what scrollPoint: will 
ultimately call, see:

http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/NSScrollViewGuide/Articles/Basics.html#//apple_ref/doc/uid/TP40003461-SW1

Regards,

Paul Sanders
___

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


32bit float array to PNG thanks to NSBitmapImageRep problem

2010-06-08 Thread Pierre-Yves Aquilanti
Hello,

i'm trying to convert a float array to a greyscale PNG with a
NSBitmapImageRep but i doesn't work and all i get is a blank png (just
white).

To test the feasibility of my idea i created a float array of size 55*77
with half filled with 1500. and the other half filled with 3000. Theorically
i should obtain a PNG that looks like the picture in the following link :
http://www.hostingpics.net/viewer.php?id=315752capture.png

Here is the source code that i use :


/ Code begin
**/
//load the floating point array
NSData * binaryData=[NSData dataWithContentsOfFile:binaryPath]; //binary is
just a 32bits array full of 1500. and 3000. as described previously

//get a pointer
datapointer = (unsigned char *) [binaryData bytes];

//convert the array into a NSBitmapImageRep

NSBitmapImageRep * bitmap = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:datapointer pixelsWide:sx pixelsHigh:sz
  bitsPerSample:32
samplesPerPixel:1 hasAlpha:NO isPlanar:NO

colorSpaceName:NSCalibratedWhiteColorSpace

bitmapFormat:NSFloatingPointSamplesBitmapFormat
  bytesPerRow:4*sx
bitsPerPixel:32];

//save it to png format
NSData * tow = [bitmap representationUsingType:NSPNGFileType
properties:nil];

[tow writeToFile:@/Users/Perif/Desktop/img.png atomically:NO];

/Code
End**/

My questions are : Is this the proper way to do what i want (convert a
32bits float array to a greyscale PNG) ? What is my error ?

Thanks a lot for your help.

Perif
___

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


Garbage collector

2010-06-08 Thread Takeichi Kanzaki Cabrera
Hi all, I'm beginning with an application for Mac OS X that in a
future could become into an iphone app, could I use the garbage
collector or is better don't use it?

Regards,
Takeichi
___

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: [iPhone] -UIScrollView

2010-06-08 Thread Scott Anguish
This is exactly what UIScrollView was intended for in Paging mode, and the 
documentation explains how to do this with a minimum of 2 or 3 views (I can't 
remember which I decided on, 2 will work, but 3 is smoother).

I'm unsure of the restraints on loading single pages of PDF files, so that 
might be an issue, but display wise, you don't need to (nor should you) make 
all the views at once and stick them in a scroll view.


On May 31, 2010, at 9:58 PM, Development wrote:

 I have a Scroll view that contains a master view. This master view adds page 
 sized views of image data, specifically PDF data. The problem that I am 
 having is that if I load all these pages at once, I run out of memory and the 
 app quits. So I was hoping there was a way to make it so that the images are 
 only drawn if they are in the scroll view's visible region. Secondly is Core 
 graphics the best way to be doing 
 this?___

___

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: Garbage collector

2010-06-08 Thread Thomas Davie
At present, the iPhone SDK does not support garbage collection, so you're best 
off at least making it GC supported, rather than required.

Bob

On 8 Jun 2010, at 11:48, Takeichi Kanzaki Cabrera wrote:

 Hi all, I'm beginning with an application for Mac OS X that in a
 future could become into an iphone app, could I use the garbage
 collector or is better don't use it?
 
 Regards,
 Takeichi
 ___
 
 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/tom.davie%40gmail.com
 
 This email sent to tom.da...@gmail.com

___

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

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

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

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


MacTech Conference 2010: Call for Speakers

2010-06-08 Thread Edward Marczak
The MacTech Conference 2010 is now actively seeking speakers:

http://www.mactech.com/conference

This is a new, community-oriented conference to be held in November in
Los Angeles, California. Topics on all areas of development are being
considered, and formats for presenting are open. Those wishing to
present at the show, please fill out the form at:

https://forms.mactech.com/phpq/fillsurvey.php?sid=139

Questions? Please feel free to contact me directly.
--
Ed Marczak
e: marc...@radiotope.com
t: http://twitter.com/marczak
___

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


Erasing drawn content

2010-06-08 Thread Matej Bukovinski
Hi,

In a cocoa application that I'm developing I have a custom NSView subclass that 
I use as an overlay view for annotating a WebView. The overlay view draws 
semi-trasparent rectangles in its drawRect: method for DOM elements that were 
selected by the user. 

Since the fill color for the drawn rectangles is semi-transparent, the pixel 
values get added up when a smaller rectangle is drawn over a larger one (here's 
an example http://cl.ly/4fecb8fac0abff6ef6ac , as you can see the smaller 
rectangle has a darker background because of the larger rectangle, that was 
drawn first). This is especially problematic if the rectangles are of different 
colors, since color mixing occurs. 

I would like to prevent this sort of behavior by somehow erasing the content 
that was perviously drawn (i.e., making the background transparent again) 
before drawing with a new element. Does anyone have an idea how to achieve 
this? 

Thank you for your time.

Best regards,
Matej



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: Activating application raises windows meant to be invisible

2010-06-08 Thread David Reitter
On May 28, 2010, at 1:04 AM, Peter Ammon wrote:

 If a window is ordered out, AppKit will not order it back in when the app is 
 activated.  Is it possible that a different window is created, or that the 
 window was not ordered out to begin with?


I have verified that it is the same window that appears.  (The NSWindow object 
is below, 1).
I have also checked that we send the window an `orderOut'.
I find that my NSApp object gets an AppKit event (sendEvent:) when the 
application becomes active (shown below, 2).  I'm passing this event back to 
NSApplication ([super sendEvent: theEvent]), and the window becomes visible at 
that moment.   Not passing on the event prevents the window from being made 
visible.

So, I still don't understand where my mistake is.

(1) window after it's been ordered out:

$4 = {
  NSResponder = {
NSObject = {
  isa = 0x1002b0b38
}, 
members of NSResponder: 
_nextResponder = 0x0
  }, 
  members of NSWindow: 
  _frame = {
origin = {
  x = 13, 
  y = 375
}, 
size = {
  width = 642, 
  height = 638
}
  }, 
  _contentView = 0x101188600, 
  _delegate = 0x101350cd0, 
  _firstResponder = 0x101350cd0, 
  _lastLeftHit = 0x101350cd0, 
  _lastRightHit = 0x0, 
  _counterpart = 0x0, 
  _fieldEditor = 0x0, 
  _winEventMask = -1071906784, 
  _windowNum = 334, 
  _level = 0, 
  _backgroundColor = 0x10084d180, 
  _borderView = 0x101185ca0, 
  _postingDisabled = 0 '\000', 
  _styleMask = 14 '\016', 
  _flushDisabled = 0 '\000', 
  _reservedWindow1 = 0 '\000', 
  _cursorRects = 0x10111d210, 
  _trectTable = 0x101137ee0, 
  _miniIcon = 0x0, 
  _unused = 0, 
  _dragTypes = 0x0, 
  _representedURL = 0x0, 
  _sizeLimits = 0x0, 
  _frameSaveName = 0x0, 
  _regDragTypes = 0x10137e890, 
  _wFlags = {
backing = 2, 
visible = 0, 
isMainWindow = 0, 
isKeyWindow = 0, 
hidesOnDeactivate = 0, 
dontFreeWhenClosed = 0, 
oneShot = 0, 
deferred = 1, 
cursorRectsDisabled = 0, 
haveFreeCursorRects = 1, 
validCursorRects = 0, 
docEdited = 1, 
dynamicDepthLimit = 0, 
worksWhenModal = 0, 
limitedBecomeKey = 0, 
needsFlush = 0, 
viewsNeedDisplay = 0, 
ignoredFirstMouse = 0, 
repostedFirstMouse = 0, 
windowDying = 0, 
tempHidden = 0, 
floatingPanel = 0, 
wantsToBeOnMainScreen = 0, 
optimizedDrawingOk = 0, 
optimizeDrawing = 1, 
titleIsRepresentedFilename = 0, 
excludedFromWindowsMenu = 0, 
depthLimit = 0, 
delegateReturnsValidRequestor = 1, 
lmouseupPending = 0, 
rmouseupPending = 0, 
wantsToDestroyRealWindow = 0, 
wantsToRegDragTypes = 0, 
sentInvalidateCursorRectsMsg = 0, 
avoidsActivation = 0, 
frameSavedUsingTitle = 0, 
didRegDragTypes = 1, 
delayedOneShot = 0, 
postedNeedsDisplayNote = 0, 
postedInvalidCursorRectsNote = 0, 
initialFirstResponderTempSet = 0, 
autodisplay = 1, 
tossedFirstEvent = 0, 
isImageCache = 0, 
interfaceStyle = 0, 
keyViewSelectionDirection = 0, 
defaultButtonCellKETemporarilyDisabled = 0, 
defaultButtonCellKEDisabled = 1, 
menuHasBeenSet = 1, 
wantsToBeModal = 0, 
showingModalFrame = 0, 
isTerminating = 0, 
win32MouseActivationInProgress = 0, 
makingFirstResponderForMouseDown = 0, 
needsZoom = 0, 
sentWindowNeedsDisplayMsg = 0, 
liveResizeActive = 0
  }, 
  _defaultButtonCell = 0x0, 
  _initialFirstResponder = 0x101188600, 
  _auxiliaryStorage = 0x1013515e0
}
(gdb) 


(2) The event:

(gdb) print *theEvent
$1 = {
  NSObject = {
isa = 0x7fff70186180
  }, 
  members of NSEvent: 
  _type = 13, 
  _location = {
x = 0, 
y = 1050
  }, 
  _modifierFlags = 80, 
  _WSTimestamp = 0x0, 
  _timestamp = 5264.234190001, 
  _windowNumber = 0, 
  _window = 0x0, 
  _context = 0x0, 
  _data = {
mouse = {
  eventNumber = 1, 
  clickCount = 0, 
  pressure = 1.59748025e-43, 
  deltaX = 3.9525251667299724e-322, 
  deltaY = 0, 
  subtype = 0, 
  buttonNumber = 0, 
  reserved1 = 0, 
  reserved2 = {0, 0, 0}
}, 
key = {
  keys = 0x1, 
  unmodKeys = 0x72, 
  keyCode = 80, 
  isARepeat = 0 '\000', 
  eventFlags = 0, 
  reserved = {0, 0, 0, 0, 0}
}, 
tracking = {
  eventNumber = 1, 
  trackingNumber = 114, 
  userData = 0x50, 
  reserved = {0, 0, 0, 0, 0, 0}
}, 
scrollWheel = {
  deltaX = 4.9406564584124654e-324, 
  deltaY = 5.6323483625902106e-322, 
  deltaZ = 3.9525251667299724e-322, 
  subtype = 0, 
  reserved1 = 0, 
  reserved2 = {0, 0, 0, 0, 0, 0}
}, 
axisGesture = {
  deltaX = 4.9406564584124654e-324, 
  deltaY = 5.6323483625902106e-322, 
  deltaZ = 3.9525251667299724e-322, 
  reserved = {0, 0, 0, 0, 0, 0, 0}
}, 
miscGesture = {
  subtype = 1, 
  gestureEnded = 0 '\000', 
  reserved = 0 '\000', 
  value = 0, 
  percentage = 1.59748025e-43, 
  

Re: Erasing drawn content

2010-06-08 Thread Steve Christensen
Perhaps call NSRectFillUsingOperation(rect, NSCompositeClear) before  
drawing each rectangle?



On Jun 8, 2010, at 5:32 AM, Matej Bukovinski wrote:


* PGP Bad Signature, Signed by an unverified key

Hi,

In a cocoa application that I'm developing I have a custom NSView  
subclass that I use as an overlay view for annotating a WebView. The  
overlay view draws semi-trasparent rectangles in its drawRect:  
method for DOM elements that were selected by the user.


Since the fill color for the drawn rectangles is semi-transparent,  
the pixel values get added up when a smaller rectangle is drawn over  
a larger one (here's an example http://cl.ly/4fecb8fac0abff6ef6ac ,  
as you can see the smaller rectangle has a darker background because  
of the larger rectangle, that was drawn first). This is especially  
problematic if the rectangles are of different colors, since color  
mixing occurs.


I would like to prevent this sort of behavior by somehow erasing  
the content that was perviously drawn (i.e., making the background  
transparent again) before drawing with a new element. Does anyone  
have an idea how to achieve this?


Thank you for your time.

Best regards,
Matej


* Matej Bukovinski ma...@bukovinski.com
* Issuer: The USERTRUST Network - Unverified


___

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: OK, break it down for me... (question about gzip)

2010-06-08 Thread John Joyce

On Jun 8, 2010, at 5:40 AM, Alastair Houghton wrote:

 On 8 Jun 2010, at 07:25, Graham Cox wrote:
 
 On 08/06/2010, at 4:16 PM, Stephen J. Butler wrote:
 
 b) In a working OS X system, the unix executables will always be where
 they're supposed to be (ie: /bin, /sbin, /usr/bin, /usr/sbin, etc).
 
 Thanks Stephen, so given the four choices I looked at each and find zip in 
 /usr/bin
 
 The question is can I be sure it's there on every system, no matter how the 
 user is logged in? i.e. can I hard-code the path?
 
 Yes.  *Don't* as someone else suggested use the which (or /usr/bin/env, 
 which would be better) to locate it, because if you do that you might pick up 
 a version of zip that you haven't tested against (or some other program 
 entirely that happens to have installed an executable called zip).  
 Hard-coding the path is the right thing to do.
 
 Kind regards,
 
 Alastair.
 
 -- 
 http://alastairs-place.net
Just a suggestion of possibility with which.
Approaching things as though you were writing a shell script when when doing 
NSTask things is not wrong.

You could of course do other things as well to test version numbers and such if 
appropriate, depending on needs. 
Some users may indeed have updated or edited things at the command line level. 
As always, the best you can do is attempt to verify there is something there 
you can reliably work with and there is no guarantee there will be. ( unless 
the users will confidently be using standard installations )

To my knowledge there is nothing particularly Cocoa API about doing this beyond 
using NSTask.___

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: OK, break it down for me... (question about gzip)

2010-06-08 Thread Charles Srstka
Something interesting I’ve noticed is that 10.6 now includes libarchive in 
/usr/lib, which would allow one to create tar files and the like without having 
to launch a shell tool. Unfortunately, Apple doesn’t seem to have included the 
headers for it, which may mean that they intend it to be private, so it’s 
probably not a good idea to rely on it. :-/

Charles___

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

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

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

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


Re: Erasing drawn content

2010-06-08 Thread Matej Bukovinski
Thanks for the suggestion Steve. 

Unfortunately this causes the background to turn black and not transparent. I 
would need the view to become transparent (so the WebView underneath is 
visible). 




On 8.6.2010, at 16:04, Steve Christensen wrote:

 Perhaps call NSRectFillUsingOperation(rect, NSCompositeClear) before drawing 
 each rectangle?
 
 
 On Jun 8, 2010, at 5:32 AM, Matej Bukovinski wrote:
 
 * PGP Bad Signature, Signed by an unverified key
 
 Hi,
 
 In a cocoa application that I'm developing I have a custom NSView subclass 
 that I use as an overlay view for annotating a WebView. The overlay view 
 draws semi-trasparent rectangles in its drawRect: method for DOM elements 
 that were selected by the user.
 
 Since the fill color for the drawn rectangles is semi-transparent, the pixel 
 values get added up when a smaller rectangle is drawn over a larger one 
 (here's an example http://cl.ly/4fecb8fac0abff6ef6ac , as you can see the 
 smaller rectangle has a darker background because of the larger rectangle, 
 that was drawn first). This is especially problematic if the rectangles are 
 of different colors, since color mixing occurs.
 
 I would like to prevent this sort of behavior by somehow erasing the 
 content that was perviously drawn (i.e., making the background transparent 
 again) before drawing with a new element. Does anyone have an idea how to 
 achieve this?
 
 Thank you for your time.
 
 Best regards,
 Matej
 
 
 * Matej Bukovinski ma...@bukovinski.com
 * Issuer: The USERTRUST Network - Unverified
 



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

[iPhone] NSManagedObjectContext save doesn't crash but breaks on objc_exception_throw

2010-06-08 Thread Hank Heijink (Mailinglists)
Dear all,

I've run into the following problem, and I'm a bit stuck - I wonder if you can 
shed some light on this. I have an iPhone app that uses Core Data, and the 
problem occurs when the app terminates. I have an NSOperationQueue with 
potentially several NSOperations that are cancelled in the 
applicationWillTerminate: UIApplication delegate method.

These NSOperations all have their own copy of an NSManagedObjectContext and an 
NSManagedObject subclass (I pass them the persistent store coordinator and an 
NSManagedObjectID that is permanent at that point).

Canceling the NSOperation changes an attribute of the NSManagedObject subclass 
and I save the NSManagedObjectContext on the background thread after this 
change is made. This means that the NSManagedObjectContext on the main thread 
is now in conflict, and since all this happens in applicationWillTerminate:, it 
won't receive the NSManagedObjectContextDidSaveNotification so it can deal with 
it.

My solution to this is to set the merge policy to 
NSMergeByPropertyStoreTrumpMergePolicy right before saving the main 
NSManagedObjectContext to give precedence to the already-saved context(s). I 
haven't been able to find any information about this scenario - the Core Data 
Programming Guide (in Communicating Changes Between Contexts) seems to suggest 
my approach (case 3b), although there in-memory changes are preferred over 
store changes.

I always have a break point set on objc_exception_throw, and it hits this 
breakpoint in the call to save. This is the stack backtrace:

#0  0x986d94e6 in objc_exception_throw ()
#1  0x01dee37c in -[NSPersistentStoreCoordinator(_NSInternalMethods) 
executeRequest:withContext:] ()
#2  0x01e22afe in -[NSManagedObjectContext save:] ()
#3  0x36b6 in -[MyAppDelegate applicationWillTerminate:]
...snip...

However, if I remove the break point or hit continue, the application quits 
with an exit code of 0. If I wrap my [NSManagedObjectContext save] call in a 
@try @catch block, the @catch statements are never executed. So, is there an 
exception or isn't there? Should I rethink my approach? I'm just not sure what 
the issue is here.

Any information is greatly appreciated!

Thanks in advance,
Hank___

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: Erasing drawn content

2010-06-08 Thread Paul Sanders
 Unfortunately this causes the background to turn black and not transparent. I 
 would need the view to become transparent
 (so the WebView underneath is visible). 

Try this:

[[NSColor clearColor] setFill];
NSRectFill (myRect);

That's what I do.

Regards,

Paul Sanders
___

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: OK, break it down for me... (question about gzip)

2010-06-08 Thread Karl Moskowski
If Zip is an acceptable substitute for gzip, you can use my BSD-licensed ZipKit 
FW. Works on Mac (as a FW or static lib, GC supported) and iPhone (as a static 
lib), has file-based and in-memory zipping classes, supports Zip64 and is 
cancellable. There's not much in terms of docs (just a How to Use It In Your 
Project doc in the wiki), but there are Demo Projects.

http://bitbucket.org/kolpanic/zipkit/


Karl Moskowski kolpa...@voodooergonomics.com
Voodoo Ergonomics Inc. http://voodooergonomics.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: [iPhone] NSManagedObjectContext save doesn't crash but breaks on objc_exception_throw

2010-06-08 Thread Alexander Spohr
Is there anything in the log?
What does save's error parameter return?

atze


Am 08.06.2010 um 17:53 schrieb Hank Heijink (Mailinglists):

 Dear all,
 
 I've run into the following problem, and I'm a bit stuck - I wonder if you 
 can shed some light on this. I have an iPhone app that uses Core Data, and 
 the problem occurs when the app terminates. I have an NSOperationQueue with 
 potentially several NSOperations that are cancelled in the 
 applicationWillTerminate: UIApplication delegate method.
 
 These NSOperations all have their own copy of an NSManagedObjectContext and 
 an NSManagedObject subclass (I pass them the persistent store coordinator and 
 an NSManagedObjectID that is permanent at that point).
 
 Canceling the NSOperation changes an attribute of the NSManagedObject 
 subclass and I save the NSManagedObjectContext on the background thread after 
 this change is made. This means that the NSManagedObjectContext on the main 
 thread is now in conflict, and since all this happens in 
 applicationWillTerminate:, it won't receive the 
 NSManagedObjectContextDidSaveNotification so it can deal with it.
 
 My solution to this is to set the merge policy to 
 NSMergeByPropertyStoreTrumpMergePolicy right before saving the main 
 NSManagedObjectContext to give precedence to the already-saved context(s). I 
 haven't been able to find any information about this scenario - the Core Data 
 Programming Guide (in Communicating Changes Between Contexts) seems to 
 suggest my approach (case 3b), although there in-memory changes are preferred 
 over store changes.
 
 I always have a break point set on objc_exception_throw, and it hits this 
 breakpoint in the call to save. This is the stack backtrace:
 
 #0  0x986d94e6 in objc_exception_throw ()
 #1  0x01dee37c in -[NSPersistentStoreCoordinator(_NSInternalMethods) 
 executeRequest:withContext:] ()
 #2  0x01e22afe in -[NSManagedObjectContext save:] ()
 #3  0x36b6 in -[MyAppDelegate applicationWillTerminate:]
 ...snip...
 
 However, if I remove the break point or hit continue, the application quits 
 with an exit code of 0. If I wrap my [NSManagedObjectContext save] call in a 
 @try @catch block, the @catch statements are never executed. So, is there an 
 exception or isn't there? Should I rethink my approach? I'm just not sure 
 what the issue is here.
 
 Any information is greatly appreciated!
 
 Thanks in advance,
 Hank___
 
 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/atze%40freeport.de
 
 This email sent to a...@freeport.de

___

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


BOOL returned via -performSelctor: not BOOL on 64-bit system

2010-06-08 Thread James Bucanek

Greetings,

I've been trying to track down a peculiar bug reported by a 
customer, and I've narrowed it down to a problem returning a 
BOOL value via -[NSObject performSelector:] on a dual Quad-Core 
Intel Xeon processor running 64-bit code. It seems that the 
returned value contains random data, which obscures the BOOL.


I've included the relevant code from the project below for 
completeness, but the problem boils down to this statement:


if ([condition performSelector:conditionSelector]!=NO)

The selector identifies a method that returns a BOOL, but 
sometimes the value returned by -performSelector contains odd 
data. I added some code to log the value (as an integer) 
returned by [condition performSelector:conditionSelector]; Most 
of the time it's 0 or 1, but sometimes it's 0x5400 or 0x2300 
when the method returned NO. Note that I cannot reproduce this 
on the two 64-bit Intel systems I have, even though one of them 
is the same model of MacPro with the same dual-Quad-Core Intel 
Xeon as my customer's. All are running 10.6.3.


I thought that, in Objective-C, all pointer and integer scalar 
values were interchangeable in the return value of a method. Is 
this a bug in GCC, a bug in the Objective-C runtime, did this 
rule change in the 64-bit world, or is there possibly something 
strange about this particular user's system?


Anyway, I'm considering changing my code to read 'if 
(([condition performSelector:conditionSelector]0x1)!=NO)' to 
work around this issue, but I'd like to get a fuller 
understanding of the problem for future reference (and so I 
don't say something stupid in my next book about Objective-C!).


--- code snippets ---

@implementation ActionCondition

...

- (BOOL)test
{
// subclass overrides this method to test some condition
return ( ... );
}

...

- (BOOL)shouldCancelAction
{
// if this condition causes actions to be skipped, apply 
the condition

return ( [self canCancelAction] ? [self test] : NO );
}

- (BOOL)shouldHoldAction
{
// if this condition causes actions to be held, apply the condition
return ( [self canHoldAction] ? [self test] : NO );
}

- (BOOL)shouldStopAction
{
// If this condition causes actions to abort, apply the condition
return ( [self canStopAction] ? [self test] : NO );
}

@end

@implementation ActionItem

...

static ActionCondition* FindCondition( NSArray* conditions, SEL 
conditionSelector )

{
// Returns first ActionCondition that returns YES from the 
given condition message

NSEnumerator* e = [conditions objectEnumerator];
ActionCondition* condition;
while ( (condition=[e nextObject]) != nil )
{
if ([condition performSelector:conditionSelector]!=NO)  
--- sometimes returns something other than 0 or 1

return (condition);
}
return (nil);
}

- (ActionCondition*)cancelCondition
{
return (FindCondition([self conditions],@selector(shouldCancelAction)));
}

- (ActionCondition*)holdCondition
{
return (FindCondition([self conditions],@selector(shouldHoldAction)));
}

- (ActionCondition*)stopCondition
{
return (FindCondition([self conditions],@selector(shouldStopAction)));
}

@end


--
James Bucanek

___

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: Printing and Segmented Control state [Solved]

2010-06-08 Thread James Merkel
Ok, should have known this -- the print version of the view is a  
separate instance of the view from the screen version, and the print  
version doesn't have the segmented control. So I have to get the state  
of the control from the screen version and set it into the print  
version so I can print out the correct string.


Jim Merkel

On Jun 7, 2010, at 10:28 PM, James Merkel wrote:

I have a view that has among other things a segmented control. In  
the printing code I want to print a string that represents the  
current state of the segmented control. However, whenever I query  
the segmented control with -selectedSegment in the print code, I get  
a value of 0. On the other hand, if I'm drawing the same view to the  
screen I get the correct index when I query for the selected  
segment. Has anyone run into this problem and found a work-around?


Thanks in advance.

Jim Merkel


___

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: BOOL returned via -performSelctor: not BOOL on 64-bit system

2010-06-08 Thread Nick Zitzmann

On Jun 8, 2010, at 10:16 AM, James Bucanek wrote:

 I've been trying to track down a peculiar bug reported by a customer, and 
 I've narrowed it down to a problem returning a BOOL value via -[NSObject 
 performSelector:] on a dual Quad-Core Intel Xeon processor running 64-bit 
 code. It seems that the returned value contains random data, which obscures 
 the BOOL.
 
 I've included the relevant code from the project below for completeness, but 
 the problem boils down to this statement:
 
if ([condition performSelector:conditionSelector]!=NO)

According to the documentation, that method returns an object, not a primitive. 
You can't use it if the selector returns a primitive; it doesn't work that way. 
If you want to call some selector and get a BOOL return value, then you must do 
this instead:

BOOL returnValue = ((BOOL (*)(id, SEL))objc_msgSend)(condition, 
conditionSelector);

This, incidentally, works for all primitives except for some floating point 
primitives, where you may have to use objc_msgSend_fpret() instead depending on 
the rules of your architecture.

 I thought that, in Objective-C, all pointer and integer scalar values were 
 interchangeable in the return value of a method.

You thought wrong.

Nick Zitzmann
http://www.chronosnet.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


QuickTime web browser plugin - get current timecode

2010-06-08 Thread Paweł Kostecki

Hi all,

Is there any possibility of getting a current timecode of a QuickTime 
video played on a web page (in QT plugin)?


I mean a possibility similar to desktop [qtMovie currentTime] in Cocoa.

What I need to do is to get a current slider timecode of a video played 
in QT plugin within a web browser (eg. Safari).


There's a QT browser plugin attribute STARTTIME, but this is an input 
attribute. I need something similar but for the output from the plugin 
(so I can read it eg. with JavaScript and know at which frame the video 
is currently).


I'm afraid that's not possible, but if anyone has a clue how to do it, 
I'd be really grateful.


Thanks a lot

--
Paweł Kostecki

e-mail: pkoste...@power.com.pl

Power Media S.A.
ul. Kiełbaśnicza 24
50-110 Wrocław, Poland
tel.: +48 71 341 06 96
fax: +48 71 321 00 16

http://www.power.com.pl

Registered in the District Court for Wrocław-Fabryczna
KRS: 281947
NIP (tax ID): PL-898-16-47-572
Capital stock: 640,000 PLN (fully paid-up)
___

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: QuickTime web browser plugin - get current timecode

2010-06-08 Thread Jean-Daniel Dupas

Le 8 juin 2010 à 17:45, Paweł Kostecki a écrit :

 Hi all,
 
 Is there any possibility of getting a current timecode of a QuickTime video 
 played on a web page (in QT plugin)?
 
 I mean a possibility similar to desktop [qtMovie currentTime] in Cocoa.
 
 What I need to do is to get a current slider timecode of a video played in QT 
 plugin within a web browser (eg. Safari).
 
 There's a QT browser plugin attribute STARTTIME, but this is an input 
 attribute. I need something similar but for the output from the plugin (so I 
 can read it eg. with JavaScript and know at which frame the video is 
 currently).
 
 I'm afraid that's not possible, but if anyone has a clue how to do it, I'd be 
 really grateful.


http://developer.apple.com/Mac/library/documentation/QuickTime/Conceptual/QTScripting_JavaScript/aQTScripting_Javascro_AIntro/Introduction%20to%20JavaScript%20QT.html

int GetTime(): Get the current time of a movie.



___

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: 32bit float array to PNG thanks to NSBitmapImageRep problem

2010-06-08 Thread Greg Guerin

Pierre-Yves Aquilanti wrote:

NSData * binaryData=[NSData dataWithContentsOfFile:binaryPath]; // 
binary is

just a 32bits array full of 1500. and 3000. as described previously



Does the endian-ness of the floats in the file match the endian-ness  
of the processor the code is running on?


Also, in the NSCalibratedWhiteColorSpace, white is 1.0, black is 0.0,  
and grays all lie in the normalized range 0.0 thru 1.0.  So 1500 and  
3000 are whiter than white and will undoubtedly be truncated to  
white (1.0).


It's unclear to me what the white value is in your 1500 and 3000  
values, but if 3000 is white, then you need to divide your raw data  
by 3000 to get it into normalized range.


  -- GG

___

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: [iPhone] Preprocessing events sent to UITableView

2010-06-08 Thread WT
Fair enough.

The app I'm writing is a newspaper-like app, similar to The New York Times app. 
The client for whom I'm writing this app wants the reader to be able to swipe 
horizontally to switch sections (say, from latest news to sports to 
entertainment, etc). Each section has its own view controller, all of which 
manage a shared view. That view is part of a larger view which contains, among 
other things, a scrollable list of section buttons. That larger view, of 
course, has its own view controller.

The reader can tap on a section button and the contents of that section get 
dumped into the tableview but the client also wants the user to be able to 
swipe horizontally to switch sections. Naturally, the view controller for a 
section is not the appropriate place to manage the swipe since it involves 
knowledge about other sections. So, I need to intercept the touch events 
received by the table view, pass them a couple of levels up to the view 
controller of the larger view, do the analysis to figure out whether to swipe 
or allow the table to scroll, then pass the events back down to the table if 
the user intended to scroll vertically.

The solution I indicated works fine, but I don't think it's very elegant. 
Personally, I think swiping to change sections is a bad idea, but that's not my 
call to make.

On Jun 6, 2010, at 4:30 PM, David Duncan wrote:

 On Jun 6, 2010, at 1:41 AM, WT wrote:
 
 Yes, I'm aware of that recommendation. I think that's precisely the core of 
 my question, namely, how to do what I need to do in the safest possible way.
 
 
 I think you need to tell us what the goal you are trying to achieve is, 
 rather than asking how to do it the way you think you should. Then perhaps 
 someone can recommend a better solution.
 --
 David Duncan
 Apple DTS Animation and Printing

On Jun 6, 2010, at 4:37 PM, Matt Neuburg wrote:

 On Sun, 6 Jun 2010 10:41:41 +0200, WT jrca...@gmail.com said:
 
 question, namely, how to do what I need to do in the safest possible way. I
 found a solution, but I don't think it's very elegant
 
 Sorry if I'm being dense, but did we establish what you *do* need to do? I
 didn't grasp why you're jumping through all these hoops in the first place.
 Just curious... Thx. m.
___

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: [iPhone] Preprocessing events sent to UITableView

2010-06-08 Thread Matt Neuburg
On or about 6/8/10 9:42 AM, thus spake WT jrca...@gmail.com:

 The reader can tap on a section button and the contents of that section get
 dumped into the tableview but the client also wants the user to be able to
 swipe horizontally to switch sections. Naturally, the view controller for a
 section is not the appropriate place to manage the swipe since it involves
 knowledge about other sections. So, I need to intercept the touch events
 received by the table view, pass them a couple of levels up to the view
 controller of the larger view, do the analysis to figure out whether to swipe
 or allow the table to scroll, then pass the events back down to the table if
 the user intended to scroll vertically.

Well, of course I could be wrong, but to me this sounds like a reason to
override sendEvent:. m.

-- 
matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf
AppleScript: the Definitive Guide, 2nd edition
http://www.tidbits.com/matt/default.html#applescriptthings
Take Control of Exploring  Customizing Snow Leopard
http://tinyurl.com/kufyy8
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.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: Erasing drawn content

2010-06-08 Thread Kyle Sluder
On Jun 8, 2010, at 8:41 AM, Matej Bukovinski ma...@bukovinski.com  
wrote:



Thanks for the suggestion Steve.

Unfortunately this causes the background to turn black and not  
transparent. I would need the view to become transparent (so the  
WebView underneath is visible).


You can't do this. All your bees are composited back-to-front into the  
window's backing store, so filling with anything will obliterate your  
web view's drawing.


What you need to do is draw the correct stuff in -drawRect:, and  
invalidate the proper regions using -setNeedsDisplayInRect: in  
response to changes in your web view.


--Kyle Sluder
(Sent from the line for Pacific Heights at WWDC)
___

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: Erasing drawn content

2010-06-08 Thread Kyle Sluder

On Jun 8, 2010, at 10:03 AM, Kyle Sluder kyle.slu...@gmail.com wrote:

You can't do this. All your bees are composited back-to-front into  
the window's backing store, so filling with anything will obliterate  
your web view's drawing.


Of course by bees, I meant views.

--Kyle Sluder
(Still on line for Pacific Heights at WWDC)
___

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


CocoaHeads-NYC date change: *tomorrow*

2010-06-08 Thread Andy Lee
The CocoaHeads-NYC meeting this month will be on *WEDNESDAY* June 9 (tomorrow) 
rather than the usual Thursday.

We don't have a speaker this month, so we'll just chat about WWDC and head for 
burgers early.  I encourage you to bring questions and/or code if there's 
something you want to show off, or if you have a stubborn bug you'd like help 
with.

--Andy

___

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

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

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

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


Re: [iPhone] NSManagedObjectContext save doesn't crash but breaks on objc_exception_throw

2010-06-08 Thread Hank Heijink (Mailinglists)
There's no error or log at all, unless I set the merge policy to the default, 
in which case the error parameter contains what I expect it to contain: a 
conflict list with the right objects and properties that I expect to be in 
conflict. I understand the error coming back from the save, but not the call to 
objc_exception_throw.

In case it matters, this is on iPhone OS 3.1.3, Xcode 3.2.2.

Thanks,
Hank

On Jun 8, 2010, at 12:08 PM, Alexander Spohr wrote:

 Is there anything in the log?
 What does save's error parameter return?
 
   atze
 
 
 Am 08.06.2010 um 17:53 schrieb Hank Heijink (Mailinglists):
 
 Dear all,
 
 I've run into the following problem, and I'm a bit stuck - I wonder if you 
 can shed some light on this. I have an iPhone app that uses Core Data, and 
 the problem occurs when the app terminates. I have an NSOperationQueue with 
 potentially several NSOperations that are cancelled in the 
 applicationWillTerminate: UIApplication delegate method.
 
 These NSOperations all have their own copy of an NSManagedObjectContext and 
 an NSManagedObject subclass (I pass them the persistent store coordinator 
 and an NSManagedObjectID that is permanent at that point).
 
 Canceling the NSOperation changes an attribute of the NSManagedObject 
 subclass and I save the NSManagedObjectContext on the background thread 
 after this change is made. This means that the NSManagedObjectContext on the 
 main thread is now in conflict, and since all this happens in 
 applicationWillTerminate:, it won't receive the 
 NSManagedObjectContextDidSaveNotification so it can deal with it.
 
 My solution to this is to set the merge policy to 
 NSMergeByPropertyStoreTrumpMergePolicy right before saving the main 
 NSManagedObjectContext to give precedence to the already-saved context(s). I 
 haven't been able to find any information about this scenario - the Core 
 Data Programming Guide (in Communicating Changes Between Contexts) seems to 
 suggest my approach (case 3b), although there in-memory changes are 
 preferred over store changes.
 
 I always have a break point set on objc_exception_throw, and it hits this 
 breakpoint in the call to save. This is the stack backtrace:
 
 #0  0x986d94e6 in objc_exception_throw ()
 #1  0x01dee37c in -[NSPersistentStoreCoordinator(_NSInternalMethods) 
 executeRequest:withContext:] ()
 #2  0x01e22afe in -[NSManagedObjectContext save:] ()
 #3  0x36b6 in -[MyAppDelegate applicationWillTerminate:]
 ...snip...
 
 However, if I remove the break point or hit continue, the application quits 
 with an exit code of 0. If I wrap my [NSManagedObjectContext save] call in a 
 @try @catch block, the @catch statements are never executed. So, is there an 
 exception or isn't there? Should I rethink my approach? I'm just not sure 
 what the issue is here.
 
 Any information is greatly appreciated!
 
 Thanks in advance,
 Hank___
 
 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/atze%40freeport.de
 
 This email sent to a...@freeport.de
 
 

___

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


Having trouble with eventWithUID:occurrence: CalCalendarStore method

2010-06-08 Thread Mazen M. Abdel-Rahman
Hi All,

The eventWithUID:occurrence: method of CalCalendarStore is not working for me 
as expected when retrieving a recurring event.  I am not sure if there is a 
disconnect between the documentation and the CalCalendarStore documentation or 
if perhaps there is something I am not seeing.

According to the documentation for the return value:

A CalEvent object that matches the specified unique identifier and date. 
Returns nil if the event is not found, or the event is recurring and date is 
not specified.


However - I am always getting back the first event of a recurring series if I 
give it the uid of a recurring event with out a date.  I am not getting back 
nil as I should be according to the documentation.

Here is some simple test code:

CalCalendarStore * calStore = [CalCalendarStore defaultCalendarStore];

NSDate * today = [NSDate date];
NSDate * start = [today dateByAddingTimeInterval:(60*60*24)];
NSDate * end = [today dateByAddingTimeInterval:(60*60*28)];


NSPredicate * predicate = [CalCalendarStore 
eventPredicateWithStartDate:start endDate:end calendars:[calStore calendars]];

NSArray * events = [calStore eventsWithPredicate:predicate];

CalEvent * event = [events objectAtIndex:0];

NSString * title = [event title];
NSString * uid = [event uid];
NSLog(@%@ %@, title, uid);


CalEvent * eventWithUID = nil;
eventWithUID = [calStore eventWithUID:uid occurrence:nil];

NSLog(@Event is %@, eventWithUID);


In my case I am retrieving exactly one event of a recurring series.   
eventWithUID should be null - but it is not.  Is anyone familiar with this 
problem - and is this already a documented issue?  Or has my brain frozen over 
and perhaps there's something I'm not seeing or understanding properly?

Thanks!
Mazen Abdel-Rahman
___

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: BOOL returned via -performSelctor: not BOOL on 64-bit system

2010-06-08 Thread James Bucanek
Nick Zitzmann mailto:n...@chronosnet.com wrote (Tuesday, June 
8, 2010 9:27 AM -0600):



On Jun 8, 2010, at 10:16 AM, James Bucanek wrote:


I've been trying to track down a peculiar bug reported by a customer, and I've 
narrowed it down to a problem returning a BOOL value via
-[NSObject performSelector:] on a dual Quad-Core Intel Xeon 
processor running 64-bit code. It seems that the returned value 
contains random data, which obscures the BOOL.


I've included the relevant code from the project below for completeness, but 
the problem boils down to this statement:

if ([condition performSelector:conditionSelector]!=NO)


According to the documentation, that method returns an object, 
not a primitive. You can't use it if the selector returns a 
primitive; it doesn't work that way. If you want to call some 
selector and get a BOOL return value, then you must do this instead:


BOOL returnValue = ((BOOL (*)(id, SEL))objc_msgSend)(condition, 
conditionSelector);


For the record, the following is equivalent (i.e. produces the 
same machine code) and is probably a little easier to read:


BOOL returnValue = (BOOL)((uintptr_t)[condition 
performSelector:conditionSelector]);


This, incidentally, works for all primitives except for some floating point
primitives, where you may have to use objc_msgSend_fpret() instead depending
on the rules of your architecture.


Thanks for getting me back on track. I see now that the BOOL 
return value is just fine--as long as you convince the compiler 
to only pay attention to the BOOL (char) part of the return 
value. Casting the return as a BOOL type and/or assigning it to 
a BOOL value is sufficient to avoid any detritus.



I thought that, in Objective-C, all pointer and integer scalar values were
interchangeable in the return value of a method.


You thought wrong.


Thanks. I think. :/

I realize now that I was thinking about the rules for nil 
objects; objc_msgSend guarantees that the value returned when 
sending to a nil object is compatible with all pointer, floating 
point, and integer scalar return values. But this clearly can't 
be extrapolated to the general case of -performSelector:.


--
James Bucanek

___

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: Erasing drawn content

2010-06-08 Thread Matej Bukovinski
Sadly this also turns the background black just like a NSCompositeClear fill 
operation. 

On 8.6.2010, at 17:56, Paul Sanders wrote:

  Unfortunately this causes the background to turn black and not transparent. 
  I would need the view to become transparent
  (so the WebView underneath is visible).
  
 Try this:
  
 [[NSColor clearColor] setFill];
 NSRectFill (myRect);
  
 That's what I do.
  
 Regards,
  
 Paul Sanders



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: BOOL returned via -performSelctor: not BOOL on 64-bit system

2010-06-08 Thread Jean-Daniel Dupas

Le 8 juin 2010 à 19:23, James Bucanek a écrit :

 Nick Zitzmann mailto:n...@chronosnet.com wrote (Tuesday, June 8, 2010 9:27 
 AM -0600):
 
 On Jun 8, 2010, at 10:16 AM, James Bucanek wrote:
 
 I've been trying to track down a peculiar bug reported by a customer, and 
 I've narrowed it down to a problem returning a BOOL value via
 -[NSObject performSelector:] on a dual Quad-Core Intel Xeon processor 
 running 64-bit code. It seems that the returned value contains random data, 
 which obscures the BOOL.
 
 I've included the relevant code from the project below for completeness, 
 but the problem boils down to this statement:
 
 if ([condition performSelector:conditionSelector]!=NO)
 
 According to the documentation, that method returns an object, not a 
 primitive. You can't use it if the selector returns a primitive; it doesn't 
 work that way. If you want to call some selector and get a BOOL return 
 value, then you must do this instead:
 
 BOOL returnValue = ((BOOL (*)(id, SEL))objc_msgSend)(condition, 
 conditionSelector);
 
 For the record, the following is equivalent (i.e. produces the same machine 
 code) and is probably a little easier to read:
 
BOOL returnValue = (BOOL)((uintptr_t)[condition 
 performSelector:conditionSelector]);

It's not more valid though. -performSelector must be used only with selector 
that return an object.

From the -performSelector reference:

For methods that return anything other than an object, use NSInvocation.


-- Jean-Daniel




___

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

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

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

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


Re: [iPhone] NSManagedObjectContext save doesn't crash but breaks on objc_exception_throw

2010-06-08 Thread Hank Heijink (Mailinglists)
On Jun 8, 2010, at 1:24 PM, David Brown wrote:

 Have you thought about avoiding the problem altogether?
 
 Instead of marking the objects and then needed to save them, write out a file 
 somewhere that identifies those objects, outside of core data.
 
 Then, when your app is starting, check for the presence of the file before 
 anything else happens, and take whatever actions you need to take to resume 
 the processing.

That's certainly a possible workaround. Core Data should be able to handle this 
though. When I relaunch my app, all the changes did propagate properly. 
Everything works in the Distribution build without warnings, errors, etc. It's 
just that objc_exception_throw gets called, and I'm wondering why. Is it a 
symptom of an unrelated problem that I'm not understanding yet, is it a bug in 
Core Data, or should I just not worry about it?

Hank

 Am 08.06.2010 um 17:53 schrieb Hank Heijink (Mailinglists):
 
 Dear all,
 
 I've run into the following problem, and I'm a bit stuck - I wonder if you 
 can shed some light on this. I have an iPhone app that uses Core Data, and 
 the problem occurs when the app terminates. I have an NSOperationQueue 
 with potentially several NSOperations that are cancelled in the 
 applicationWillTerminate: UIApplication delegate method.
 
 These NSOperations all have their own copy of an NSManagedObjectContext 
 and an NSManagedObject subclass (I pass them the persistent store 
 coordinator and an NSManagedObjectID that is permanent at that point).
 
 Canceling the NSOperation changes an attribute of the NSManagedObject 
 subclass and I save the NSManagedObjectContext on the background thread 
 after this change is made. This means that the NSManagedObjectContext on 
 the main thread is now in conflict, and since all this happens in 
 applicationWillTerminate:, it won't receive the 
 NSManagedObjectContextDidSaveNotification so it can deal with it.
 
 My solution to this is to set the merge policy to 
 NSMergeByPropertyStoreTrumpMergePolicy right before saving the main 
 NSManagedObjectContext to give precedence to the already-saved context(s). 
 I haven't been able to find any information about this scenario - the Core 
 Data Programming Guide (in Communicating Changes Between Contexts) seems 
 to suggest my approach (case 3b), although there in-memory changes are 
 preferred over store changes.
 
 I always have a break point set on objc_exception_throw, and it hits this 
 breakpoint in the call to save. This is the stack backtrace:
 
 #0  0x986d94e6 in objc_exception_throw ()
 #1  0x01dee37c in -[NSPersistentStoreCoordinator(_NSInternalMethods) 
 executeRequest:withContext:] ()
 #2  0x01e22afe in -[NSManagedObjectContext save:] ()
 #3  0x36b6 in -[MyAppDelegate applicationWillTerminate:]
 ...snip...
 
 However, if I remove the break point or hit continue, the application 
 quits with an exit code of 0. If I wrap my [NSManagedObjectContext save] 
 call in a @try @catch block, the @catch statements are never executed. So, 
 is there an exception or isn't there? Should I rethink my approach? I'm 
 just not sure what the issue is here.
 
 Any information is greatly appreciated!
 
 Thanks in advance,
 Hank___
 
 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/atze%40freeport.de
 
 This email sent to a...@freeport.de
 
 
 
 ___
 
 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/ddb%40bithead.net
 
 This email sent to d...@bithead.net
 
 

___

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

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

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

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


Re: Erasing drawn content

2010-06-08 Thread Matej Bukovinski
Thanks Kyle.

Drawing only the portions that won't be covered by a smaller rectangle is the 
obvious solution to this problem but unfortunately one that requires a lot of 
drawing logic (especially when you can have several nested rectangles). I was 
hoping there exists a more elegant way of achieving this. It would have saved 
me a lot of math. 

Have a great time at the WWDC. 

 What you need to do is draw the correct stuff in -drawRect:, and invalidate 
 the proper regions using -setNeedsDisplayInRect: in response to changes in 
 your web view.



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: BOOL returned via -performSelctor: not BOOL on 64-bit system

2010-06-08 Thread Alexander Heinz
On Jun 8, 2010, at 1:37 PM, Jean-Daniel Dupas wrote:
 
 Le 8 juin 2010 à 19:23, James Bucanek a écrit :
 
 Nick Zitzmann mailto:n...@chronosnet.com wrote (Tuesday, June 8, 2010 9:27 
 AM -0600):
 
 On Jun 8, 2010, at 10:16 AM, James Bucanek wrote:
 
 I've been trying to track down a peculiar bug reported by a customer, and 
 I've narrowed it down to a problem returning a BOOL value via
 -[NSObject performSelector:] on a dual Quad-Core Intel Xeon processor 
 running 64-bit code. It seems that the returned value contains random data, 
 which obscures the BOOL.
 
 I've included the relevant code from the project below for completeness, 
 but the problem boils down to this statement:
 
 if ([condition performSelector:conditionSelector]!=NO)
 
 According to the documentation, that method returns an object, not a 
 primitive. You can't use it if the selector returns a primitive; it doesn't 
 work that way. If you want to call some selector and get a BOOL return 
 value, then you must do this instead:
 
 BOOL returnValue = ((BOOL (*)(id, SEL))objc_msgSend)(condition, 
 conditionSelector);
 
 For the record, the following is equivalent (i.e. produces the same machine 
 code) and is probably a little easier to read:
 
  BOOL returnValue = (BOOL)((uintptr_t)[condition 
 performSelector:conditionSelector]);
 
 It's not more valid though. -performSelector must be used only with selector 
 that return an object.
 
 From the -performSelector reference:
 
 For methods that return anything other than an object, use NSInvocation.

Alternatively, if you can alter the method being called, (which I assume you 
can, since you posted the source) you could change the methods to return an 
NSNumber-wrapped boolean value, rather than a scalar value. 
(Standard written-in-Mail warning applies)

 - (NSNumber*)shouldCancelAction
 {
   // if this condition causes actions to be skipped, apply the condition
   return [NSNumber numberWithBool:( [self canCancelAction] ? [self test] : NO 
 )];
 }
 
 - (NSNumber*)shouldHoldAction
 {
   // if this condition causes actions to be held, apply the condition
   return [NSNumber numberWithBool:( [self canHoldAction] ? [self test] : NO 
 )];
 }
 
 - (NSNumber*)shouldStopAction
 {
   // If this condition causes actions to abort, apply the condition
   return [NSNumber numberWithBool:( [self canStopAction] ? [self test] : NO 
 )];
 }

And the conditional statements change to the form:

 if (![[condition performSelector:conditionSelector] boolValue])

This is certainly the least performant of the recommended solutions, but if 
that's not a major concern, this would be my preferred way, since I think it's 
the easiest to read.

- Alex___

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: Erasing drawn content

2010-06-08 Thread Paul Sanders
On Jun 8, 2010, at 10:03 AM, Kyle Sluder kyle.slu...@gmail.com wrote:

 You can't do this. All your views are composited back-to-front into  
 the window's backing store, so filling with anything will obliterate  
 your web view's drawing.

Of course, silly me.  Can something be done with a layer-backed view here, used 
as some kind of overlay?  Alternatively, one could position a borderless window 
over the WebView and draw your rectangles into that.  This window can be made 
initially transparent by:
  - calling setOpaque: NO on the window
  - having the content view return isOpaque as YES
  - filling the content view with clearColor

Then draw your rectangles in the content view of this window and the NSRectFill 
trick should work.

Regards,

Paul Sanders.
___

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: BOOL returned via -performSelctor: not BOOL on 64-bit system

2010-06-08 Thread James Bucanek
Jean-Daniel Dupas mailto:devli...@shadowlab.org wrote 
(Tuesday, June 8, 2010 10:37 AM +0200):



Le 8 juin 2010 à 19:23, James Bucanek a écrit :



For the record, the following is equivalent (i.e. produces the same machine 
code) and is probably a little easier to read:

BOOL returnValue = (BOOL)((uintptr_t)[condition 
performSelector:conditionSelector]);


It's not more valid though. -performSelector must be used only with selector 
that return an object.

From the -performSelector reference:

For methods that return anything other than an object, use NSInvocation.


I concede that you're technically correct. But pragmatically, 
the CPU register used to return integer and pointer values to 
the caller has always been the same register for both Motorola 
and Intel processors since as long as I can remember programming 
in C -- and that's been awhile.


--
James Bucanek

___

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: BOOL returned via -performSelctor: not BOOL on 64-bit system

2010-06-08 Thread Jean-Daniel Dupas

Le 8 juin 2010 à 19:52, Alexander Heinz a écrit :

 On Jun 8, 2010, at 1:37 PM, Jean-Daniel Dupas wrote:
 
 Le 8 juin 2010 à 19:23, James Bucanek a écrit :
 
 Nick Zitzmann mailto:n...@chronosnet.com wrote (Tuesday, June 8, 2010 
 9:27 AM -0600):
 
 On Jun 8, 2010, at 10:16 AM, James Bucanek wrote:
 
 I've been trying to track down a peculiar bug reported by a customer, and 
 I've narrowed it down to a problem returning a BOOL value via
 -[NSObject performSelector:] on a dual Quad-Core Intel Xeon processor 
 running 64-bit code. It seems that the returned value contains random 
 data, which obscures the BOOL.
 
 I've included the relevant code from the project below for completeness, 
 but the problem boils down to this statement:
 
 if ([condition performSelector:conditionSelector]!=NO)
 
 According to the documentation, that method returns an object, not a 
 primitive. You can't use it if the selector returns a primitive; it 
 doesn't work that way. If you want to call some selector and get a BOOL 
 return value, then you must do this instead:
 
 BOOL returnValue = ((BOOL (*)(id, SEL))objc_msgSend)(condition, 
 conditionSelector);
 
 For the record, the following is equivalent (i.e. produces the same machine 
 code) and is probably a little easier to read:
 
  BOOL returnValue = (BOOL)((uintptr_t)[condition 
 performSelector:conditionSelector]);
 
 It's not more valid though. -performSelector must be used only with selector 
 that return an object.
 
 From the -performSelector reference:
 
 For methods that return anything other than an object, use NSInvocation.
 
 Alternatively, if you can alter the method being called, (which I assume you 
 can, since you posted the source) you could change the methods to return an 
 NSNumber-wrapped boolean value, rather than a scalar value. 
 (Standard written-in-Mail warning applies)
 
 - (NSNumber*)shouldCancelAction
 {
   // if this condition causes actions to be skipped, apply the condition
   return [NSNumber numberWithBool:( [self canCancelAction] ? [self test] : 
 NO )];
 }
 
 - (NSNumber*)shouldHoldAction
 {
   // if this condition causes actions to be held, apply the condition
   return [NSNumber numberWithBool:( [self canHoldAction] ? [self test] : NO 
 )];
 }
 
 - (NSNumber*)shouldStopAction
 {
   // If this condition causes actions to abort, apply the condition
   return [NSNumber numberWithBool:( [self canStopAction] ? [self test] : NO 
 )];
 }
 
 And the conditional statements change to the form:
 
 if (![[condition performSelector:conditionSelector] boolValue])
 
 This is certainly the least performant of the recommended solutions, but if 
 that's not a major concern, this would be my preferred way, since I think 
 it's the easiest to read.
 
 - Alex

Don't assume without benchmarking. 
NSInvocation is quite more heavyweight than boxing boolean into NSNumber 
objects (especially when you know that commonly used NSNumber are cached and 
not reallocated each time).
In fact, this code is this is a nice and efficient way to workaround the 
perform selector limitation.

-- Jean-Daniel






___

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

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

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

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


Re: BOOL returned via -performSelctor: not BOOL on 64-bit system

2010-06-08 Thread James Bucanek
Alexander Heinz mailto:ahei...@johnshopkins.edu wrote 
(Tuesday, June 8, 2010 10:53 AM -0400):


Alternatively, if you can alter the method being called, (which I assume you
can, since you posted the source) you could change the methods to return an
NSNumber-wrapped boolean value, rather than a scalar value. (Standard
written-in-Mail warning applies)


Alexander,

That's an excellent suggestion and I think I'll adopt it (or 
something close to it).


I don't want to rewrite the shouldCancelAction, 
shouldHoldActions, etc. because those get call from a lot of 
other places and having them return NSNumber would be awkward. 
But a separate wrapper method that tests the same condition and 
returns it as an NSNumber would fix this nicely.


Thanks,

James

--
James Bucanek

___

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: Erasing drawn content

2010-06-08 Thread Matej Bukovinski
Could you perhaps elaborate a bit how you think that a layer backed view could 
help?

The window overlay sounds like it could work. Hoverer, a NSView overlay would 
be preferred since I'm inserting the overlay in the WebView's scroll view (and 
matching the documents view size via bounds change notifications). This works 
very well when scrolling both the web and overlay view at the same time (and is 
also efficient). 


 
 Of course, silly me.  Can something be done with a layer-backed view here, 
 used as some kind of overlay?  Alternatively, one could position a borderless 
 window over the WebView and draw your rectangles into that.  This window can 
 be made initially transparent by:
  - calling setOpaque: NO on the window
  - having the content view return isOpaque as YES
  - filling the content view with clearColor
 
 Then draw your rectangles in the content view of this window and the 
 NSRectFill trick should work.
 



smime.p7s
Description: S/MIME cryptographic signature
___

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

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

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

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

Re: [iPhone] NSManagedObjectContext save doesn't crash but breaks on objc_exception_throw

2010-06-08 Thread David Brown
Have you thought about avoiding the problem altogether?

Instead of marking the objects and then needed to save them, write out a file 
somewhere that identifies those objects, outside of core data.

Then, when your app is starting, check for the presence of the file before 
anything else happens, and take whatever actions you need to take to resume the 
processing.

On Jun 8, 2010, at 10:16 am PDT, Hank Heijink (Mailinglists) wrote:

 There's no error or log at all, unless I set the merge policy to the default, 
 in which case the error parameter contains what I expect it to contain: a 
 conflict list with the right objects and properties that I expect to be in 
 conflict. I understand the error coming back from the save, but not the call 
 to objc_exception_throw.
 
 In case it matters, this is on iPhone OS 3.1.3, Xcode 3.2.2.
 
 Thanks,
 Hank
 
 On Jun 8, 2010, at 12:08 PM, Alexander Spohr wrote:
 
 Is there anything in the log?
 What does save's error parameter return?
 
  atze
 
 
 Am 08.06.2010 um 17:53 schrieb Hank Heijink (Mailinglists):
 
 Dear all,
 
 I've run into the following problem, and I'm a bit stuck - I wonder if you 
 can shed some light on this. I have an iPhone app that uses Core Data, and 
 the problem occurs when the app terminates. I have an NSOperationQueue with 
 potentially several NSOperations that are cancelled in the 
 applicationWillTerminate: UIApplication delegate method.
 
 These NSOperations all have their own copy of an NSManagedObjectContext and 
 an NSManagedObject subclass (I pass them the persistent store coordinator 
 and an NSManagedObjectID that is permanent at that point).
 
 Canceling the NSOperation changes an attribute of the NSManagedObject 
 subclass and I save the NSManagedObjectContext on the background thread 
 after this change is made. This means that the NSManagedObjectContext on 
 the main thread is now in conflict, and since all this happens in 
 applicationWillTerminate:, it won't receive the 
 NSManagedObjectContextDidSaveNotification so it can deal with it.
 
 My solution to this is to set the merge policy to 
 NSMergeByPropertyStoreTrumpMergePolicy right before saving the main 
 NSManagedObjectContext to give precedence to the already-saved context(s). 
 I haven't been able to find any information about this scenario - the Core 
 Data Programming Guide (in Communicating Changes Between Contexts) seems to 
 suggest my approach (case 3b), although there in-memory changes are 
 preferred over store changes.
 
 I always have a break point set on objc_exception_throw, and it hits this 
 breakpoint in the call to save. This is the stack backtrace:
 
 #0  0x986d94e6 in objc_exception_throw ()
 #1  0x01dee37c in -[NSPersistentStoreCoordinator(_NSInternalMethods) 
 executeRequest:withContext:] ()
 #2  0x01e22afe in -[NSManagedObjectContext save:] ()
 #3  0x36b6 in -[MyAppDelegate applicationWillTerminate:]
 ...snip...
 
 However, if I remove the break point or hit continue, the application quits 
 with an exit code of 0. If I wrap my [NSManagedObjectContext save] call in 
 a @try @catch block, the @catch statements are never executed. So, is there 
 an exception or isn't there? Should I rethink my approach? I'm just not 
 sure what the issue is here.
 
 Any information is greatly appreciated!
 
 Thanks in advance,
 Hank___
 
 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/atze%40freeport.de
 
 This email sent to a...@freeport.de
 
 
 
 ___
 
 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/ddb%40bithead.net
 
 This email sent to d...@bithead.net

___

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

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

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

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


Re: Erasing drawn content

2010-06-08 Thread Kyle Sluder
On Jun 8, 2010, at 2:02 PM, Matej Bukovinski ma...@bukovinski.com wrote:

 Could you perhaps elaborate a bit how you think that a layer backed view 
 could help?

Layers are composed into their own backing stores, so you can accumulate data 
there rather than recalculating it every time you need to repaint.

That said, you would need to use a layer hosting view rather than a layer 
backed view, which might put you at a disadvantage from where you started.

 
 The window overlay sounds like it could work. Hoverer, a NSView overlay would 
 be preferred since I'm inserting the overlay in the WebView's scroll view 
 (and matching the documents view size via bounds change notifications). This 
 works very well when scrolling both the web and overlay view at the same time 
 (and is also efficient). 

I don't believe you're actually allowed to mess with the web view's scroll view 
hierarchy; the web view comes with a prepackaged scroll view, unlike say 
NSTextView.

It sounds like the overlay window is the best bet.

--Kyle Sluder
(Sent from WWDC)___

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: BOOL returned via -performSelctor: not BOOL on 64-bit system

2010-06-08 Thread Michael Ash
 I concede that you're technically correct. But pragmatically, the CPU 
 register used to return integer and pointer values to the caller has always 
 been the same register for both Motorola and Intel processors since as long 
 as I can remember programming in C -- and that's been awhile.

No need to have different registers for this to break. For example, an
ABI which merely specified that 8-bit values be returned in the top of
registers instead of the bottom would be enough to sink you. I don't
think anything does this now, but on the other hand your previous code
worked just fine on existing hardware at the time too

Mike
___

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

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

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

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


Re: Erasing drawn content

2010-06-08 Thread Paul Sanders
 The window overlay sounds like it could work. Hoverer, a NSView overlay would 
 be preferred since I'm inserting
 the overlay in the WebView's scroll view (and matching the documents view 
 size via bounds change
 notifications). This works very well when scrolling both the web and overlay 
 view at the same time (and is also
 efficient). 

A layer-backed (or layer-hosted) view matching the bounds of a large web page 
would use a lot of memory (bounds.width * bounds.height * 4 bytes, probably).  
I would handle scrolling in the overlay window yourself by offsetting the 
content view's bounds in the way that a scrollview does for its document view.  
Flipping the view's coordinates might help with the maths.  It looks like 
listening for NSViewBoundsDidChangeNotification will let you track the scroll 
position of the webview and you need only draw those rectanges which are 
visible, of course.

Kyle, I rather liked your stack of 'bees'.

Regards,

Paul Sanders.
___

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: Erasing drawn content

2010-06-08 Thread Paul Sanders
 The window overlay sounds like it could work. Hoverer, a NSView overlay would 
 be preferred since I'm inserting
 the overlay in the WebView's scroll view (and matching the documents view 
 size via bounds change
 notifications). This works very well when scrolling both the web and overlay 
 view at the same time (and is also
 efficient). 


Also, you can probably make your overlay window a child window of the window 
containing the webview.  Then:
  - it will stay on top of it
  - it will move with it

Regards,

Paul Sanders.
___

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: Erasing drawn content

2010-06-08 Thread Quincey Morris
On Jun 8, 2010, at 14:10, Kyle Sluder wrote:

 It sounds like the overlay window is the best bet.

Surely it's easier to do what the OP wanted with a clipping path?

In drawRect: just draw the tint rectangles front-to-back instead of 
back-to-front, and after drawing each one remove the rect's interior from the 
clipping path. No off-screen drawing is needed, nor any complex logic to draw 
all the non-overlapping rectangle pieces separately.


___

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: Erasing drawn content

2010-06-08 Thread Kyle Sluder
On Tue, Jun 8, 2010 at 4:05 PM, Quincey Morris
quinceymor...@earthlink.net wrote:
 On Jun 8, 2010, at 14:10, Kyle Sluder wrote:
 Surely it's easier to do what the OP wanted with a clipping path?

 In drawRect: just draw the tint rectangles front-to-back instead of 
 back-to-front, and after drawing each one remove the rect's interior from the 
 clipping path. No off-screen drawing is needed, nor any complex logic to 
 draw all the non-overlapping rectangle pieces separately.

Except that would still rely on inserting a custom view in the
WebView's private scrollview hierarchy.

--Kyle Sluder
(Waiting for an Apple Engineer in the Cocoa Lab at WWDC)
___

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: SQLite Database 2 distinct database iphone.

2010-06-08 Thread Sandro Noël
Thank you Greg.
Now i know it can be done.
much appreciated!

Sandro.


On 2010-06-07, at 11:46 AM, Greg Reichow wrote:

 
 Greetings.
 
 I'm building a iPhone application which is database driven.
 in that application i've designed it to have two databases.
 One database will be distributed with the application and is meant to be 
 read only.
 the second database is meant to copy items to it for the user's safe keeping.
 
 the reason for this is that the application update will also include a 
 refreshed database
 and as such if i only link to the records it might happen that the record 
 that the user 
 wished to keep would of been purged from the original database.
 
 evidently the structure is quite the same on both, with the exception of 
 some additional fields
 in the user database.
 
 when the application starts it complains that it can not merge the two 
 models.
 i've been looking on the net but found nothing of significance.
 
 is it possible to have two separate database in the same application on the 
 iphone.
 and what are the steps to make it happen.
 
 do i have to duplicate the Core data initialization procedures and maintain 
 2 distinct managed object contexts?
 
 I have a very similar application requirement.  In my case, I am using 2 
 separate persistent stores.   One is the user store located in their 
 documents directory to maintain their unique copy of the database and edits 
 to the provided data.  The second is part of the application bundle.  In this 
 case, I use 2 separate MOC's and migrate data from the app persistent store 
 to the user persistent store.  Using the metadata that can be stored with the 
 persistent stores, I check a version key I create and then if it is 
 different, do a merge of the 2 stores.  See the core data docs for a method 
 for efficiently doing a large comparison and merge.  This has worked quite 
 well and allows for application database updates without messing up any 
 unique changes the user has made to their own earlier copy.  
 
 Doing it this way also protects the user if the application is reloaded.  The 
 user data in the documents directory is backed up and can easily be restored.
 
 As for model changes, if they are simple changes to the model between 
 versions, you may be able to get away with lightweight migration.  It is a 
 simple option to add when loading the persistent store.  
 
 There very well may be a better approach but this has successfully worked for 
 me.
 
 Greg Reichow
 MangoCode

___

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: OK, break it down for me... (question about gzip)

2010-06-08 Thread Graham Cox
Thanks to everyone who chipped in on this one.

I have what I want working using ditto with NSTask. I've hard-coded the launch 
path to /usr/bin/ditto and of course, that works right now. I guess as long as 
that isn't likely to change in 10.7 and was also the same in 10.5 then I'll be 
fine.

I might have a follow-up question about how to keep track of how NSTask is 
getting along using a progress bar, but I'll try and work it out myself first.

thanks, GRaham




On 08/06/2010, at 4:43 PM, Kyle Sluder wrote:

 On Jun 7, 2010, at 11:04 PM, Graham Cox graham@bigpond.com wrote:
 
 I need to be able to make a .gzip file from a FOLDER on my hard disk 
 programatically.
 
 I would use ditto to produce the tarball, because it will produce the same 
 results as the Finder.
 
 --Kyle Sluder
 (Sent from my hotel room at WWDC, where you should be too!)

___

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: Erasing drawn content

2010-06-08 Thread Graham Cox

On 09/06/2010, at 3:06 AM, Kyle Sluder wrote:

 Of course by bees, I meant views.


Pity, I like the idea of more bee-based metaphors in APIs (or Apis). It could 
be known as Bee-OS.

--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


My Custom Framework Is Not Exporting One of My Header Files

2010-06-08 Thread Chris Tracewell
I just made my first private framework a few weeks ago. I took some common 
categories and custom classes I use across projects and put them in my new FW. 
All has been fine until today when I added a new class file to it. I clean and 
build the FW and then build my project that is utilizing the FW and I get an 
error saying there is No such file or directory - referring to my new class 
file in the FW. FWIW, I use #import MyFramework/MyFramework.h in my project 
as it imports all the FW headers - standard protocol.

After I build the FW I look in MyFramework - build - Release - 
MyFramework.framework - Headers and can see the header is indeed missing. I 
know this is the correct directory because I can see MyFramework.framework 
being deleted when I clean the FW target.

 Why would it not be exporting the file? Yes, I added it to the target when I 
created the file.

Thanks for the help


-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: My Custom Framework Is Not Exporting One of My Header Files

2010-06-08 Thread Kiel Gillard
Have you set the scope of the necessary header files to public?

file:///Developer/Documentation/DocSets/com.apple.ADC_Reference_Library.DeveloperTools.docset/Contents/Resources/Documents/documentation/DeveloperTools/Conceptual/XcodeBuildSystem/100-Targets/bs_targets.html

On 09/06/2010, at 11:20 AM, Chris Tracewell wrote:

 I just made my first private framework a few weeks ago. I took some common 
 categories and custom classes I use across projects and put them in my new 
 FW. All has been fine until today when I added a new class file to it. I 
 clean and build the FW and then build my project that is utilizing the FW and 
 I get an error saying there is No such file or directory - referring to my 
 new class file in the FW. FWIW, I use #import MyFramework/MyFramework.h in 
 my project as it imports all the FW headers - standard protocol.
 
 After I build the FW I look in MyFramework - build - Release - 
 MyFramework.framework - Headers and can see the header is indeed missing. I 
 know this is the correct directory because I can see MyFramework.framework 
 being deleted when I clean the FW target.
 
 Why would it not be exporting the file? Yes, I added it to the target when I 
 created the file.
 
 Thanks for the help
 
 
 -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/kiel.gillard%40gmail.com
 
 This email sent to kiel.gill...@gmail.com

___

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

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

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

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


Re: My Custom Framework Is Not Exporting One of My Header Files

2010-06-08 Thread Graham Cox

On 09/06/2010, at 11:20 AM, Chris Tracewell wrote:

 Why would it not be exporting the file? Yes, I added it to the target when I 
 created the file.


Right-click the file in Xcode and set its role to Public.

This necessary step is very obscure and the menu doesn't reflect the currently 
set role. File bugs.

--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


Cocoaheads Lake Forest (92630) meeting, Wed 6/9/2010 at 7 pm on implementing a Cocoa Touch app

2010-06-08 Thread Scott Ellsworth
CocoaHeads Lake Forest will be meeting on the second Wednesday of the month.
 We will be meeting at the Orange County Public Library (El Toro) community
room, 24672 Raymond Way, Lake Forest, CA 92630

Please join us from 7pm to 9pm on Wednesday, 6/9.

We will be finishing up coding our card trading app in real time.

If you are able and willing to speak on OpenCL, Grand Central Dispatch, Core
Animation, Open GL, Mac Open Source, or Cocoa 101 for either iPhone or Mac,
please contact me.

At an upcoming meeting, we will be covering the basics of starting an app
from just after installing the SDK to having the app live.

Thanks go to O'Reilly Media for providing our door prize - a cool book on
astrophotography that I was very tempted to just run off with myself.  :)

Bring your comments, your books, and your bugs, and we will leap right in.

As always, details and the upcoming meeting calendar can be found at the
cocoaheads web site, www.cocoaheads.org.
___

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

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

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

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


Re: Erasing drawn content

2010-06-08 Thread Andy Lee
On Jun 8, 2010, at 8:58 PM, Graham Cox wrote:
 
 On 09/06/2010, at 3:06 AM, Kyle Sluder wrote:
 
 Of course by bees, I meant views.
 
 
 Pity, I like the idea of more bee-based metaphors in APIs (or Apis). It could 
 be known as Bee-OS.

Nice double pun!

--Andy

___

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

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

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

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


get the selection in an NSOutlineView

2010-06-08 Thread Rua Haszard Morris
I have an NSOutlineView which has a single column, and 2 levels of tree - each 
item in the list can have child items but those subitems don't have children.

How can I determine the selected items?

NSTableView -selectedRow returns row indices that change dependent on whether 
parent items are expanded, so that won't do.
I could attempt to keep track of the selection via delegate method 
outlineView:shouldSelectItem: but this seems a bad idea.

Am I missing something? Surely it is possible to ask an NSOutlineView which 
items are selected?

thanks
Rua Haszard Morris.___

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: get the selection in an NSOutlineView

2010-06-08 Thread Graham Cox

On 09/06/2010, at 2:29 PM, Rua Haszard Morris wrote:

 I have an NSOutlineView which has a single column, and 2 levels of tree - 
 each item in the list can have child items but those subitems don't have 
 children.
 
 How can I determine the selected items?


-selectedRowIndexes


 
 NSTableView -selectedRow returns row indices that change dependent on whether 
 parent items are expanded, so that won't do.
 I could attempt to keep track of the selection via delegate method 
 outlineView:shouldSelectItem: but this seems a bad idea.
 
 Am I missing something? Surely it is possible to ask an NSOutlineView which 
 items are selected?


Yes, as above. But bear in mind that the row index has a dynamic relationship 
with the indexes of items in your data model, because the user can expand and 
collapse items at will. At the time you call -selectedRowIndexes, you should 
then extract the items corresponding to those indexes from your data model 
(e.g. using [NSArray objectsAtIndexes:]) before the user has a chance to change 
the arrangement.

It's also usual to track the selection as it changes in the delegate using the 
-outlineViewSelectionDidChange: method. You can also get the item associated 
with a row using [NSOutlineView itemForRow:]

--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


Invalid exception being thrown: CIUnsharpMask is not kvc for the key inputIntensity - except that it is

2010-06-08 Thread Mark Aufflick
Hi all,

So I have a property, unsharpMaskFilter, setup in init like so:

CIFilter *filter = [CIFilter filterWithName:@CIUnsharpMask];
[filter setDefaults];
[filter setValue:[NSNumber numberWithFloat:0.1]
forKey:@inputIntensity];
[filter setValue:[NSNumber numberWithFloat:0.2] forKey:@inputRadius];

NSLog(@filter:%@ ii:%@ ir:%@, filter, [filter
valueForKey:@inputIntensity], [filter valueForKey:@inputRadius]);
self.unsharpMaskFilter = filter;

the NSLog line shows that we can call valueForKey on inputIntensity,
but when it is assigned to the property, bindings in the xib kick in
(there's a slider and a text field whose value is bound to
unsharpMaskFilter.inputIntensity) and I get the following exception:

*** Terminating app due to uncaught exception
'NSUnknownKeyException', reason: '[CIUnsharpMask 0x2000648c0
valueForUndefinedKey:]: this class is not key value coding-compliant
for the key inputIntensity.'

What on earth is going on here? The very line before the exception is
triggered we successfully call [filter valueForKey:@inputIntensity].
I feel like I've tried everything including rebuilding a brand new xib
from scratch with nothing but a single text field.

A fresh idea would be welcomed!

Cheers,

Mark.

-- 
Mark Aufflick
  http://mark.aufflick.com/about/contact
___

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