Lake Forest Cocoaheads meeting 8/11, no set topic - come drive the discussion!

2010-08-10 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, 8/11.

Due to an unexpected commitment on my part, we will be having a social
meeting with no set topic.  This is your chance to grab the mic and drive
the meeting!

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.

Thanks go to O'Reilly Media for providing our door prize.  (Let me know who
wins, and I will be bring it for the Sep. meeting.)

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


Updating timestamp on save => merge error

2010-08-10 Thread Gideon King
I have a managed object I want to update with a "last saved timestamp" on save. 
I have the update done on the NSPersistentDocument 
-saveToURL:ofType:forSaveOperation:error: method. 

This works fine, except on save as. I know that the save as creates a new 
document and updates from the managed objects, and then saves, and it seems 
that there is a managed object context merge happening in there. 

In my case, the timestamp has changed, so I get an error message saying that it 
can't merge the changes.

Is there a way that I can tell that it's in the process of merging changes in 
the middle of a save as, and therefore not update the timestamp? Or some other 
method that I can accomplish my goal of having a save timestamp without running 
into this issue that happens during a Save As operation.

Thanks

Gideon






___

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

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

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

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


Re: How to search for specific bindings in IB

2010-08-10 Thread Jerry Krinock
On 2010 Aug 09, at 17:14, Chris Tracewell wrote:

> In larger NIB files this can be hard to find and remove. Is there anyway to 
> search IB for bindings other than selecting individual elements and looking 
> at the bindings inspector?

Not in Interface Builder 3.3.2.

The only workaround, when you just can't find something, is to search the .xib 
file using a text editor such as BBEdit.  Usually, a binding's name is used 3 
times in an "IBConnectionRecord" element.  In that same element, look for the 
"source" and "destination" values – they'll be 9-10 digit decimal numbers.  
Then search the file again for those numbers, and then in these "source" and 
"destination" elements you'll usually get enough clues to "Aha!" the problem.

It's tedious and very annoying.  I'm hoping that maybe Apple has added a "Find" 
in the next IB release.

Also, next time you have a question on Developer Tools, use 
xcode-us...@lists.apple.com.  Contrary to the name, they do Interface Builder 
over there 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: printPanelDidEnd:returnCode:contextInfo: variable isn't updated

2010-08-10 Thread Kevin Walzer

On 8/10/10 4:28 PM, Quincey Morris wrote:


Based on the NSLog statements, I can tell that printResult is being correctly 
updated, but for some reason that value never makes it to the other function. I 
understand the selector method doesn't return a value; that's why I'm assigning 
the value to the printResult variable.  I don't believe it should be an error 
of variable scope, as the variable printResult is defined at the global level 
of the code, outside any functions or class definitions.

Any thoughts about what I'm doing wrong here?


Yup. The issue is not whether the didEnd method returns a value. The issue is 
the beginSheet pattern is asynchronous. When beginSheet... returns, the didEnd 
method has *not* been invoked yet -- the sheet probably isn't even visible yet. 
That all happens later, and at the end of all of it, your didEnd method is 
invoked so that you can do whatever should happen when the sheet is dismissed.

There isn't any way to make the beginSheet... pattern synchronous. (Well, you 
might be able to do it by running the run loop locally, but I wouldn't suggest 
considering that approach.) Instead, if you want synchronous behavior, use 
runModal instead. That will use a panel (separate window) instead of a sheet, 
but that tradeoff is common the to the beginSheet/runModel pattern used 
throughout Cocoa.


I've decided to address this by refactoring the delegate code to call a 
function that decides how to handle printing based on the returnCode of 
the delegate. It seems to hiccup the first time the command is called 
because it passes NSOKButton (and thus printing the document) regardless 
of what's clicked; but later print sessions are correctly handled. This 
is still a bug, but I think it's one I can live with because most users 
likely won't notice it.


--
Kevin Walzer
Code by Kevin
http://www.codebykevin.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


-[NSBrowser setReusesColumns:] broken?

2010-08-10 Thread James Bucanek

Greetings,

I'm trying to implement an NSBrowser view using the legacy 
(10.5) compatible delegate methods (i.e. not the 10.6 "item data 
source" methods).


I'd very much like to use the reusesColumns property to recycle 
my, rather complex, NSMatrix subclasses. However this property 
appears to broken. I'm currently developing and testing under 10.6.


The first time my delegate receives 
-browser:createRowsForColumn:inMatrix:, the matrix parameter is 
correct and the column gets populated with data. When I select 
another item in the first column, my delegate receives 
-browser:createRowsForColumn:inMatrix: again, but this time the 
matrix value is nil.


This makes no sense. Sending the NSBrowser object 
-matrixInColumn: also returns nil.


Is this just broken?

TIA

P.S. I'd love to use the new 10.6 browser API, but it seems that 
the new code doesn't use NSMatrix objects for each column; 
instead using some kind of custom view that doesn't appear to be 
customizable. Is that also correct?

--
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: Looking for a FTP framework

2010-08-10 Thread Charles Srstka
On Aug 10, 2010, at 6:15 PM, David Alter wrote:

> I'm adding FTP support to a Mac application.  It actually needs to support
> SFTP. I need to support upload and downloading. If a connection is dropped I
> need to be able to re-establish a connection and finish the operation.
> 
> It looks like there are some choices out there and I wanted to see what
> people where suggesting. Here are the choices I have come across.
> 
> 1) I have seen some information about ConnectionKit. It looks like this was
> written back in 2007. The original open source project appears to have
> vanished. However it looks like it was resurrected as a iOS framework.
> Sounds like it was well supported back in 2007. I'm wondering if it is still
> a good solution. I'm thinking changing it to work on the Mac would not be
> that hard to do. Here is where the project is hosted   connectionkit -
> Project Hosting on Google Code 
> 
> 2) Use the CFNetwork APIs. It appears that Apple has some examples to look
> at for this. I thought they might be a good starting point. One is dated
> back to 10.3 days. It looks like a good example but I was unable to make it
> upload a file to my FTP server. That example can be found at
> CFFTPSample
> 
> Then Apple has also provided an example for iOS. That one looks good too. I
> was unable to build it because I have not installed the 4.0 SDK. That
> example can be found at
> SimpleFTPSample
> 
> 3) Then there is always CURL.
> 
> I need to provide a solution for this. The FTP is a very small part of the
> Application. I would like to find something easy to get implemented. I'm
> interested in what other people are doing.
> 
> Thank you for the help
> -dave

Since you mention that what you actually need is SFTP, you could look into 
either libssh or libssh2. They won’t give you regular FTP support, though. If 
you need that as well, libcurl is probably the easiest way to go. Implementing 
your own FTP support using CFNetwork would probably not be that hard, but why 
reinvent the wheel when someone else has already done all the work for you?

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: Is it possible to set UISlider intervals?

2010-08-10 Thread Jonathon Kuo

On Aug 10, 2010, at 5:43 PM, Devraj Mukherjee wrote:

> Hi all,
> 
> I am using UISliders in my iOS app.
> 
> I can't see a way of setting the slide value interval. Is this
> possible? Or do I have to calculate the change based on the 0.1
> increases?
> 
> Minimum value set to -20 and Max to 20 and I want the slider to
> increment by 0.5 on a slide.

UISliders do not 'increment' their value, they increase or decrease their value 
according to how they're touched. You can use these properties to set the 
slider limits:

slider.minimumValue = 0.0;
slider.maximumValue = 0.5;

This is also possible to set within Interface Builder.

___

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


Is it possible to set UISlider intervals?

2010-08-10 Thread Devraj Mukherjee
Hi all,

I am using UISliders in my iOS app.

I can't see a way of setting the slide value interval. Is this
possible? Or do I have to calculate the change based on the 0.1
increases?

Minimum value set to -20 and Max to 20 and I want the slider to
increment by 0.5 on a slide.

Thanks.
___

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: [ SOLVED ] Core Data bindings: add entity to relationship

2010-08-10 Thread James Maxwell
Yikes... I finally figured out what I'd done. In fact, my model and bindings 
were correct. The problem was in trying to access the object hierarchy 
elsewhere in my code. I had it in mind that I wanted something like 
Instrument.articulation.name, when in fact my data structure demanded that it 
be Instrument.articulations.articulation.name. The only reason I was getting 
the valueForUndefinedKey is because I was leaving out one link in the chain. 
Ugh...

Just in case anybody followed this little fiasco of mine, and was disappointed 
to reach the end without resolution, the only difference in IB was to assign my 
table's Selected Object (not Value) to [AssignedArticulation_controller 
arrangedObjects].articulation (not articulation.name). Of course, this makes 
sense, because it's a question of specifying a relationship to an Articulation 
entity, not just that entity's name.

Thanks again for your help.

J.


On 2010-08-09, at 2:00 PM, James Maxwell wrote:

>> 
>> 
>> As to the rest of it, I'm lost as to what you're talking about. What does 
>> "ran the assignment in the app" mean?
> 
> Yeah, I just mean when I try to access the data programmatically from another 
> part of the app -- when I iterate over the object hierarchy.
> 
>> What's the exact text of the reported error? There is no such error as 
>> "valueUndefinedForKey". Maybe you're referring to "valueForUndefinedKey"?
> 
> Sorry, yes, that's correct.
>> 
>> It sounds like your popup button selection is getting bound to the 'name' 
>> property of the Articulation object, and you run into an exception because 
>> there's no setter for that property. As I said before, configuring 
>> NSPopUpButton bindings is hard.
>> 
> 
> hard it is. Cold comfort, I suppose.
> Thanks for your help.
> 
> J.
> 
> 
> 
> 
>> 
>> 
>> ___
>> 
>> 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/jbmaxwell%40rubato-music.com
>> 
>> This email sent to jbmaxw...@rubato-music.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/jbmaxwell%40rubato-music.com
> 
> This email sent to jbmaxw...@rubato-music.com

James B Maxwell
Composer/Doctoral Student
School for the Contemporary Arts (SCA)
School for Interactive Arts + Technology (SIAT)
Simon Fraser University
jbmaxw...@rubato-music.com
jbmax...@sfu.ca

___

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

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

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

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


Re: Exception in -[NSManagedObjectContext save:]

2010-08-10 Thread Nick Zitzmann

On Aug 10, 2010, at 5:58 PM, Rick Mann wrote:

> We're very frequently seeing an exception down inside 
> -[NSManagedObjectContext save:]. The exception itself is caught somewhere 
> inside -save: and no errors are returned, but the debugger always stops 
> there. Nothing is written to the console.
> 
> Is there something wrong? 

I doubt it. I've also seen this method throw and catch internal exceptions 
while it's working. Nothing is wrong, unless the method returns a negative & an 
error. It does get annoying when exception breaking is turned on, though...

Nick Zitzmann


___

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


Exception in -[NSManagedObjectContext save:]

2010-08-10 Thread Rick Mann
We're very frequently seeing an exception down inside -[NSManagedObjectContext 
save:]. The exception itself is caught somewhere inside -save: and no errors 
are returned, but the debugger always stops there. Nothing is written to the 
console.

Is there something wrong? There is no way I know of to get the debugger to 
ignore that exception without ignoring them everywhere else.

TIA,
Rick

___

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

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

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

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


Re: [iPhone] UITableViewCell Height with UIWebView content

2010-08-10 Thread Sandro Noël
Glenn thank you, 
I will revisit the design.

as for using Core Text, I read the doc, but unfortunately for me I'm still 
novice at drawing stuff.
I need to read more about it as it is the only way to get exactly what I want 
from the platform.
so it is in the top of the todo list.

best regards.
Sandro.

> 
> Rethink your design - putting a UIWebView inside a UITableView is usually a 
> bad idea for a number of reasons, including:
> - not being able to tell the height of the view until far too late to be any 
> good (UITableView needs to know before it is displayed, UIWebView can't know 
> until after everything has been loaded)
> - views which scroll vertically inside other views which scroll vertically 
> can cause a bad user experience (though at least as of 3.x they work - in 
> previous OSes the results were far less useful),
> - UIWebView is a very heavy weight view, and UITableViewCells are designed to 
> be light weight
> 
> You should probably put the resulting UIWebView in its own view controller, 
> and push that as a disclosure of the table cell (or detail disclosure).
> 
> If your goal is just to display "styled text" inside a table row, you can use 
> things like NSAttributedString/CoreText (or for pre 3.2 support, 
> CFAttributedString & custom drawing routines).
> 
> 
> Glenn Andreas  gandr...@gandreas.com 
> The most merciful thing in the world ... is the inability of the human mind 
> to correlate all its contents - HPL
> 

___

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


Looking for a FTP framework

2010-08-10 Thread David Alter
I'm adding FTP support to a Mac application.  It actually needs to support
SFTP. I need to support upload and downloading. If a connection is dropped I
need to be able to re-establish a connection and finish the operation.

It looks like there are some choices out there and I wanted to see what
people where suggesting. Here are the choices I have come across.

1) I have seen some information about ConnectionKit. It looks like this was
written back in 2007. The original open source project appears to have
vanished. However it looks like it was resurrected as a iOS framework.
Sounds like it was well supported back in 2007. I'm wondering if it is still
a good solution. I'm thinking changing it to work on the Mac would not be
that hard to do. Here is where the project is hosted   connectionkit -
Project Hosting on Google Code 

2) Use the CFNetwork APIs. It appears that Apple has some examples to look
at for this. I thought they might be a good starting point. One is dated
back to 10.3 days. It looks like a good example but I was unable to make it
upload a file to my FTP server. That example can be found at
CFFTPSample

Then Apple has also provided an example for iOS. That one looks good too. I
was unable to build it because I have not installed the 4.0 SDK. That
example can be found at
SimpleFTPSample

3) Then there is always CURL.

I need to provide a solution for this. The FTP is a very small part of the
Application. I would like to find something easy to get implemented. I'm
interested in what other people are doing.

Thank you for the help
-dave
___

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

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

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

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


NSTextView in NSCollectionView doesn't draw

2010-08-10 Thread Rainer Standke
Hello,

In a core data document based app I have a NSTextView inside an 
NSCollectionView. The text view's value is bound to a core data attribute. When 
a document is opened the text does not draw in the text view. When the user 
clicks the view it will draw the text correctly.

The text always draws correctly in a NSTextField - unless that text field is 
included in a NSScrollView, then the text doesn't draw.

This seems to hint at the scroll view being part of the problem. I tried the 
fix (probably for a different problem, though) described here:

http://www.mail-archive.com/cocoa-dev@lists.apple.com/msg54451.html

Unfortunately not a solution for my problem. I tried to force drawing of the 
text view, but when it draws, it draws the blank view, no text. It seems that 
the binding message flow doesn't work right. I tried sending 
will/didChangeValue messages to the represented object (i.e. a core data 
managed object), to no avail.

Any insight would be greatly appreciated,

Rainer___

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: CGImage to NSImage, or PDFPage?

2010-08-10 Thread Brian Postow

On Aug 10, 2010, at 6:02 PM, Nick Zitzmann wrote:

> 
> On Aug 10, 2010, at 3:45 PM, Brian Postow wrote:
> 
>> Is there something obvious that I'm missing?
> 
> Yes. If you can require Leopard or later, then just create an 
> NSBitmapImageRep using -initWithCGImage:, then create the NSImage with the 
> size of the CGImage and add that NSBitmapImageRep to the NSImage. If not, 
> then create a new image with the size of the CGImage, lock focus on the 
> image, draw the CGImage using CGContextDrawImage(), and unlock focus.
> 
> Nick Zitzmann
> 
> 
> 


Excellent! Now is there an easier way to get the CGImage out of the PDFPage 
than:

PDFPage * pg = [doc pageAtIndex: pageNum -1];

NSData* imgData = [pg dataRepresentation];
NSImage* img = [[NSImage alloc] initWithData:imgData ];

imgData = [img TIFFRepresentation]; 

CGImageSourceRef imageSource = 
CGImageSourceCreateWithData((CFDataRef)imgData,  NULL);
NSDictionary * options = [NSDictionary dictionaryWithObject: 

(id)kCFBooleanTrue  

forKey: (id) kCGImageSourceShouldCache];
CGImageRef imgRef = CGImageSourceCreateImageAtIndex(imageSource, 0, 
options);


? About 1/2 of the time I seem to be crashing in the dataRepresentation call 
for some reason... 


Brian Postow
Senior Software Engineer
Acordex Imaging Systems

___

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: CGImage to NSImage, or PDFPage?

2010-08-10 Thread Brian Postow

On Aug 10, 2010, at 6:03 PM, glenn andreas wrote:

> 
> On Aug 10, 2010, at 4:45 PM, Brian Postow wrote:
> 
>> 
>> I'm not sure if this is rightly a Cocoa question or Quartz, so I'm posting 
>> on both lists. Sorry for the double...
>> 
>> I have a CGImageRef, and I need to put it into a PDFPage. At the moment, the 
>> only way I see to do that is to turn it into an NSImage first. I've 
>> currently got:
> [snip]
>> 
>> Is there something obvious that I'm missing?
>> 
> 
> 
> How about -[NSImage initWithCGImage:(CGImageRef)cgImage size:(NSSize)size] if 
> you're using 10.6, or use -[NSBitmapImageRep 
> initWithCGImage:(CGImageRef)cgImage] and add it to an NSImage if you're using 
> 10.5?


I can assume 10.5, but not 10.6... so, the NSBitmapImageRep is my best bet.

thanks!
(Also thanks Nick for the same advice!)

Brian Postow
Senior Software Engineer
Acordex Imaging Systems

___

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: CGImage to NSImage, or PDFPage?

2010-08-10 Thread John Calhoun
On Aug 10, 2010, at 2:45 PM, Brian Postow wrote:
> I have a CGImageRef, and I need to put it into a PDFPage. At the moment, the 
> only way I see to do that is to turn it into an NSImage first.

That will work, but it is also possible to subclass PDFPage and override the 
-[drawWithBox:] method in your subclass. Your method would get the current 
context as a CGContext and draw the CGImageRef directly.

Make sure to return the correct size in -[PDFPage boundsForBox:] as well.

John Calhoun—___

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: CGImage to NSImage, or PDFPage?

2010-08-10 Thread glenn andreas

On Aug 10, 2010, at 4:45 PM, Brian Postow wrote:

> 
> I'm not sure if this is rightly a Cocoa question or Quartz, so I'm posting on 
> both lists. Sorry for the double...
> 
> I have a CGImageRef, and I need to put it into a PDFPage. At the moment, the 
> only way I see to do that is to turn it into an NSImage first. I've currently 
> got:
[snip]
> 
> Is there something obvious that I'm missing?
> 


How about -[NSImage initWithCGImage:(CGImageRef)cgImage size:(NSSize)size] if 
you're using 10.6, or use -[NSBitmapImageRep 
initWithCGImage:(CGImageRef)cgImage] and add it to an NSImage if you're using 
10.5?


Glenn Andreas  gandr...@gandreas.com 
The most merciful thing in the world ... is the inability of the human mind to 
correlate all its contents - HPL

___

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: CGImage to NSImage, or PDFPage?

2010-08-10 Thread Brian Postow

On Aug 10, 2010, at 5:57 PM, Quincey Morris wrote:

> On Aug 10, 2010, at 14:45, Brian Postow wrote:
> 
>>  NSImage* img = [NSImage alloc];
>>  [img initWithData: imgData];
> 
> Well, you definitely don't want to do this. There's no guarantee that the 
> initialized object returned by 'initWithData:' is img, so you could easily be 
> returning an uninitialized object.

Yeah, that was just me trying to make sure that the alloc was giving me an 
object...

> 
> Assuming that's not the problem here, what source line is producing the "not 
> a TIFF file" error?
> 

The error is coming from the Finalize.

> 
> ___
> 
> 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/brian.postow%40acordex.com
> 
> This email sent to brian.pos...@acordex.com
> 

Brian Postow
Senior Software Engineer
Acordex Imaging Systems

___

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: CGImage to NSImage, or PDFPage?

2010-08-10 Thread Nick Zitzmann

On Aug 10, 2010, at 3:45 PM, Brian Postow wrote:

> Is there something obvious that I'm missing?

Yes. If you can require Leopard or later, then just create an NSBitmapImageRep 
using -initWithCGImage:, then create the NSImage with the size of the CGImage 
and add that NSBitmapImageRep to the NSImage. If not, then create a new image 
with the size of the CGImage, lock focus on the image, draw the CGImage using 
CGContextDrawImage(), and unlock focus.

Nick Zitzmann


___

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: CGImage to NSImage, or PDFPage?

2010-08-10 Thread Quincey Morris
On Aug 10, 2010, at 14:45, Brian Postow wrote:

>   NSImage* img = [NSImage alloc];
>   [img initWithData: imgData];

Well, you definitely don't want to do this. There's no guarantee that the 
initialized object returned by 'initWithData:' is img, so you could easily be 
returning an uninitialized object.

Assuming that's not the problem here, what source line is producing the "not a 
TIFF file" error?


___

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


CGImage to NSImage, or PDFPage?

2010-08-10 Thread Brian Postow

I'm not sure if this is rightly a Cocoa question or Quartz, so I'm posting on 
both lists. Sorry for the double...

I have a CGImageRef, and I need to put it into a PDFPage. At the moment, the 
only way I see to do that is to turn it into an NSImage first. I've currently 
got:

NSImage* cgImageToNSImage(CGImageRef image)
{
int h, w;
h = CGImageGetHeight(image);
w = CGImageGetWidth(image);
NSMutableData* imgData = [NSMutableData dataWithLength: h * w * 4];
CGImageDestinationRef dest = CGImageDestinationCreateWithData
(imgData, kUTTypeTIFF, 1, NULL);
[imgData retain];
CGImageDestinationAddImage(dest, image, NULL);
CGImageDestinationFinalize(dest);
NSImage* img = [NSImage alloc];
[img initWithData: imgData];
CFRelease (dest);
[imgData release];
return img;
}

But this consistantly gives me the error: tiff data provider: Not a TIFF file, 
bad magic number 0 (0x0).

I'm pretty sure that the CGImage is a valid image, and I don't see any options 
to AddImage that look helpful...

Is there something obvious that I'm missing?

thanks.

Brian Postow
Senior Software Engineer
Acordex Imaging Systems

___

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: Math.h functions with CGFloat

2010-08-10 Thread Quincey Morris
On Aug 10, 2010, at 14:00, Michael Ash wrote:

> All operators with floating-point arguments must be performed with
> double precision. However, the C spec operates according to the
> "as-if" rule. The compiler is free to generate ANY code it wishes so
> long as the result is the same "as if" it were performed as the spec
> dictates. So in short, as long as your CPU's FPU does accurate 32-bit
> float calculations (and they usually do), the compiler can take
> something like this:
> 
> floata = floatb * floatc;
> 
> And compile it into code that does not ever promote to double, and
> still adhere to the standard.

Here's where I was going with this:

Although the above might be provably identical (given the CPU/FPU architecture) 
to the spec-mandated calculation:

floata = (double) floatb * (double) floatc;

the following are not identical to each other numerically:

floata = atan (floatb) * atan (floatc);
floata = atanf (floatb) * atanf (floatc);

Therefore, switching from the double to the float versions of math.h functions 
*for the purpose of eliminating compiler warnings about the size of the 
variables* is slightly risky numerically, in a way that depends on the details 
of the expression being calculated. 99 times out 100 in general purpose 
programming the difference is irrelevant, but there is a potential danger.

I was just trying to make explicit the OP's unstated semi-premise that there's 
no numerical issue there.


___

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


Clicks while using NSOpenGLContext's setFullScreen?

2010-08-10 Thread Andy O'Meara

Hey guys, quick question for the cocoa gurus here...

I'm using NSOpenGLContext's setFullScreen method to run my NSOpenGLContext in 
fullscreen.  However, in that mode, it's not clear how one should get mouse 
events (or at least clicks).   I saw one post a few years ago imply that he 
used a repeating task that polls [NSApp currentEvent] -- is that the best 
approach?

http://lists.apple.com/archives/cocoa-dev/2006/Feb/msg00345.html

Thanks in advance!

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: Math.h functions with CGFloat

2010-08-10 Thread Rick Mann
Thanks. When I did the in-Xcode file search, it didn't turn up, so I was 
curious.

On Aug 10, 2010, at 14:15:03, Nick Zitzmann wrote:

> 
> On Aug 10, 2010, at 3:06 PM, Rick Mann wrote:
> 
>> Is  available on iOS? (I have code shared among platforms.)
> 
> Yes:
> 
> % find /Developer/Platforms/iPhoneOS.platform -name 'tgmath.h'
> [...]
> /Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/clang/1.5/include/tgmath.h
> /Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/gcc/arm-apple-darwin10/4.0.1/include/tgmath.h
> /Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/gcc/arm-apple-darwin10/4.0.1/install-tools/include/tgmath.h
> /Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/gcc/arm-apple-darwin10/4.2.1/include/tgmath.h
> /Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/gcc/arm-apple-darwin10/4.2.1/install-tools/include/tgmath.h
> [...]
> 
> Nick Zitzmann
> 
> 

___

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: Math.h functions with CGFloat

2010-08-10 Thread Nick Zitzmann

On Aug 10, 2010, at 3:06 PM, Rick Mann wrote:

> Is  available on iOS? (I have code shared among platforms.)

Yes:

% find /Developer/Platforms/iPhoneOS.platform -name 'tgmath.h'
[...]
/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/clang/1.5/include/tgmath.h
/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/gcc/arm-apple-darwin10/4.0.1/include/tgmath.h
/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/gcc/arm-apple-darwin10/4.0.1/install-tools/include/tgmath.h
/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/gcc/arm-apple-darwin10/4.2.1/include/tgmath.h
/Developer/Platforms/iPhoneOS.platform/Developer/usr/lib/gcc/arm-apple-darwin10/4.2.1/install-tools/include/tgmath.h
[...]

Nick Zitzmann


___

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: Math.h functions with CGFloat

2010-08-10 Thread Greg Parker
On Aug 10, 2010, at 2:06 PM, Rick Mann wrote:
> On Aug 10, 2010, at 08:35:43, Kyle Sluder wrote:
>> The correct thing to do is leave the warning enabled and #include .
> 
> Is  available on iOS? (I have code shared among platforms.)

Yes; it's part of C99.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler


___

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

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

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

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


Re: Math.h functions with CGFloat

2010-08-10 Thread Rick Mann

On Aug 10, 2010, at 08:35:43, Kyle Sluder wrote:

> The correct thing to do is leave the warning enabled and #include .

Is  available on iOS? (I have code shared among platforms.)

-- 
Rick


___

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

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

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

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


Re: Math.h functions with CGFloat

2010-08-10 Thread Michael Ash
On Tue, Aug 10, 2010 at 1:44 PM, Quincey Morris
 wrote:
> Excuse me for jumping into this discussion with half a brain, but isn't there 
> another consideration?
>
> I was under the impression that C does not have symmetric support for 
> 'double' and 'float'. Specifically, I thought that any (a) expression 
> involving floating point numbers promoted everything to doubles to apply the 
> operators to;

All operators with floating-point arguments must be performed with
double precision. However, the C spec operates according to the
"as-if" rule. The compiler is free to generate ANY code it wishes so
long as the result is the same "as if" it were performed as the spec
dictates. So in short, as long as your CPU's FPU does accurate 32-bit
float calculations (and they usually do), the compiler can take
something like this:

floata = floatb * floatc;

And compile it into code that does not ever promote to double, and
still adhere to the standard.

> and (b) 'float' values passed as function arguments are actually passed as 
> doubles.  (Or is it that there are no 'float' expressions, only 'double' 
> expressions?) (Isn't that why it's safe to put 'float's in variable argument 
> lists without casting them to 'double'?) Is this just something I dreamed, or 
> is there something in the C language spec that's relevant?

It's sort of half and half. Floats are promoted to doubles *when
passed as a variable argument to a function that takes varargs*. They
are not promoted when passing to a normal, non-variable argument
function, unless of course the function takes 'double' for that
parameter. So in the vast majority of cases, passing a float to a
function that takes a float will not result in promotion to double.

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


Handling NSManagedObjectContextDidSaveNotification from different threads

2010-08-10 Thread Rick Mann
We have an app that uses a "main" NSManagedObjectContext (MOC) for all 
UI-related work, and has background threads that add and update data via their 
own dedicated MOCs. When they call -save: on their MOC, the "main" MOC gets the 
NSManagedObjectContextDidSaveNotification and calls 
-mergeChangesFromContextDidSaveNotification:.

The problem is, this actually happens on the thread that called -save:, not on 
the main thread. We're seeing occasional crashes, and suspect that it is due to 
this problem. However, I didn't see anything in the docs that said we had to 
call -save: from the main thread, or take any special steps when handling that 
notification.

Did I just overlook something, or should this work safely always? It seems like 
the latter is unlikely, since two threads could be accessing a MOC 
simultaneously.

Thanks,
Rick

___

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

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

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

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


Re: printPanelDidEnd:returnCode:contextInfo: variable isn't updated

2010-08-10 Thread Quincey Morris
On Aug 10, 2010, at 07:55, Kevin Walzer wrote:

> - (void)printPanelDidEnd:(NSPrintPanel *)printPanel 
> returnCode:(int)returnCode contextInfo:(void *)contextInfo {
> 
>  printResult = [...]
> 
> }
> 
> @end
> 
> And here's the logic in another function of my code:
> 
>[printPanel beginSheetWithPrintInfo:printInfo modalForWindow:windowRef 
> delegate:printDelegate 
> didEndSelector:@selector(printPanelDidEnd:returnCode:contextInfo:) 
> contextInfo:printInfo];
> 
> if {printResult = NSOkButton} {
>   //do print stuff here
> } else {
>   return
> 
> }
> 
> Based on the NSLog statements, I can tell that printResult is being correctly 
> updated, but for some reason that value never makes it to the other function. 
> I understand the selector method doesn't return a value; that's why I'm 
> assigning the value to the printResult variable.  I don't believe it should 
> be an error of variable scope, as the variable printResult is defined at the 
> global level of the code, outside any functions or class definitions.
> 
> Any thoughts about what I'm doing wrong here?

Yup. The issue is not whether the didEnd method returns a value. The issue is 
the beginSheet pattern is asynchronous. When beginSheet... returns, the didEnd 
method has *not* been invoked yet -- the sheet probably isn't even visible yet. 
That all happens later, and at the end of all of it, your didEnd method is 
invoked so that you can do whatever should happen when the sheet is dismissed.

There isn't any way to make the beginSheet... pattern synchronous. (Well, you 
might be able to do it by running the run loop locally, but I wouldn't suggest 
considering that approach.) Instead, if you want synchronous behavior, use 
runModal instead. That will use a panel (separate window) instead of a sheet, 
but that tradeoff is common the to the beginSheet/runModel pattern used 
throughout Cocoa.


___

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] UITableViewCell Height with UIWebView content

2010-08-10 Thread glenn andreas

On Aug 10, 2010, at 2:04 PM, Sandro Noël wrote:

> Greetings.
> 
> I've been trying to set the table view cell's height for a custom 
> tableviewCell containing a UIWebView
> to display attributed content but i cant's get the height properly.
> 
[snip]
> since it is so tedious, Now i'm thinking this is a design flaw on my part, 
> trying to resize a TableCellView with posibily big content.
> 
> any advice?
> 

Rethink your design - putting a UIWebView inside a UITableView is usually a bad 
idea for a number of reasons, including:
- not being able to tell the height of the view until far too late to be any 
good (UITableView needs to know before it is displayed, UIWebView can't know 
until after everything has been loaded)
- views which scroll vertically inside other views which scroll vertically can 
cause a bad user experience (though at least as of 3.x they work - in previous 
OSes the results were far less useful),
- UIWebView is a very heavy weight view, and UITableViewCells are designed to 
be light weight

You should probably put the resulting UIWebView in its own view controller, and 
push that as a disclosure of the table cell (or detail disclosure).

If your goal is just to display "styled text" inside a table row, you can use 
things like NSAttributedString/CoreText (or for pre 3.2 support, 
CFAttributedString & custom drawing routines).


Glenn Andreas  gandr...@gandreas.com 
The most merciful thing in the world ... is the inability of the human mind to 
correlate all its contents - HPL

___

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


printPanelDidEnd:returnCode:contextInfo: variable isn't updated

2010-08-10 Thread Kevin Walzer
I'm implementing basic printing functionality as a library extension to 
a GUI toolkit I use (Tk).. The code uses a custom Cocoa class as the 
delegate for the printPanelDidEnd:returnCode:contextInfo selector (when 
the print dialog is presented as a sheet).


The design of the code is to get the value of the returnCode (NSOKButton 
or NSCancelButton), assign it to a variable, printResult, then take 
action based on the variable (print or return).  I am doing this because 
the  printPanelDidEnd:returnCode:contextInfo selector  isn't supposed to 
return a value. The issue I'm running into is that the selector returns 
immediately and apparently the value of printResult isn't updated in the 
global scope of my code.


 Here's the relevant code:

int printResult;

@interface PrintDelegate: NSObject

-(id) init;

- (void)printPanelDidEnd:(NSPrintPanel *)printPanel 
returnCode:(int)returnCode contextInfo:(void *)contextInfo;


@end

@implementation PrintDelegate

-(id) init {
  self = [super init];
  return self;
}

- (void)printPanelDidEnd:(NSPrintPanel *)printPanel 
returnCode:(int)returnCode contextInfo:(void *)contextInfo {


  printResult = NULL;

 if (returnCode == NSOKButton) {
printResult = NSOKButton;
NSLog(@"printResult is OK button!");
  }
  if (returnCode = NSCancelButton) {
printResult = NSCancelButton;
NSLog(@"printResult is Cancel button!");
  }

}

@end

And here's the logic in another function of my code:

[printPanel beginSheetWithPrintInfo:printInfo 
modalForWindow:windowRef delegate:printDelegate 
didEndSelector:@selector(printPanelDidEnd:returnCode:contextInfo:) 
contextInfo:printInfo];


if {printResult = NSOkButton} {
//do print stuff here
} else {
return

}

Based on the NSLog statements, I can tell that printResult is being 
correctly updated, but for some reason that value never makes it to the 
other function. I understand the selector method doesn't return a value; 
that's why I'm assigning the value to the printResult variable.  I don't 
believe it should be an error of variable scope, as the variable 
printResult is defined at the global level of the code, outside any 
functions or class definitions.


Any thoughts about what I'm doing wrong here?

Thanks,
Kevin

--
Kevin Walzer
Code by Kevin
http://www.codebykevin.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: Custom zones...

2010-08-10 Thread Jayson Adams

On Aug 10, 2010, at 6:55 AM, Bill Bumgarner wrote:

> 
> On Aug 10, 2010, at 1:31 AM, Alastair Houghton wrote:
> 
>> Sounds like a bug to me.  While zones are *discouraged* (they're very 
>> definitely an advanced topic and easily misused), I don't think they're 
>> actually deprecated.
> 
> Their use is deprecated and should be documented as such.   
> 
> Zones were never very useful.   They seemed like they might be, but proved to 
> be vastly more problematic than useful.
> 
> (For those that don't know, the idea was to be able to create a zone for all 
> of, say, a document's objects.  Then, when the document was closed, you 
> destroy the zone without destroying the individual objects.)


More significantly, per-document zones group all of a document's object 
allocations together, so that if I have four documents open but am only working 
on one of them, the OS can easily page out the memory associated with the three 
documents I'm not working on.  I remember way back in the day when I updated to 
the first NeXTSTEP build that included zones, and suddenly my machine wasn't 
thrashing anymore.  Zones were useful, but, as you say, problematic, because if 
you make a mistake like allocating just one object for document A in document 
B's zone, you lose the benefits.
 
Best,


__jayson

Circus Ponies NoteBook - Organization for a Creative Mind
www.circusponies.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


[iPhone] UITableViewCell Height with UIWebView content

2010-08-10 Thread Sandro Noël
Greetings.

I've been trying to set the table view cell's height for a custom tableviewCell 
containing a UIWebView
to display attributed content but i cant's get the height properly.

I am using a UITable View with sections, the first section shows a list of 
child objects
and the second section displays the current node's text.

Here is the explanation of my workout. yes it's a workout.

1: define a custom TableCellViewCell in interface builder, containing a 
UIWebView.
2: the UITableView is given a HTML String before being pushed on the Navigation 
view.
3: in the cellForRowAtIndexPath the cell is given the HTML String
4: i've also implemented the heightForRowAtIndexPath method. which calls a 
function that calculated the height of the cell using the text as source.

- (CGFloat) heightOfCellForString:(NSString *)string 
inTableView:(UITableView*)tblView andFont:(UIFont *)font{

CGFloat minimumCellHeight = 44.0f;
CGRect tableViewFrame = [tblView frame];
CGSize textSize = { tableViewFrame.size.width, 20.00f }; 
CGSize size = [string sizeWithFont:font constrainedToSize:textSize 
lineBreakMode:UILineBreakModeWordWrap];
// if there is more than one line add a little padding..
if (size.height > 21) 
size.height += 25;

CGFloat result = MAX(size.height, minimumCellHeight);

return result;
}

This function works great for ordinary cells, but falls verry verry short when 
it comes 
to resizing the cell containing the UIWebView, 

is there a effective way to tell how high the tableviewCell should be to 
accommodate the UITableCellView
at the heightForRowAtIndexPath stage?

since it is so tedious, Now i'm thinking this is a design flaw on my part, 
trying to resize a TableCellView with posibily big content.

any advice?

Best regards.
Sandro Noel.


___

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: Custom zones...

2010-08-10 Thread charlie


In an effort to simplify the example, I may have made it more complicated.

I'm actually trying to create an NSSecureTextField, but I tried to make 
the example more apple-vs-apples, by showing a c string and an NSString 
back to back.


I tried with:

NSSecureTextField
NSTextField
NSButton
NSString

All fail to allocate within the custom zone.

Of these classes, I think only NSString is part of a cluster, so 
something else has to be at fault here too.


The CF solution is great.  Thanks for that.  Good to know.  But, I 
guess I need to know how to allocate the backing store for the string 
storage for an NSSecureTextField in a custom zone still.


I was hoping that I could simply allocate the text field itself from 
the custom zone and it would internally allocate its string storage 
from the same zone.


I guess I could subclass NSSecureTextField and provide my own string 
storage using the CF methodology you mentioned.


(task: to ensure that the string storage is encrypted, and wiped clean 
before it's deallocated)


Thanks again.

Chuck











On August 10, 2010 04:31:26 A.M. EDT, Alastair Houghton 
 wrote:



On 10 Aug 2010, at 05:18, charlie wrote:

As you can see, the c string is successfully allocated from space in 
the custom zone.  But the NSString object is allocated from the 
default zone, despite having called +[NSObject allocWithZone:].


Anyone know the trick to this?


Sounds like a bug to me.  While zones are *discouraged* (they're very 
definitely an advanced topic and easily misused), I don't think 
they're actually deprecated.


Anyway, the solution is to drop down a layer to Core Foundation.  You 
can make an allocator that will use an NSZone easily enough using 
CFAllocatorCreate(), then pass that into CFStringCreate() as the 
allocator argument.


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: Math.h functions with CGFloat

2010-08-10 Thread Greg Parker
On Aug 10, 2010, at 10:44 AM, Quincey Morris wrote:
> Also, I remember we had a discussion on this list a few months ago concerning 
> a warning flag that might have been 'Wshorten-64-to-32' or might have been 
> something vaguely similar, where someone from Apple jumped in to say that 
> using the warning *didn't* really make sense. I can't remember any more 
> details, and I can't find the post in a quick search of the archives, but I 
> mention it in case someone else has a better memory.

You're probably thinking of -Wconversion, which adds some useful 
type-conversion checking but also some unavoidable complaints about perfectly 
good prototypes.


-- 
Greg Parker gpar...@apple.com Runtime Wrangler


___

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

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

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

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


Re: Math.h functions with CGFloat

2010-08-10 Thread Quincey Morris
Excuse me for jumping into this discussion with half a brain, but isn't there 
another consideration?

I was under the impression that C does not have symmetric support for 'double' 
and 'float'. Specifically, I thought that any (a) expression involving floating 
point numbers promoted everything to doubles to apply the operators to; and (b) 
'float' values passed as function arguments are actually passed as doubles.  
(Or is it that there are no 'float' expressions, only 'double' expressions?) 
(Isn't that why it's safe to put 'float's in variable argument lists without 
casting them to 'double'?) Is this just something I dreamed, or is there 
something in the C language spec that's relevant?

If I'm at all correct, then using the 'float' versions of the math functions 
doesn't entirely eliminate (runtime) type conversions, and may introduce 
troubling precision issues in the order of conversions in an expression is not 
considered. Compiler optimization may mitigate some of this, but see 
http://ridiculousfish.com/blog/archives/2010/07/23/will-it-optimize/ for a 
salutary warning about naively believe in floating point optimization 
techniques.

Also, I remember we had a discussion on this list a few months ago concerning a 
warning flag that might have been 'Wshorten-64-to-32' or might have been 
something vaguely similar, where someone from Apple jumped in to say that using 
the warning *didn't* really make sense. I can't remember any more details, and 
I can't find the post in a quick search of the archives, but I mention it in 
case someone else has a better memory.


___

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: Math.h functions with CGFloat

2010-08-10 Thread Sean McBride
On Tue, 10 Aug 2010 16:50:17 +0100, Alastair Houghton said:

> seems like a good solution.

Indeed.  I wish I knew about that before.  :)  A pity that Cocoa.h
includes math.h and not tgmath.h.

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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: Math.h functions with CGFloat

2010-08-10 Thread Alastair Houghton
On 10 Aug 2010, at 16:28, Graham Cox wrote:

> If your code is working with CGFloat, then the warning isn't very helpful, 
> because by using CGFloat you've elected to use 32-bit precision.

Only on 32-bit.  On the 64-bit runtime, CGFloat is a double, not a float, and 
therein lies the problem.  If you use e.g. sqrtf() on 64-bit you'll get the 
conversion warning, and if you use sqrt() on 32-bit and assign the result to a 
CGFloat, you'll get the conversion warning too.

 seems like a good solution.

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: Math.h functions with CGFloat

2010-08-10 Thread Kyle Sluder
On Tue, Aug 10, 2010 at 8:28 AM, Graham Cox  wrote:
> If your code is working with CGFloat, then the warning isn't very helpful, 
> because by using CGFloat you've elected to use 32-bit precision. If you want 
> 'double', use 'double'. The warning could be useful on 64-bit compiles to 
> indicate the inadvertent use of 'float' where you meant 'double' or 
> 'CGFloat', but if you're only using CGFloat then that won't happen.

Turning off -Wshorten-64-to-32 is not a preferable option. Remember
that this also warns about long -> int conversion on LP64.

The correct thing to do is leave the warning enabled and #include .

--Kyle Sluder
___

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

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

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

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


Re: Math.h functions with CGFloat

2010-08-10 Thread Graham Cox

On 11/08/2010, at 1:08 AM, steven Hooley wrote:

> But then e.g. when building 32-bit i still have to cast the return
> value or i get the warning:-
> 
> 'implicit conversion shortens 64-bit value into a 32-bit value'
> 
> It seems that this warning is my fault because i have added the flag
> -Wshorten-64-to-32 which isn't enabled by default so maybe it
> shouldn't be?


If your code is working with CGFloat, then the warning isn't very helpful, 
because by using CGFloat you've elected to use 32-bit precision. If you want 
'double', use 'double'. The warning could be useful on 64-bit compiles to 
indicate the inadvertent use of 'float' where you meant 'double' or 'CGFloat', 
but if you're only using CGFloat then that won't happen.

--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: Math.h functions with CGFloat

2010-08-10 Thread steven Hooley
But then e.g. when building 32-bit i still have to cast the return
value or i get the warning:-

'implicit conversion shortens 64-bit value into a 32-bit value'

It seems that this warning is my fault because i have added the flag
-Wshorten-64-to-32 which isn't enabled by default so maybe it
shouldn't be?
Thanks

On 10 August 2010 15:19, Graham Cox  wrote:
>
> On 11/08/2010, at 12:12 AM, steven Hooley wrote:
>
>> Because CGFloat is typedef'd to float on 32bit and double on 64bit i
>> have to swap between, eg,  atan and atanf depending on my build
>> settings. I have a framework which is intended to support 32bit and
>> 64bit.
>
>
> Just use atan(). 32-bit floats are promoted to doubles silently. There is a 
> slight performance penalty but it's absolutely tiny.
>
> --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: Math.h functions with CGFloat

2010-08-10 Thread Graham Cox

On 11/08/2010, at 12:12 AM, steven Hooley wrote:

> Because CGFloat is typedef'd to float on 32bit and double on 64bit i
> have to swap between, eg,  atan and atanf depending on my build
> settings. I have a framework which is intended to support 32bit and
> 64bit.


Just use atan(). 32-bit floats are promoted to doubles silently. There is a 
slight performance penalty but it's absolutely tiny.

--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: Math.h functions with CGFloat

2010-08-10 Thread James Montgomerie
You should, I believe, be able to include  ('type generic math' - a 
C99 addition) instead, and then just 'use' the non-suffixed versions of the 
functions.  Hidden macro magic is supposed to then make the compiler call the 
double or float versions as appropriate for the type used.

Having said that, I had a lot of trouble when trying this in my iPhone app a 
year or so ago.  Things seemed very slow when complied, and disassembly showed 
all sorts of float<->double conversion going on.  I ended up explicitly calling 
the f-suffixed ones anyway.  I don't think I should have needed to though, and 
if there was a bug back then (rather than just me doing something incorrect) it 
could be fixed now.

Jamie.

On 10 Aug 2010, at 15:04, steven Hooley wrote:

> Sorry, 'safe' was a bad choice. I do care because i have compiler
> warnings. I have started defining macros for each function and thought
> i better check that they didn't already exist.
> Thankyou
> 
> On 10 August 2010 14:54, Alastair Houghton  
> wrote:
>> On 10 Aug 2010, at 13:42, steven Hooley wrote:
>> 
>>> Is there a preferred way to use the Math.h functions with CGFloats
>>> that is 32 and 64 bit safe?
>> 
>> Why would they be unsafe?  (They aren't.)
>> 
>> It's possible that using the double versions (the ones without the "f" 
>> suffix) is inefficient in 32-bit mode, but in practice you're very unlikely 
>> to notice.  If you particularly cared, you could #define some macros for 
>> them, but I doubt it's worthwhile unless you're going to do some heavy-duty 
>> geometry (and in that case, you might find that you want to use double 
>> anyway, for accuracy).
>> 
>> BTW,  isn't capitalised; please don't use random upper-case letters 
>> when including header files... it causes grief if your source code is ever 
>> moved somewhere case-sensitive.
>> 
>>> Should i even be using Math.h functions in Cocoa?
>> 
>> Why should you not?
>> 
>> Kind regards,
>> 
>> Alastair.
> ___
> 
> 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/jamie%40montgomerie.net
> 
> This email sent to ja...@montgomerie.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: Math.h functions with CGFloat

2010-08-10 Thread steven Hooley
Yes, sorry - i meant /usr/include/math.h

Because CGFloat is typedef'd to float on 32bit and double on 64bit i
have to swap between, eg,  atan and atanf depending on my build
settings. I have a framework which is intended to support 32bit and
64bit.

I thought this may have been a common scenario and some useful macros
might already exist.
Thanks

On 10 August 2010 14:10, lbland  wrote:
> hi-
>
> On Aug 10, 2010, at 8:42 AM, steven Hooley wrote:
>
>> Is there a preferred way to use the Math.h functions with CGFloats
>> that is 32 and 64 bit safe?
>> Do some Macros already exist somewhere?
>>
>> Should i even be using Math.h functions in Cocoa?
>
> What do you mean by Math.h ? Do you mean: math.h (/usr/include/math.h) ?
>
> You can use math.h in Cocoa.
>
> math.h is a C standard and doesn't know about CGFloat (except that CGFloat is 
> typedef to double or float). math.h functions generally take doubles (with 
> implicit promotion of floats), or you can use the float counterpart (such as 
> cos() v.s. cosf() ).
>
> thanks!-
>
> -lance
___

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

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

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

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


Re: Custom zones...

2010-08-10 Thread Alastair Houghton
On 10 Aug 2010, at 14:55, Bill Bumgarner wrote:

> On Aug 10, 2010, at 1:31 AM, Alastair Houghton wrote:
> 
>> Sounds like a bug to me.  While zones are *discouraged* (they're very 
>> definitely an advanced topic and easily misused), I don't think they're 
>> actually deprecated.
> 
> Their use is deprecated and should be documented as such.   

I guess that's a documentation bug, then, since there don't seem to be many 
deprecation markings that I can see, and NSZone is documented all over the 
place.

> The key problems were two fold.   First, if a reference to an object in the 
> zone escaped said zone and wasn't cleaned up prior to zone destruction, you 
> ended up with an entirely unfathomable crash.   This happened often.   
> Secondly, if any object was allocated in the zone that required some kind of 
> more-than-dealloc-or-free operations to occur when deallocated, the zone's 
> destruction would bypass that.  Nothing like a dangling backing store 
> [window] to brighten your debugging day!

Indeed, that's why I said "easily misused".

That said, is the part about objects escaping zones really true for *NS*Zone?  
It's true for malloc zones, for sure, but the docs for NSRecycleZone say:

  Frees zone after adding any of its pointers still in use to the default zone.
  (This strategy prevents retained objects from being inadvertently destroyed.)

which seems to imply otherwise.

You *are* just talking about *NS*Zone, right?  malloc zones are very useful and 
I definitely don't want to see those go away (I'm thinking of a certain 
million-plus node data structure we maintain that we'd have to go calling 
free() a million or more times to release...)

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


Fwd: Math.h functions with CGFloat

2010-08-10 Thread steven Hooley
Sorry, 'safe' was a bad choice. I do care because i have compiler
warnings. I have started defining macros for each function and thought
i better check that they didn't already exist.
Thankyou

On 10 August 2010 14:54, Alastair Houghton  wrote:
> On 10 Aug 2010, at 13:42, steven Hooley wrote:
>
>> Is there a preferred way to use the Math.h functions with CGFloats
>> that is 32 and 64 bit safe?
>
> Why would they be unsafe?  (They aren't.)
>
> It's possible that using the double versions (the ones without the "f" 
> suffix) is inefficient in 32-bit mode, but in practice you're very unlikely 
> to notice.  If you particularly cared, you could #define some macros for 
> them, but I doubt it's worthwhile unless you're going to do some heavy-duty 
> geometry (and in that case, you might find that you want to use double 
> anyway, for accuracy).
>
> BTW,  isn't capitalised; please don't use random upper-case letters 
> when including header files... it causes grief if your source code is ever 
> moved somewhere case-sensitive.
>
>> Should i even be using Math.h functions in Cocoa?
>
> Why should you not?
>
> Kind regards,
>
> Alastair.
___

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: Custom zones...

2010-08-10 Thread Bill Bumgarner

On Aug 10, 2010, at 1:31 AM, Alastair Houghton wrote:

> Sounds like a bug to me.  While zones are *discouraged* (they're very 
> definitely an advanced topic and easily misused), I don't think they're 
> actually deprecated.

Their use is deprecated and should be documented as such.   

Zones were never very useful.   They seemed like they might be, but proved to 
be vastly more problematic than useful.

(For those that don't know, the idea was to be able to create a zone for all 
of, say, a document's objects.  Then, when the document was closed, you destroy 
the zone without destroying the individual objects.)

The key problems were two fold.   First, if a reference to an object in the 
zone escaped said zone and wasn't cleaned up prior to zone destruction, you 
ended up with an entirely unfathomable crash.   This happened often.   
Secondly, if any object was allocated in the zone that required some kind of 
more-than-dealloc-or-free operations to occur when deallocated, the zone's 
destruction would bypass that.  Nothing like a dangling backing store [window] 
to brighten your debugging day!

Thus, zones haven't been used or really supported in a long, long, time. The 
only context where they would be safe to use is in sub-graphs of objects that 
are entirely comprised of classes you've written;  where you control every last 
detail of the implementation and do not allow a reference to escape beyond your 
very well protected entry points into said sub-graph.

b.bum




___

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: Math.h functions with CGFloat

2010-08-10 Thread Alastair Houghton
On 10 Aug 2010, at 13:42, steven Hooley wrote:

> Is there a preferred way to use the Math.h functions with CGFloats
> that is 32 and 64 bit safe?

Why would they be unsafe?  (They aren't.)

It's possible that using the double versions (the ones without the "f" suffix) 
is inefficient in 32-bit mode, but in practice you're very unlikely to notice.  
If you particularly cared, you could #define some macros for them, but I doubt 
it's worthwhile unless you're going to do some heavy-duty geometry (and in that 
case, you might find that you want to use double anyway, for accuracy).

BTW,  isn't capitalised; please don't use random upper-case letters 
when including header files... it causes grief if your source code is ever 
moved somewhere case-sensitive.

> Should i even be using Math.h functions in Cocoa?

Why should you not?

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: calling a function in one class from another

2010-08-10 Thread Graham Cox

On 10/08/2010, at 7:06 PM, Geoffrey Holden wrote:

> I'm writing an app which communicates with a server.  The protocol that it
> uses is subject to change, so I'm writing a plugin to support that
> particular protocol.  When, in the future, the protocol changes (as it
> probably will), I'll only need to change the plugin and not the entire app.
> That's my thinking anyway.
> 
> Sometimes, the server will send an update message out - my plugin can
> respond to these events correctly, but (obviously) I need my app to - so,
> effectively, I need to find a way of delegating the response to the app (the
> plugin needs to pass the event on).


I don't know that I can comment on your specific protocol - do whatever makes 
sense.

As a matter of general design though, perhaps a better way to set this up is to 
have some controller object implement the general form of the system, but defer 
to another object to provide the specific implementation. The plug-in can then 
insert whatever object it needs to in this position when it is loaded (modulo 
dealing with the presence of multiple plugins, multiple protocols). In other 
words do it the other way around - don't get the plug-in to do a lot of 
complicated work and hand off to the app as needed, get the app to call an 
object the plug-in put there. This approach is a lot easier to test too, since 
you can insert a test object without even needing a plug-in.

In a procedural/static language, plug-ins can be complicated, needing all sorts 
of communication protocols set up between the host app and the plugin that 
everyone agrees on. In Cocoa, almost any sort of plug-in design becomes, if not 
trivial, then at least orders of magnitude easier, because of a) the existence 
of objects and b) the dynamic nature of Obj-C. Usually it's enough to load the 
plugin and then give it a chance to run at certain well-defined times (e.g. 
when it is first loaded, app launch, as each document is created, etc.). At 
those times the plugin simply manufactures suitable objects and inserts them 
into the app where they take a normal role in the business of the app. The fact 
that the code that implements these objects is part of the plug-in's bundle 
makes no difference. In other words, a plugin is merely a factory for other 
objects that get the work done.

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


Math.h functions with CGFloat

2010-08-10 Thread steven Hooley
Is there a preferred way to use the Math.h functions with CGFloats
that is 32 and 64 bit safe?
Do some Macros already exist somewhere?

Should i even be using Math.h functions in Cocoa?

Thanks
___

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: calling a function in one class from another

2010-08-10 Thread Geoffrey Holden
I'm writing an app which communicates with a server.  The protocol that it
uses is subject to change, so I'm writing a plugin to support that
particular protocol.  When, in the future, the protocol changes (as it
probably will), I'll only need to change the plugin and not the entire app.
 That's my thinking anyway.

Sometimes, the server will send an update message out - my plugin can
respond to these events correctly, but (obviously) I need my app to - so,
effectively, I need to find a way of delegating the response to the app (the
plugin needs to pass the event on).

At the moment, my plugin protocol looks like this - obviously, it doesn't
support events at this stage and I need to update it accordingly.  At this
stage, the app and its plugin can make a connection to the remote server
but, without being able to respond to updates from the server, it's all a
bit useless.

@protocol ConnectionPluginProtocol


+ (BOOL)activate;

+ (void)deactivate;


- (void) doLogin;

- (void) doLogout;

- (void) doStartConnection:(NSString*)destination:(NSString*)body;


@end;

Thanks for all your help.

On Tue, Aug 10, 2010 at 3:28 AM, Graham Cox  wrote:

>
> On 10/08/2010, at 7:13 AM, Geoffrey Holden wrote:
>
> > On a related note, how does this relate to plugin bundles?  I've created
> a plugin (using the tutorial in Aaron Hillegass's excellent book) - and it
> works perfectly.  I want to be able to respond to events in the plugin
> though - would IBAction be the best way to do this since there doesn't seem
> to be a way of getting the App to be a delegate for one of its plugins?
>
>
> What do you mean by 'events'? Actual events, such as mouse down, key
> strokes, that sort of thing? Or do you really mean 'actions', which are
> responders to button clicks, menu choices, etc.
>
> IBActions are useful for the latter. Events are a lower level concept (for
> example, a mouse down, mouse drag and mouse up could be a whole series of
> events that a button responds to, but which trigger one action, which
> informs the button's controller that the button was "clicked"). Actions are
> typically used to connect a user interface item to a controller that gives
> that user interface item some functional meaning by manipulating the data
> model appropriately.
>
> A plug-in is not restricted as to what sort of UI it can present. You
> typically don't want the app (or its delegate) to be a controller on behalf
> of a plug-in's UI. It's not actually impossible but it's a crazy design, so
> I'm glad you think it is impossible! A plug-in can have a nib or nibs that
> provide a user interface just as the app can. How the plug-in interfaces to
> the app itself is up to you, but this should be happening at the controller
> or data-model level, not the UI. Other than that there's not much advice to
> give, given that I don't know anything about what your app or its plugins
> do.
>
> --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: Custom zones...

2010-08-10 Thread Alastair Houghton
On 10 Aug 2010, at 05:18, charlie wrote:

> As you can see, the c string is successfully allocated from space in the 
> custom zone.  But the NSString object is allocated from the default zone, 
> despite having called +[NSObject allocWithZone:].
> 
> Anyone know the trick to this?

Sounds like a bug to me.  While zones are *discouraged* (they're very 
definitely an advanced topic and easily misused), I don't think they're 
actually deprecated.

Anyway, the solution is to drop down a layer to Core Foundation.  You can make 
an allocator that will use an NSZone easily enough using CFAllocatorCreate(), 
then pass that into CFStringCreate() as the allocator argument.

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: Proper UTI for accepting files dropped on my table view?

2010-08-10 Thread Kyle Sluder
On Tue, Aug 10, 2010 at 12:04 AM, Rick Mann  wrote:
> Thanks, Kyle. Wow, the sure made it wordy to use.

It's not really that wordy: [somePasteboard
readObjectsForClasses:[NSArray arrayWithObject:[NSURL class]]
options:[NSDictionary dictionaryWithObject:[NSNumber
numberWithBool:YES] forKey: NSPasteboardURLReadingFileURLsOnlyKey]].
If you find this excessively wordy, Cocoa might not be your favorite
framework. ;-) Anyway, I'd say the mere existence of support for
multiple items in the new API is well worth the slightly increased
verbosity.

Cases like this really scream out for built-in dictionary and array
literal syntax, though. I recall someone has already implemented
something of the sort. Perhaps someone on the list can remind us?

--Kyle Sluder
___

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

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

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

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


Re: Proper UTI for accepting files dropped on my table view?

2010-08-10 Thread Rick Mann
Thanks, Kyle. Wow, the sure made it wordy to use.

On Aug 9, 2010, at 23:59:45, Kyle Sluder wrote:

> On Mon, Aug 9, 2010 at 11:53 PM, Rick Mann  wrote:
>> From that I can only get an NSPasteboard, as far as I can tell.
> 
> 10.6 has a new pasteboard API based around NSPasteboardItem and
> protocols like NSPasteboardReading that natively understands multiple
> objects and URLs. You might have better luck using that API.
> 
> Specifically, the Pasteboard Programming Guide has a section on using
> the new API with file URLs:
> http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/PasteboardGuide106/Articles/pbReading.html#//apple_ref/doc/uid/TP40008123-SW5
> 
>> I pretty much followed Apple direction to get to this point. If there's a 
>> more modern pasteboard, they should mention it in the old pasteboard docs.
> 
> They do in the Pasteboard Programming Guide, but it looks like some of
> the API reference hasn't been updated to point at the new API. The old
> API apparently hasn't been officially deprecated yet. *sigh* Also, see
> the pasteboard video from WWDC09. It's also got an awesome song at the
> end. :)
> 
> In the meantime, file bugs on the documentation for methods like
> -propertyListForType:; maybe they'll be willing to put a note in there
> about the new API.
> 
> --Kyle Sluder

___

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

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

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

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


Re: Proper UTI for accepting files dropped on my table view?

2010-08-10 Thread Kyle Sluder
On Mon, Aug 9, 2010 at 11:53 PM, Rick Mann  wrote:
> From that I can only get an NSPasteboard, as far as I can tell.

10.6 has a new pasteboard API based around NSPasteboardItem and
protocols like NSPasteboardReading that natively understands multiple
objects and URLs. You might have better luck using that API.

Specifically, the Pasteboard Programming Guide has a section on using
the new API with file URLs:
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/PasteboardGuide106/Articles/pbReading.html#//apple_ref/doc/uid/TP40008123-SW5

> I pretty much followed Apple direction to get to this point. If there's a 
> more modern pasteboard, they should mention it in the old pasteboard docs.

They do in the Pasteboard Programming Guide, but it looks like some of
the API reference hasn't been updated to point at the new API. The old
API apparently hasn't been officially deprecated yet. *sigh* Also, see
the pasteboard video from WWDC09. It's also got an awesome song at the
end. :)

In the meantime, file bugs on the documentation for methods like
-propertyListForType:; maybe they'll be willing to put a note in there
about the new API.

--Kyle Sluder
___

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

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

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

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