Re: NSWindowController for Prefs XIB Question (Core Data involved)

2010-05-20 Thread Steve Cronin
Folks;

This one is driving me mad!
I'm trying to bust up an overly complicated xib into 2 xibs - the main xib and 
a preference xib

I've started completely over trying to implement a pref xib -- no CoreData just 
bare bones….

I have created a brand new subclass of NSWindowController: Pref2Controller
there is not a single line of code in this object nor any instance 
variables.
I have created a brand new xib file: ptest
XCode creates the xib with a FilesOwner, FirstResponder, Application, 
and Window (set to releaseOnClose and visibleAtLaunch)
I have set the FilesOwner to be an instance of Pref2Controller (using IB)
I have set the window outlet of the FilesOwner to point to the NSWindow object 
(using IB)
These two are the only changes I've made to ptest.xib
When I use this code in the appDelegate:

- (IBAction) configure:(id)sender {
if (!prefPanelController) {
prefPanelController = [[Pref2Controller alloc] 
initWithWindowNibName:@"ptest"];
}
   [prefPanelController showWindow:sender];
}

The new ptest.xib window will open once but never again if I close it.
this is true regardless of whether I set the window to releaseOnClose 
or not
this is also true regardless of whether I have hooked up the window 
outlet or not
logging [pController window] shows (null) regardless of whether 
I have outlet assigned or not
as well as regardless of whether prefPanelController already 
exists or has just been alloc'ed and init'ed..

What I am just not understanding here?
Please?
Steve

On May 20, 2010, at 10:08 PM, Steve Cronin wrote:

> Folks;
> 
> I have a feeling that this is an embarrassing one so try and go easy on me…
> XC 3.2.2 
> 
> I have a main nib that opens a window and that works fine.
> I used to have an NSPanel in this nib to handle preferences.
> I've decided it's a good idea to split the nib into two different nibs: the 
> main nib and a preferences nib.
> 
> I've looked over the Sketch project and used it as a model.
> I've also read over the Document-Based App Overview FAQ
> 
> I've added a window nib to the project and then subclassed a 
> NSWindowController.
> I've made the xib's files owner this window controller
> At this point I can get a simple empty window to open just fine.
> 
> However, I'm using CoreData and I want to pass the existing MOC to the pref 
> window:
> I have added an array controller to the pref nib with its MOC set to files 
> owner's MOC in IB.
> The controller manages an entity not a mutable dictionary.
> MOC is a synthesized property of the PrefController (the windowController 
> mentioned above).
> 
> if (!prefPanelController) {
>   prefPanelController = [[PreferencesController alloc] 
> initWithWindowNibName:@"testPref"];
>   [prefPanelController setManagedObjectContext:[self 
> managedObjectContext]];
> }
> [prefPanelController showWindow:sender];
> 
> No window opens and I get a console error:  Cannot perform operation without 
> a managed object context
> 
> Could someone give me the gentle head slap I need here?
> Steve


___

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: NSWindowController for Prefs XIB Question (Core Data involved)

2010-05-20 Thread Quincey Morris
On May 20, 2010, at 20:08, Steve Cronin wrote:

> if (!prefPanelController) {
>   prefPanelController = [[PreferencesController alloc] 
> initWithWindowNibName:@"testPref"];
>   [prefPanelController setManagedObjectContext:[self 
> managedObjectContext]];
> }
> [prefPanelController showWindow:sender];
> 
> No window opens and I get a console error:  Cannot perform operation without 
> a managed object context

This could well be a time, or order of things happening, problem.

At the time the nib is loaded, the MOC property of the controller hasn't been 
set yet, so the array controller fetches a nil MOC, and throws an exception 
which aborts the rest of the loading process.

You probably need to write a custom initializer for your custom window 
controller and pass the MOC as a parameter, instead of trying to set it later.

That's my theory, anyway.

Note you can figure this out by writing your own getter method, setting a 
breakpoint in it and see if it's called while the MOC value is still nil. Also 
make sure you (always) have a breakpoint on objc_exception_throw, so that you 
see the backtrace of exceptions at the time they occur.


___

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: Notifications on main thread

2010-05-20 Thread Adam R. Maxwell

On May 19, 2010, at 4:02 AM, Jonny Taylor wrote:

> I've noticed a slight issue (with both NSInvocation and NSOpQ) when a menu is 
> pulled down and posting styles NSPostASAP or NSPostWhenIdle are used. While 
> the menu is visible, the notifications are posted ok (on the main thread), 
> but objects do not receive the notifications until the menu is released. I 
> don't quite understand why this should be (is the main loop not running when 
> a menu is displayed, or are menu-related events somehow jumping the queue and 
> preventing my notifications from reaching the head of the queue?).

Not quite; the main runloop is running in a different mode, likely 
NSEventTrackingRunLoopMode.  Try enqueuing your notification with an array of 
specific modes, or maybe NSRunLoopCommonModes.

-- 
Adam

___

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: EPS image in NSScrollView

2010-05-20 Thread Adam R. Maxwell

On May 20, 2010, at 1:43 PM, jyoun...@kc.rr.com wrote:

> One other quick question.  What I'm really trying to achieve is something 
> similar to how the pdfkit works.  I like how the image/text enlarges within 
> the scrollview when the window is resized.  The code is pretty simple as well:
> 
> [pdfView setDocument:[[[PDFDocument alloc] initWithData:[fileMan 
> contentsAtPath:filePath]] autorelease]];
> [theBox setContentView:pdfView];
> 
> Is it possible to take an eps image and convert it to a pdf file so I can 
> view it through the pdfkit?

Yes, using CGPSConverter.

http://developer.apple.com/mac/library/documentation/GraphicsImaging/Reference/CGPSConverter/Reference/reference.html




___

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 allObjects memory allocation problem

2010-05-20 Thread Nick Zitzmann

On May 19, 2010, at 5:36 AM, Vassilis Pantazis wrote:

> Hello,
> 
> I have in my code the following statement:
> 
>NSDirectoryEnumerator* dirEnum;
>NSArray* inDirContents;
> 
>dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:inPath]; //
> inPath is a valid path
>inDirContents = [dirEnum allObjects];
> 
> I have noticed that when the path contains many objects, a significant
> amount of memory is allocated that is not released, neither when trying to
> explicitly release inDirContents, nor when using an autorelease pool.
> Can someone explain to me why this happens please and how to solve it?

Have you tried using the object alloc instrument in Instruments? That will show 
you what is really going on with your application's memory usage.

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


View manipulation problem

2010-05-20 Thread ico
Hi All,

I have a little iPhone app which has the following UI:
1. 2 buttons, use to manipulate my model object.
2. 2 switches, let's call them infoSwitch and optionSwitch respectively
3. A custom view, its subview includes 4 UILabel, those labels are used to
display infomation of
my model object. Let's call it infoView.
4. Another custom view, includes a slider and textfield which are used to
setup some states of
my model objects, and the optionSwitch mentioned above. Let's call the view
as optionView.
5. Yet another custom view, it will show the drawing graph of my model
object according to its
state. Let's call it graphView.

The layout I want to show to the user is 2 buttons on top, next line is
infoSwitch, and the next line
is optionSwith. And the next line of course is my drawing graph of my model
object. That's all
the user can see at the beginning. Both switches are set to off when they
are loaded. And both
infoView and optionView are transparent. (Alpha value is 0.0).

User will use those 2 buttons to change the basic state of my model object.
And the user can also
switch the infoSwith to be on, once this event occurs, the optionView and
the graphView
will slip certain pixel down, and the infoView will be showed right down to
the infoSwith. Same
thing should happen to the optionView. Once the user switch the optionSwitch
to be on, the
graphView  will slip certain pixel down, and the optionView should be showed
to the user.

That's what I want to implement. I have a problem regarding to this. In
order to make the user
can see what I expect, the optionView will be layout on top of the infoView
at the beginning.
Hence the optionView will become the subview of the infoView. However, I
will set the infoView
alpha to 0.0 in the awakeFromNib method, then its subview includes
optionView will be transparent
as well even I set optionView alpha to 1.0, how to fix this? Do I approach
it the right way? Also,
if I relocate the optionView down to certain pixcel, I guess it will no be
displayed on the screen
because it is located outside of the infoView(its superview). Can anyone
suggest me a solution
for this? Thank you.

best regards,
 ico
==
Life isn't about finding yourself.
Life is about creating yourself.
___

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


NSWindowController for Prefs XIB Question (Core Data involved)

2010-05-20 Thread Steve Cronin
Folks;

I have a feeling that this is an embarrassing one so try and go easy on me…
XC 3.2.2 

I have a main nib that opens a window and that works fine.
I used to have an NSPanel in this nib to handle preferences.
I've decided it's a good idea to split the nib into two different nibs: the 
main nib and a preferences nib.

I've looked over the Sketch project and used it as a model.
I've also read over the Document-Based App Overview FAQ

I've added a window nib to the project and then subclassed a NSWindowController.
I've made the xib's files owner this window controller
At this point I can get a simple empty window to open just fine.

However, I'm using CoreData and I want to pass the existing MOC to the pref 
window:
I have added an array controller to the pref nib with its MOC set to files 
owner's MOC in IB.
The controller manages an entity not a mutable dictionary.
MOC is a synthesized property of the PrefController (the windowController 
mentioned above).

if (!prefPanelController) {
prefPanelController = [[PreferencesController alloc] 
initWithWindowNibName:@"testPref"];
[prefPanelController setManagedObjectContext:[self 
managedObjectContext]];
}
[prefPanelController showWindow:sender];

No window opens and I get a console error:  Cannot perform operation without a 
managed object context

Could someone give me the gentle head slap I need here?
Steve
___

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: Adding Mutiple Lines to a UITableView

2010-05-20 Thread Shao Xianbiao
Hi,

the following may be what you want:

- (id) initWithStyle:(UITableViewStyle)style {

[self.tableView setRowHeight:SOME_PROPER_HEIGHT];
.
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
.
[cell.textLabel setNumberOfLines:0];
..
[cell.textLabel setText:YOUR_TEXT];
.
}

2010/5/20 Nick Rawlins 

> Hi,
>
> Does anyone have any suggestions or examples on adding more than 2 lines to
> a UITableView row on the iPhone?
>
>
> I am using textLabel and detailTextLabel at present but wish to also add a
> 3rd and 4th line.
>
>
> Best Regards,
>
> Nick
> ___
>
> 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/shao.xianbiao%40gmail.com
>
> This email sent to shao.xianb...@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: iPhone/iPad: Desktop wallpaper can't be set.

2010-05-20 Thread Phil Hystad
I hope this feature is not supported.  The last thing I want is some 
application changing my desktop background which is my choice, not one of the 
application.  Yes, I know this can be done with some kind of dialog for 
approval but then that really stresses the logic of why you would want to do 
this -- OS X already provides a way for me to set my background, I don't need 
to buy or use an app to do that.

I vote no -- don't do it.

phil

On May 19, 2010, at 9:08 AM, David Duncan wrote:

> On May 19, 2010, at 7:55 AM, sebi wrote:
> 
>> A customer wants an app that changes the desktop background image. I told 
>> him that is not possible (and probably won't be in the near future) because 
>> that would mean to play outside the sandbox. Is this correct?
> 
> 
> Correct, this is not possible in the current API. I would recommend filing a 
> bug report asking for this capability.
> --
> David Duncan
> Apple DTS Animation and Printing
> 
> ___
> 
> 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/phystad%40mac.com
> 
> This email sent to phys...@mac.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: Notifications on main thread

2010-05-20 Thread Jonny Taylor
>>> - I could try acquiring the NSNotificationQueue for the main thread, but 
>>> there does not appear to be a standard way of doing that. I have seen this 
>>> suggested as a strategy elsewhere, but I think I have also read that one is 
>>> not meant to post to queues other than that of the current thread (not sure 
>>> why...).
>> [...]
>>> I feel there must be a simple way of doing what I want - can anybody advise?
>> 
>> There is a way to do this. You need to set up the enqueue message in an 
>> NSInvocation, have it retain the arguments, and then call the invocation's 
>> -performSelectorOnMainThread:... method to invoke the invocation on the main 
>> thread. This works any time you need to call something on the main thread, 
>> but you need to set more than one argument, or the method has arguments that 
>> take primitives instead of objects.
> 
> Note that if you're targeting 10.6 then you can do it MUCH more easily
> by using blocks and either NSOperationQueue or GCD:
> 
> // NSOpQ
> [[NSOperationQueue mainQueue] addOperationWithBlock: ^{ /* post your
> notification here */ }];

Thankyou all three for your very helpful responses. The blocks-based approach 
is particularly nice. I haven't been able to do much with blocks up to now, 
because bad things happen as soon as they catch sight of a hint C++ code.

I've noticed a slight issue (with both NSInvocation and NSOpQ) when a menu is 
pulled down and posting styles NSPostASAP or NSPostWhenIdle are used. While the 
menu is visible, the notifications are posted ok (on the main thread), but 
objects do not receive the notifications until the menu is released. I don't 
quite understand why this should be (is the main loop not running when a menu 
is displayed, or are menu-related events somehow jumping the queue and 
preventing my notifications from reaching the head of the queue?). I feel there 
must be a way of keeping the GUI updated while the menu is down - any 
suggestions?

Many thanks
Jonny___

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

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

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

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


Calling allObjects memory allocation problem

2010-05-20 Thread Vassilis Pantazis
Hello,

I have in my code the following statement:

NSDirectoryEnumerator* dirEnum;
NSArray* inDirContents;

dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:inPath]; //
inPath is a valid path
inDirContents = [dirEnum allObjects];

I have noticed that when the path contains many objects, a significant
amount of memory is allocated that is not released, neither when trying to
explicitly release inDirContents, nor when using an autorelease pool.
Can someone explain to me why this happens please and how to solve it?

Kind regards to all, this is my first mail in this list.
Vas
___

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: Error 134100 - Core Data models incompatible

2010-05-20 Thread eric dolecki GMail
Well said.

Sent from my iPad

On May 20, 2010, at 6:54 PM, Fritz Anderson  wrote:

> On 20 May 2010, at 4:13 PM, Brad Gibbs wrote:
> 
>> Mac OS X 10.6.2, iPhone OS 4.0 beta 2 (although the iPad client started life 
>> before the first OS 4 beta was released).
> 
> And here is why you won't get any answers. The NDA you agreed to in order to 
> get the 4.0 SDK forbids you, and anyone who knows the answer, to discuss it 
> in public. The penalties can be draconian.
> 
> If you have access to prerelease software, you have access to the Apple 
> Developer Forums behind your login at developer.apple.com/iphone. Try there.
> 
>   — F
> 
> ___
> 
> 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/edolecki%40gmail.com
> 
> This email sent to edole...@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


migrating CoreData data model doesn't work

2010-05-20 Thread Rainer Standke
Hello,

when I select my data model in the xcode project, and then select Design/Data 
Model/Add Model Version I do get a new bundle in Xcode project, but now copy of 
the existing datamodel. The bundle, both in Xcode and on the Finder level, is 
empty. The app does not compile any more.

The only thing that might be unusual in this project - as far as I can tell - 
is that I have iVars in the ManagedObject classes that calculate some things on 
the fly, based on regular attributes. Could this be a reason for trouble?

I have no idea why this is going wrong, and would appreciate some help, greatly.

Thanks,

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: Error 134100 - Core Data models incompatible

2010-05-20 Thread Fritz Anderson
On 20 May 2010, at 4:13 PM, Brad Gibbs wrote:

> Mac OS X 10.6.2, iPhone OS 4.0 beta 2 (although the iPad client started life 
> before the first OS 4 beta was released).

And here is why you won't get any answers. The NDA you agreed to in order to 
get the 4.0 SDK forbids you, and anyone who knows the answer, to discuss it in 
public. The penalties can be draconian.

If you have access to prerelease software, you have access to the Apple 
Developer Forums behind your login at developer.apple.com/iphone. Try there.

— F

___

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: Displaying NSPopUpButtonCells in NSTableView

2010-05-20 Thread James Maxwell
hmm... Well, I've tried returning the cell's selectedItem, indexOfSelectedItem, 
and also:

[[inst MIDI_Inst_Ports] objectAtIndex:[ports indexOfSelectedItem]]

(that is, the port name at indexOfSelectedItem). 
If I NSLog the [ports indexOfSelectedItem] it's always zero. So I'm obviously 
not understanding how (or when) the cell gets selected.

Maybe the menu/cell selection is a separate process? Do I need to control the 
popup separately? 
I'll look into NSPopUpButtonCell again, but if anyone see's what I'm missing, 
please pop me a note.

thanks,

J.
 
On 2010-05-20, at 2:04 PM, James Maxwell wrote:

> ah, that makes sense. I'll make the change and see if that fixes it.
> 
> thanks, Peter.
> 
> J.
> 
> 
> On 2010-05-20, at 1:28 PM, Peter Ammon wrote:
> 
>> 
>> On May 20, 2010, at 1:14 PM, James Maxwell wrote:
>> 
>>> I thought I'd change the topic on this, since the content really has 
>>> changed.
>>> 
>>> I have an table for setting up MIDI instruments with a name, port, and 
>>> channel. I've got the initial display of options for the table row 
>>> displaying correctly, and when I make changes to the name, port, and 
>>> channel, the data object is updated correctly. The only thing left is that 
>>> the popups in columns 2 and 3 are not holding the selected value. I 
>>> understand that this is probably because I'm reloading the menu in 
>>> tableView:objectValueForTableColumn:row, but I'm not sure how to get around 
>>> it. 
>>> 
>>> Here's the code I've got so far. I'm not using an NSArrayController, 
>>> because that approach was driving me absolutely mental...
>>> I've copied all the code (except imports) to be thorough. Logging "Edited 
>>> MIDIInstrument" at the end shows that the instrument is set up correctly, 
>>> with the desire name, port, and channel. It's just that the popups always 
>>> display the 2nd item.
>> 
>> Hi James,
>> 
>> If you have a table view containing an NSPopUpButtonCell, the object value 
>> returned by your objectValueForTableColumn: method should be an NSNumber, 
>> which contains the index of the item that should be selected.  It looks like 
>> the attached code is returning the cell itself, which is strange, and I 
>> think that's causing the problem.
>> 
>> Hope this helps,
>> -Peter
>> 
> 
> 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/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


Error 134100 - Core Data models incompatible

2010-05-20 Thread Brad Gibbs
Hi,

I'm writing an iPad app with an OS X-based configuration utility.  The user 
enters data in the OS X-based config utility and exports it.  The iPad then 
picks up the SQLite file and uses it as its persistent store.  This was working 
fine 2 months ago.  I took a break on the iPad app to make some changes to the 
config utility.

After making changes to the data model used for the export, I deleted the data 
model in the iPad client app and copied the export data model from the config 
utility to the iPad app.  Now, i'm getting the dreaded Cocoa error 134100 - the 
model used to open the store is incompatible with the model used to create the 
store.  I've logged the metadata from the export store's persistent store and 
the persistent store the iPad client is trying to use.  They're identical.

Any ideas on what's causing the problem or how to troubleshoot this?

Mac OS X 10.6.2, iPhone OS 4.0 beta 2 (although the iPad client started life 
before the first OS 4 beta was released).

I only have one version of the data model.

Thanks in advance.

Brad
___

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:EPS image in NSScrollView

2010-05-20 Thread jyoung79
One other quick question.  What I'm really trying to achieve is something 
similar to how the pdfkit works.  I like how the image/text enlarges within the 
scrollview when the window is resized.  The code is pretty simple as well:

[pdfView setDocument:[[[PDFDocument alloc] initWithData:[fileMan 
contentsAtPath:filePath]] autorelease]];
[theBox setContentView:pdfView];

Is it possible to take an eps image and convert it to a pdf file so I can view 
it through the pdfkit?

Thanks.

Jay--- Begin Message ---
I'm getting a little closer to figuring this out, but hope that someone can
give me a little more info.  I found some Apple documentation that shows how
to programatically create an image in a scrollview.  Below, I've included the
code when the app starts up.  I'd like to have the imageRect the same width as
the scrollView is, but I want the image inside it to remain proportional.
The next step I'd like to do is make the image larger when I resize the 
window.  Below, I'm experimenting with the 'windowDidResize' which works for
making the image 1.2 bigger, but I'm not sure how to make it work when
resizing larger then back to smaller.  Would appreciate any thoughts.

Thanks.

Jay
 
--
theImage = [[NSImage alloc] initWithContentsOfFile:filePath];
imageWidth = [theImage size].width; // * 1.5;
imageHeight = [theImage size].height; // * 1.5;
imageRect = NSMakeRect(0.0, 0.0, imageWidth, imageHeight);
[theImageView setBounds:imageRect];
[theImageView setImageScaling:NSScaleToFit];
[theImageView setImage:theImage];
scrollView = [[NSScrollView alloc] initWithFrame:[[theBox contentView] frame]];
[scrollView setHasVerticalScroller:YES];
[scrollView setHasHorizontalScroller:YES];
[scrollView setBorderType:NSNoBorder];
[scrollView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
[scrollView setDocumentView:theImageView];
[theBox setContentView:scrollView];
--


--
 - (void)windowDidResize:(NSNotification *)notification {
imageRect.size.width = imageWidth * 1.2;
imageRect.size.height = imageHeight * 1.2;
[theImageView setBounds:imageRect];
[theImageView setImageScaling:NSScaleToFit];
 [theImageView setImage:theImage];
[scrollView setDocumentView:theImageView];
 [scrollView setFrame:imageRect];
[theBox setContentView:scrollView];
[scrollView setNeedsDisplay:YES];
}
--
--- End Message ---
___

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: Displaying NSPopUpButtonCells in NSTableView

2010-05-20 Thread James Maxwell
ah, that makes sense. I'll make the change and see if that fixes it.

thanks, Peter.

J.


On 2010-05-20, at 1:28 PM, Peter Ammon wrote:

> 
> On May 20, 2010, at 1:14 PM, James Maxwell wrote:
> 
>> I thought I'd change the topic on this, since the content really has changed.
>> 
>> I have an table for setting up MIDI instruments with a name, port, and 
>> channel. I've got the initial display of options for the table row 
>> displaying correctly, and when I make changes to the name, port, and 
>> channel, the data object is updated correctly. The only thing left is that 
>> the popups in columns 2 and 3 are not holding the selected value. I 
>> understand that this is probably because I'm reloading the menu in 
>> tableView:objectValueForTableColumn:row, but I'm not sure how to get around 
>> it. 
>> 
>> Here's the code I've got so far. I'm not using an NSArrayController, because 
>> that approach was driving me absolutely mental...
>> I've copied all the code (except imports) to be thorough. Logging "Edited 
>> MIDIInstrument" at the end shows that the instrument is set up correctly, 
>> with the desire name, port, and channel. It's just that the popups always 
>> display the 2nd item.
> 
> Hi James,
> 
> If you have a table view containing an NSPopUpButtonCell, the object value 
> returned by your objectValueForTableColumn: method should be an NSNumber, 
> which contains the index of the item that should be selected.  It looks like 
> the attached code is returning the cell itself, which is strange, and I think 
> that's causing the problem.
> 
> Hope this helps,
> -Peter
> 

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:EPS image in NSScrollView

2010-05-20 Thread jyoung79
I'm getting a little closer to figuring this out, but hope that someone can
give me a little more info.  I found some Apple documentation that shows how
to programatically create an image in a scrollview.  Below, I've included the
code when the app starts up.  I'd like to have the imageRect the same width as
the scrollView is, but I want the image inside it to remain proportional.
The next step I'd like to do is make the image larger when I resize the 
window.  Below, I'm experimenting with the 'windowDidResize' which works for
making the image 1.2 bigger, but I'm not sure how to make it work when
resizing larger then back to smaller.  Would appreciate any thoughts.

Thanks.

Jay
 
--
theImage = [[NSImage alloc] initWithContentsOfFile:filePath];
imageWidth = [theImage size].width; // * 1.5;
imageHeight = [theImage size].height; // * 1.5;
imageRect = NSMakeRect(0.0, 0.0, imageWidth, imageHeight);
[theImageView setBounds:imageRect];
[theImageView setImageScaling:NSScaleToFit];
[theImageView setImage:theImage];
scrollView = [[NSScrollView alloc] initWithFrame:[[theBox contentView] frame]];
[scrollView setHasVerticalScroller:YES];
[scrollView setHasHorizontalScroller:YES];
[scrollView setBorderType:NSNoBorder];
[scrollView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
[scrollView setDocumentView:theImageView];
[theBox setContentView:scrollView];
--


--
 - (void)windowDidResize:(NSNotification *)notification {
imageRect.size.width = imageWidth * 1.2;
imageRect.size.height = imageHeight * 1.2;
[theImageView setBounds:imageRect];
[theImageView setImageScaling:NSScaleToFit];
 [theImageView setImage:theImage];
[scrollView setDocumentView:theImageView];
 [scrollView setFrame:imageRect];
[theBox setContentView:scrollView];
[scrollView setNeedsDisplay:YES];
}
--

___

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: Displaying NSPopUpButtonCells in NSTableView

2010-05-20 Thread Peter Ammon

On May 20, 2010, at 1:14 PM, James Maxwell wrote:

> I thought I'd change the topic on this, since the content really has changed.
> 
> I have an table for setting up MIDI instruments with a name, port, and 
> channel. I've got the initial display of options for the table row displaying 
> correctly, and when I make changes to the name, port, and channel, the data 
> object is updated correctly. The only thing left is that the popups in 
> columns 2 and 3 are not holding the selected value. I understand that this is 
> probably because I'm reloading the menu in 
> tableView:objectValueForTableColumn:row, but I'm not sure how to get around 
> it. 
> 
> Here's the code I've got so far. I'm not using an NSArrayController, because 
> that approach was driving me absolutely mental...
> I've copied all the code (except imports) to be thorough. Logging "Edited 
> MIDIInstrument" at the end shows that the instrument is set up correctly, 
> with the desire name, port, and channel. It's just that the popups always 
> display the 2nd item.

Hi James,

If you have a table view containing an NSPopUpButtonCell, the object value 
returned by your objectValueForTableColumn: method should be an NSNumber, which 
contains the index of the item that should be selected.  It looks like the 
attached code is returning the cell itself, which is strange, and I think 
that's causing the problem.

Hope this helps,
-Peter

___

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


Displaying NSPopUpButtonCells in NSTableView

2010-05-20 Thread James Maxwell
I thought I'd change the topic on this, since the content really has changed.

I have an table for setting up MIDI instruments with a name, port, and channel. 
I've got the initial display of options for the table row displaying correctly, 
and when I make changes to the name, port, and channel, the data object is 
updated correctly. The only thing left is that the popups in columns 2 and 3 
are not holding the selected value. I understand that this is probably because 
I'm reloading the menu in tableView:objectValueForTableColumn:row, but I'm not 
sure how to get around it. 

Here's the code I've got so far. I'm not using an NSArrayController, because 
that approach was driving me absolutely mental...
I've copied all the code (except imports) to be thorough. Logging "Edited 
MIDIInstrument" at the end shows that the instrument is set up correctly, with 
the desire name, port, and channel. It's just that the popups always display 
the 2nd item.

thanks,

J.


@implementation MIDI_Instrument_Controller

@synthesize instrumentLibrary;
@synthesize selectedInstrument;

- (id)  init
{
self = [super init];
if(self)
{
NSMutableArray* inst = [[NSMutableArray alloc] init];
[self setInstrumentLibrary:inst];
[inst release];
}
return self;
}

- (IBAction)addInstrumentToLibrary: (id)sender
{
MIDIInstrument* newInst = [[MIDIInstrument alloc] init];
[[self instrumentLibrary] addObject:newInst];
[self setSelectedInstrument:newInst];
[newInst release];
[midiInstrumentsTable reloadData];
NSIndexSet* idxs = [NSIndexSet 
indexSetWithIndexesInRange:NSMakeRange(([[self instrumentLibrary] count] - 1), 
1)];
[midiInstrumentsTable selectRowIndexes:idxs byExtendingSelection:NO];
[midiInstrumentsTable editColumn:0 row:([[self instrumentLibrary] count] - 
1) withEvent:nil select:YES];
}

- (IBAction)removeInstrumentFromLibrary: (id)sender
{
if([self selectedInstrument] != nil)
{
[[self instrumentLibrary] removeObject:[self 
selectedInstrument]];
[midiInstrumentsTable reloadData];
}
}

- (void)tableViewSelectionDidChange: 
(NSNotification*)notification
{
int row = [midiInstrumentsTable selectedRow];
if(row >= 0)
[self setSelectedInstrument:[[self instrumentLibrary] 
objectAtIndex:row]];
}

- (NSInteger)   numberOfRowsInTableView:(NSTableView*)tv
{
if(tv == midiInstrumentsTable)
return [[self instrumentLibrary] count];
return 0;
}

- (id) tableView:(NSTableView *)tv objectValueForTableColumn:(NSTableColumn 
*)tc row:(NSInteger)row
{
NSLog(@"Updating instruments table...");
if(tv == midiInstrumentsTable)
{
id inst = [[self instrumentLibrary] objectAtIndex:row];
if(inst == nil)
return nil;
if(tc == midiInstNamesColumn)
{
// give the name for the associated MIDIInstrument
[tc setEditable:YES];
return [inst MIDI_Inst_Name];
}
else if(tc == midiPortsColumn)
{
// list the ports for the associated MIDIInstrument
[tc setEditable:YES];
NSPopUpButtonCell* ports = [tc dataCell];
[ports removeAllItems];
int i;
for(i=0;i < [[inst MIDI_Inst_Ports] count];i++)
[ports addItemWithTitle:[[inst MIDI_Inst_Ports] 
objectAtIndex:i]];
return ports;
}
else if(tc == midiChannelsColumn)
{
// list the channels for the associated MIDIInstrument 
(just 16 numbers)
[tc setEditable:YES];
NSPopUpButtonCell* channels = [tc dataCell];
[channels removeAllItems];
int i;
for(i=0;i < 16;i++)
[channels addItemWithTitle:[NSString 
stringWithFormat:@"%i", i+1]];
return channels;
}
}
return nil;
}

- (void) tableView:(NSTableView *)tv setObjectValue:(id)v 
forTableColumn:(NSTableColumn *)tc row:(NSInteger)row 
{
NSLog(@"Updating instruments...");
if (tv == midiInstrumentsTable) 
{
MIDIInstrument* inst = [[self instrumentLibrary] 
objectAtIndex:row];
if(inst == nil)
return;
if (tc == midiInstNamesColumn)  
{
// set the given name
[inst setMIDI_Inst_Name:v];

turning XMLString into XML nodes

2010-05-20 Thread Rainer Standke
Hello all,

I am wondering how to turn XML string fragments into XMLNodes or XMLElements. 
So far, the only thing I have come up with is to create a new, temporary 
NSXMLDocument and detach the rootelement from it. This seems a little clunky...

In the past I have used XMLLib in AppleScript, and it could turn strings into 
XML objects - is there something like that on NSXML somewhere?

As always, thanks!

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: "semi modal" view

2010-05-20 Thread B . J . Buchalter
Further to this, I have come up with appears to be a reasonable  
solution, but I would like to solicit feedback about the approach:


Rather than insert a NSTextField directly, I am now inserting a NSView  
subclass (call it BJJCoverView) as a subview of the content view of  
the window. This subclass then inserts the NSTextField into as a  
subview and postions it properly. Since there is no drawing  
implemented for BJJCoverView, it is not visible to the user, but since  
we get events for the view, we can detect when the user clicks outside  
the NSTextField. This seems to work well.


I needed to override - (void)viewWillStartLiveResize to detect when  
the user clicks on the resize widget of the window as that captures  
the click (the BJJCoverView does not see the mouse down).


One thing I still need to work out:

Is there any way to pass the "mouseDown" event to the view that would  
have gotten the click if my BJJCoverView was not over the view? Do I  
just need to find the view for the mouseDown event, and then send it a  
mouseDown message?


Thanks!

B.J. Buchalter
Metric Halo
http://www.mhlabs.com

On May 19, 2010, at 7:32 PM, B.J. Buchalter wrote:


Hey Folks,

I would like to implement something that I would describe as "popup"  
text entry. Effectively I have a view that displays some textual  
information. I would like to make it so that if the user clicks on  
the view it becomes a text entry box.


I have worked out how to insert a NSTextField into the view  
hierarchy and make it the first responder. That works well.


What I would like to do is make it so that if the user hits tab or  
enter, the "popup" text entry is removed and the text that was  
entered is commited. I think I understand how to do that.


I also need for the popup text entry to be removed when the user  
clicks outside of the NSTextField.


In my Carbon version of this, I made a modal window that I stuck the  
text edit field into, and I could detect if there was a click  
outside that window.


With Cocoa, Ideally, I would rather just let the event loop run  
normally, but I can't work out how to detect if the user has clicked  
outside of the NSTextField. Is there any way to do this easily, or  
do I need to run a local eventloop, or do I need to go back to the  
way I did it in Carbon and stick the entire text entry into its own  
window?


Any guidance (or pointers to the relevant docs would be greatly  
appreciated!!


___

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

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

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

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


Re: How does NSSavePanel support UTIs?

2010-05-20 Thread Quincey Morris
On May 20, 2010, at 12:14, James Walker wrote:

> The Uniform Type Identifiers Overview claims that NSSavePanel supports UTIs, 
> but the NSSavePanel class reference makes absolutely no mention of UTIs. 
> What's up with that?  I thought maybe there's be something like 
> setAllowedFileTypes: but with UTIs instead of extensions.

setAllowedFileTypes: accepts both UTIs and extensions. (UTIs are strings that 
always include at least one '.', so there's no confusion.)

This is documented in the UTI documentation and/or the Leopard release notes. 
Looks like just a documentation deficiency in NSSavePanel.


___

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


Listening for token deletion in NSTokenField

2010-05-20 Thread Duncan Oliver
Is there anyway to get some sort of notification for when a user
deletes a token in a NSTokenField? That's to say, is there a way to
know when a user has deleted a whole token when hitting the delete key
once? I have a NSTokenField linked to a managed object's relationship,
and need to nullify the relationship when the token is deleted. Thanks
in advance.
---
Duncan Oliver
duncan.oli...@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: Image from WebView is sometimes blank

2010-05-20 Thread Duncan Oliver
Thanks. I added the layout line, and that seems to have fixed it. I'll
have to do some more testing, but so far, I haven't had the problem
anymore.
---
Duncan Oliver
duncan.oli...@gmail.com

On Fri, May 14, 2010 at 1:27 PM, Adam R. Maxwell  wrote:
>
> On May 11, 2010, at 2:33 PM, Duncan Oliver wrote:
>
>> I have a WebView that I use to capture a thumbnail of a loaded webpage
>> using cacheDisplayInRect:. The WebView object is created
>> programmatically and not attached to a window. About half the time,
>> the image it grabs is blank. I can't seem to figure out if I'm trying
>> to grab it too soon or what. Would love to know how to get a completed
>> image all the time. Thanks in advance.
>
> This can be kind of tricky, especially when you need to make it work for 
> arbitrary pages; just figuring out when the webview finishes loading is 
> tricky, since -[WebView isLoading] doesn't account for redirection.
>
>>
>> Here's the code:
>>
>> - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
>> {
>>       if ([frame isEqualTo:[sender mainFrame]])
>>       {
>
> My first guess is that pages aren't fully loaded when you get this callback, 
> but that's generally only a problem with redirects.
>
>>               if ([sender saveThumbnail] == YES)
>>               {
>>                       NSView *mainFrameView = sender.mainFrame.frameView;
>>                       NSBitmapImageRep *thumbnailImageRep = [mainFrameView
>> bitmapImageRepForCachingDisplayInRect:[mainFrameView frame]];
>>                       [sender cacheDisplayInRect:[mainFrameView frame]
>>                                         toBitmapImageRep:thumbnailImageRep];
>
> Another potential problem is that you need to force layout in the 
> WebDocumentView; this shouldn't be necessary, but I couldn't find any other 
> workaround.  Try sending
>
> [[mainFrameView documentView] layout];
>
> before calling -cacheDisplayInRect:toBitmapImageRep:.  This fixed a bunch of 
> random white page issues for me.  If you use -[WebFrameView 
> setAllowsScrolling:NO] at some point, the problem is much worse (as of Safari 
> 4.0.3).
>
> I have a BSD-licensed web thumbnail class here:
>
> http://code.google.com/p/fileview/source/browse/trunk/fileview/FVWebViewIcon.m
>
> It's complicated by threading issues, but shows one way to track redirected 
> frames during loading, and also how to draw.
>
> hth,
> Adam
>
>
>
___

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

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

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

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


How does NSSavePanel support UTIs?

2010-05-20 Thread James Walker
The Uniform Type Identifiers Overview claims that NSSavePanel supports 
UTIs, but the NSSavePanel class reference makes absolutely no mention of 
UTIs.  What's up with that?  I thought maybe there's be something like 
setAllowedFileTypes: but with UTIs instead of extensions.

--
  James W. Walker, Innoventive Software LLC
  
___

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: Layer-hosting views and layer-backed scroll views

2010-05-20 Thread Kyle Sluder
On Thu, May 20, 2010 at 9:52 AM, Kyle Sluder  wrote:
> I have uploaded a sample project to
> http://www.lanechng.com/ScrolledLayerHostingView.zip. Resize the
> window to see the problem in action; then click one of the scroll
> arrows to see it fix itself.

Well, I've filed rdar://problem/8009542 with this demo project
attached. I've also been informed that IKImageBrowserView isn't
flipped, perhaps because of this very same issue. It's also the only
class besides NSView to implement _updateLayerGeometryFromView.
Needless to say, I'm more than a little suspicious that scroll views
are just plain broken.

--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: Get controller from nib

2010-05-20 Thread James Maxwell
So, I decided to get rid of the NSArrayController, since it was driving me 
slightly crazy, and just do this manually. I've got the table **appearing** as 
I'd like it to, but I can't change the selection. There are 3 columns: 1) 
string, 2) NSPopUpButtonCell for MIDI ports, and 3) NSPopUpButtonCell for MIDI 
channels. Basically, nothing can be changed. It comes up as 1) "default" (set 
in the init of MIDIInstrument), 2) as item 2 in column 2's popup, and 3) as 
item 2 in column 3's popup.

I don't know if maybe I have the functions of these two methods reversed 
somehow, or what. The naming of the methods is a bit unclear. I'm assuming that 
"objectValueForTableColumn" would mean what I want to "give" to the table for 
display, whereas "setObjectValue:forTableColumn" would be what I want to "give" 
to my object, from the table. Mind you, the latter would be clearer as 
"setObjectValue:fromTableColumn", if that was the case... dunno...

Here's my manual code for updating the table:

- (id) tableView:(NSTableView *)tv objectValueForTableColumn:(NSTableColumn 
*)tc row:(NSInteger)row
{
if(tv == midiInstrumentsTable)
{
id inst = [[self instrumentLibrary] objectAtIndex:row];
if(inst == nil)
return nil;
if(tc == midiInstNamesColumn)
{
// give the name for the associated MIDIInstrument
return [inst MIDI_Inst_Name];
}
else if(tc == midiPortsColumn)
{
// list the ports for the associated MIDIInstrument
NSPopUpButtonCell* ports = [tc dataCell];
[ports removeAllItems];
int i;
for(i=0;i < [[inst MIDI_Inst_Ports] count];i++)
[ports addItemWithTitle:[[inst MIDI_Inst_Ports] 
objectAtIndex:i]];
return ports;
}
else if(tc == midiChannelsColumn)
{
// list the channels for the associated MIDIInstrument 
(just 16 numbers)
NSPopUpButtonCell* channels = [tc dataCell];
[channels removeAllItems];
int i;
for(i=0;i < 16;i++)
[channels addItemWithTitle:[NSString 
stringWithFormat:@"%i", i+1]];
return channels;
}
}
return nil;
}

- (void) tableView:(NSTableView *)tv setObjectValue:(id)v 
forTableColumn:(NSTableColumn *)tc row:(NSInteger)row 
{
if (tv == midiInstrumentsTable) 
{
id inst = [[self instrumentLibrary] objectAtIndex:row];
if(inst == nil)
return;
if (tc == midiInstNamesColumn)  
{
// set the given name
[inst setMIDI_Inst_Name:[[tc dataCell] title]];
}
else if(tc == midiPortsColumn)
{
// set the selected port
[inst setMIDI_Inst_Port:[[[tc dataCell] selectedItem] 
title]];
}
else if(tc == midiChannelsColumn)
{
// set the selected channel
[inst setMIDI_Inst_Channel:[NSNumber 
numberWithInt:tc dataCell] selectedItem] title] integerValue]]];
}
}
}

Any help very much appreciated.

J.


On 2010-05-19, at 2:19 PM, James Maxwell wrote:

> okay, going slightly nuts. I've implemented my MIDI_Instrument_Controller 
> object, and hooked it up to my table view, but it's complaining about 
> implementing numberOrRowsInTableView and 
> tableView:objectValueForTableColumn:row:. Fine, except that I very definitely 
> have implemented them. I tried cleaning, and reloading classes in IB, to no 
> avail. Has anyone seen this? Any solutions?
> 
> J.
> 
> 
> 
> On 2010-05-18, at 6:27 PM, Mark Ritchie wrote:
> 
>> Hey James!
>> 
>> On 18/May/2010, at 5:42 PM, James Maxwell wrote:
>>> Okay, getting a bit deeper into this, I realize I'm still "in the woods", 
>>> so to speak. I'm going to have to hook up my NSTableView to set the 
>>> *selected* port and channel for the MIDIInstruments, which means it's 
>>> pretty much going to have to be loaded in the nib after all (since the 
>>> MIDIInstrument has to respond to the selection made in the table). So, if I 
>>> do that, and make the connections to Central_MIDI_Controller, as 
>>> recommended, will the NSArrayController be able to add new instances of 
>>> MIDIInstrument (and new rows to my table), which also have these 
>>> connections? As I mentioned, I need an arbitrary number of MIDIInstruments. 
>> 
>> It seems to me that you are not separating the model, view and controller 
>> bits.
>> To me, MIDIInstrumen

Re: Regarding MVC design pattern

2010-05-20 Thread mmalc Crawford

On May 20, 2010, at 7:40 am, Thomas Davie wrote:

>> However, you should typically not invoke accessor methods in init or dealloc 
>> methods.
> 
> Can I ask why you shouldn't use them in init?  It makes a lot of sense to not 
> use them in alloc/dealloc, but I'm not using them in init... after all, what 
> if I replace the ivar with a derived property from another object?  Why 
> should I have to recode my init?



mmalc

___

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


Layer-hosting views and layer-backed scroll views

2010-05-20 Thread Kyle Sluder
We have a layer-hosting document view that is contained in a
layer-backed scroll view. We have noticed that the scroll view does
some funky stuff to the layer if the view's -isFlipped returns YES.
This manifests itself in our app in the form of our document view
being scrolled by the correct amount but in the wrong direction at
startup. Everything gets fixed if the user scrolls the document.

Is there a known bug with NSScrollView and layer-hosting views? It
looks like NSClipView's implementation of
-_updateLayerGeometryFromView is at fault here. It is not being called
to correctly position the document view's layer within the clip view.

I have uploaded a sample project to
http://www.lanechng.com/ScrolledLayerHostingView.zip. Resize the
window to see the problem in action; then click one of the scroll
arrows to see it fix itself.

--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: Regarding MVC design pattern

2010-05-20 Thread Kyle Sluder
On Thu, May 20, 2010 at 9:27 AM, Dave Keck  wrote:
> I'm not a fan of isInitialized either, but even less enthralled by
> duplicated code. Furthermore, couldn't one make the case that a class
> that's well-fit for subclassing has exactly one technique for setting
> a property (the setter), giving subclasses full control over that
> behavior?

Not saying your concerns are invalid, but the problem isn't so much
with the initialization of the duplicated code than it is with the
timing within the superclass's init method. Not only is the subclass
sensitive to the fact that its -init implementation needs to call
super's designated initializer before it's done any initialization of
its own, but it's also sensitive to the ordering of multiple accessor
calls within super's initializer implementation.

The only code that should wind up duplicated is an assignment and
perhaps a call to -retain or -release.

> We've been over this before so I'll leave it at that.

Agreed.

--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: Regarding MVC design pattern

2010-05-20 Thread Dave Keck
> You can get away with a lot of things if you don't care about writing
> subclass-tolerant code. But since I don't have a crystal ball, I don't
> write code which I know will require hacky "isInitialized" flags to be
> correct.

I'm not a fan of isInitialized either, but even less enthralled by
duplicated code. Furthermore, couldn't one make the case that a class
that's well-fit for subclassing has exactly one technique for setting
a property (the setter), giving subclasses full control over that
behavior?

We've been over this before so I'll leave it at that.
___

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: Regarding MVC design pattern

2010-05-20 Thread Kyle Sluder
On Thu, May 20, 2010 at 8:27 AM, Dave Keck  wrote:
> Which could be solved with a simple if-statement within the subclass'
> -setContent:, allowing you to use accessors everywhere to avoid code
> duplication and giving your subclasses full control over the setting
> of the content property.

You can get away with a lot of things if you don't care about writing
subclass-tolerant code. But since I don't have a crystal ball, I don't
write code which I know will require hacky "isInitialized" flags to be
correct.

Since I didn't write the superclass, I did in fact have to set an
"isInitialized" flag, call -initWithContent: with a nil argument, and
then at the end of my initializer call -setContent: with the object I
intended to call it with originally.

> This issue is highly debated to the point that it is merely a question
> of style. Mike Ash has an excellent article on the topic here:

Mike is overly dismissive of subclassing concerns and KVO. That's
exactly what my overridden -setContent: does.

--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: Regarding MVC design pattern

2010-05-20 Thread Dave Keck
> I'll give you a concrete example. We have an NSController-like class that
> lives in a framework. Its designated intializer is -initWithContent:. In one
> of our apps, we have a subclass of this whose initializer is
> -initWithDocument:, and which uses the document to figure out its content.
> It also overrides -setContent: to register for notifications and the like.
> -setContent: relies on certain state that is set up in -initWithDocument:,
> but this setup can't be done until -initWithDocument: calls -[super
> initWithContent:]. But that method uses the -setContent: setter to set its
> content property. Boom!

Which could be solved with a simple if-statement within the subclass'
-setContent:, allowing you to use accessors everywhere to avoid code
duplication and giving your subclasses full control over the setting
of the content property.

This issue is highly debated to the point that it is merely a question
of style. Mike Ash has an excellent article on the topic here:


http://www.mikeash.com/pyblog/friday-qa-2009-11-27-using-accessors-in-init-and-dealloc.html
___

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: Regarding MVC design pattern

2010-05-20 Thread glenn andreas

On May 20, 2010, at 9:47 AM, Thomas Davie wrote:

> 
> On 20 May 2010, at 15:45, Barry Skidmore wrote:
> 
>> If you need to have it set you should create an initWithOptionName: and call 
>> that from your standard init, or return an error stating a missing value is 
>> needed.
>> 
>> Your init should always call down tithe most specific init.
>> 
>> Specific examples of this are available as best practice in several cocoa 
>> and design pattern books.
> 
> I think you've misunderstood what I was asking.
> 
> If I use a setter (in the most specific init), then I don't need to recode 
> (even the most specific init) if I change how the property is implemented.
> 
> If I don't use the setter, I do.
> 
> What I was asking was why you would want to avoid using setters in the init 
> method... Is there some safety issue I've missed?


The problem is that if you later subclass that object and override the setter 
in the subclass, this means that code in the subclass (the setter) is run 
before the subclasses init has run.  This may be a problem if the subclass 
setter assumes that various other values in the subclass are properly 
initialized.  So:

@interface ClassA : NSObject {
AnObject *ivar;
}
@property (nonatomic, retain) AnObject *ivar;
@end

// A subclass of ClassA that add some sort of logging/transcript
@interface ClassB : ClassA
@property (nonatomic, readonly) id uniqueId;
@end

@implementation ClassA
@synthesize ivar;
- (id) init
{
self = [super init];
if (self) {
self.ivar = some value; // (1)
}
return self;
}
@end

@interface ClassB
- (id) init
{
self = [super init]; // (2)
if (self) {
self.uniqueId = [UniqueId uniqueId]; // (4) in keeping with the 
bad style, we call our setter here as well
}
return self;
}
- (void) setIvar: (AnObject *) obj
{
[[Transcript currentTranscript] setProperty: @"ivar" ofObject: 
self.uniqueId toValue: obj ]; // (3)
[super setIvar: obj];
}
@end

So when you do:

[[ClassA alloc] init];

everything is fine, but

[[ClassB alloc] init];

when it gets to (2), calls the super init and at (1) ends up calling code at 
(3).  But self.uniqueId will be nil (since the code at (4) hasn't been reached 
yet), and the -[Transcript setProperty:ofObject:toValue:] may not be able to 
deal with nil as the object parameter.




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: Simulating Text Input

2010-05-20 Thread Eiko Bleicher
Flavio,

thanks! This should be a good starting point for the lookup table, it does what 
I wanted to do (at least it looks like it). :-)

Eiko

Am 20.05.2010 um 16:57 schrieb Flavio Donadio:

> Eiko,
> 
> 
> There's some code in OSXvnc that might help with this. Check this file:
> 
> http://osxvnc.cvs.sourceforge.net/viewvc/osxvnc/OSXvnc/VNCBundle.m?revision=1.2&view=markup
> 
> It creates a "keyTable" with Unicode characters as indexes and CGKeyCodes as 
> values, based on the selected keyboard layout.  Pseudo-code:
> 
> CGEventCreateKeyboardEvent (NULL, (CGKeyCode)theKeyTable[someUnichar], true);
> 
> 
> Cheers,
> Flavio
> 
> 
> On 20/05/2010, at 11:13, Eiko Bleicher wrote:
> 
>> Sure, CGEventCreateKeyboardEvent was the first obvious way (and probably the 
>> one I'll stick with).
>> 
>> Just be warned that the codes are different for each keyboard layout, so 
>> already the stock code
>> 
>> CGEventRef event1, event2, event3, event4;
>> event1 = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)56, true);
>> event2 = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)6, true);
>> event3 = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)6, false);
>> event4 = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)56, false);
>> 
>> will produce varying results - "Z" on English QUERTY keyboards, "Y" on 
>> German QUERTZ ones. Given many many different layouts it is at least not 
>> trivial to get the characters / strings you need...
>> 
>> Eiko
>> 
>> 
>> Am 20.05.2010 um 15:55 schrieb Flavio Donadio:
>> 
>>> Paul and Eiko,
>>> 
>>> 
>>> I just checked OSXvnc's source code. Their code led me to the right place, 
>>> but it's fairly complex for a beginner (like myself) to learn how to post 
>>> keyboard events (generate keystrokes or simulating keyboard input).
>>> 
>>> The functions needed for this are in Quartz / Core Graphics. OSXvnc still 
>>> uses CGPostKeyboardEvent, which is now deprecated in 10.6. Apple suggests 
>>> CGEventCreateKeyboardEvent as a substitute.
>>> 
>>> Check Developer Documentation for more information. There's a code snippet 
>>> in CGEventCreateKeyboardEvent's reference that makes things very clear.
>>> 
>>> 
>>> Cheers,
>>> Flavio
>>> 
>>> On 19/05/2010, at 16:53, Paul Sanders wrote:
>>> 
> I am interested in simulating text input (maybe via generating 
> keystrokes), but never found an example for that.
 
 Well VNC must simulate keystrokes somewhere along the line, although 
 finding it may take a bit of digging around in the sources.  As you say, 
 mapping all the various keycodes is likely to be painful.
 
 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: Regarding MVC design pattern

2010-05-20 Thread Kyle Sluder

On May 20, 2010, at 7:40 AM, Thomas Davie  wrote:

Can I ask why you shouldn't use them in init?  It makes a lot of  
sense to not use them in alloc/dealloc, but I'm not using them in  
init... after all, what if I replace the ivar with a derived  
property from another object? Why should I have to recode my init?


I'll give you a concrete example. We have an NSController-like class  
that lives in a framework. Its designated intializer is - 
initWithContent:. In one of our apps, we have a subclass of this whose  
initializer is -initWithDocument:, and which uses the document to  
figure out its content. It also overrides -setContent: to register for  
notifications and the like. -setContent: relies on certain state that  
is set up in -initWithDocument:, but this setup can't be done until - 
initWithDocument: calls -[super initWithContent:]. But that method  
uses the -setContent: setter to set its content property. Boom!


--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: Simulating Text Input

2010-05-20 Thread Flavio Donadio
Eiko,


There's some code in OSXvnc that might help with this. Check this file:

http://osxvnc.cvs.sourceforge.net/viewvc/osxvnc/OSXvnc/VNCBundle.m?revision=1.2&view=markup

It creates a "keyTable" with Unicode characters as indexes and CGKeyCodes as 
values, based on the selected keyboard layout.  Pseudo-code:

CGEventCreateKeyboardEvent (NULL, (CGKeyCode)theKeyTable[someUnichar], true);


Cheers,
Flavio


On 20/05/2010, at 11:13, Eiko Bleicher wrote:

> Sure, CGEventCreateKeyboardEvent was the first obvious way (and probably the 
> one I'll stick with).
> 
> Just be warned that the codes are different for each keyboard layout, so 
> already the stock code
> 
> CGEventRef event1, event2, event3, event4;
> event1 = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)56, true);
> event2 = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)6, true);
> event3 = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)6, false);
> event4 = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)56, false);
> 
> will produce varying results - "Z" on English QUERTY keyboards, "Y" on German 
> QUERTZ ones. Given many many different layouts it is at least not trivial to 
> get the characters / strings you need...
> 
> Eiko
> 
> 
> Am 20.05.2010 um 15:55 schrieb Flavio Donadio:
> 
>> Paul and Eiko,
>> 
>> 
>> I just checked OSXvnc's source code. Their code led me to the right place, 
>> but it's fairly complex for a beginner (like myself) to learn how to post 
>> keyboard events (generate keystrokes or simulating keyboard input).
>> 
>> The functions needed for this are in Quartz / Core Graphics. OSXvnc still 
>> uses CGPostKeyboardEvent, which is now deprecated in 10.6. Apple suggests 
>> CGEventCreateKeyboardEvent as a substitute.
>> 
>> Check Developer Documentation for more information. There's a code snippet 
>> in CGEventCreateKeyboardEvent's reference that makes things very clear.
>> 
>> 
>> Cheers,
>> Flavio
>> 
>> On 19/05/2010, at 16:53, Paul Sanders wrote:
>> 
 I am interested in simulating text input (maybe via generating 
 keystrokes), but never found an example for that.
>>> 
>>> Well VNC must simulate keystrokes somewhere along the line, although 
>>> finding it may take a bit of digging around in the sources.  As you say, 
>>> mapping all the various keycodes is likely to be painful.
>>> 
>>> 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: Regarding MVC design pattern

2010-05-20 Thread Barry Skidmore
Ah I see.  Not that I am aware of, in fact if you require a set  
property  in your object then init is the best place for it to be.


Sent from my iPhone

On May 20, 2010, at 9:47 AM, Thomas Davie  wrote:



On 20 May 2010, at 15:45, Barry Skidmore wrote:

If you need to have it set you should create an initWithOptionName:  
and call that from your standard init, or return an error stating a  
missing value is needed.


Your init should always call down tithe most specific init.

Specific examples of this are available as best practice in several  
cocoa and design pattern books.


I think you've misunderstood what I was asking.

If I use a setter (in the most specific init), then I don't need to  
recode (even the most specific init) if I change how the property is  
implemented.


If I don't use the setter, I do.

What I was asking was why you would want to avoid using setters in  
the init method... Is there some safety issue I've missed?


Bob

___

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: Regarding MVC design pattern

2010-05-20 Thread Thomas Davie

On 20 May 2010, at 15:45, Barry Skidmore wrote:

> If you need to have it set you should create an initWithOptionName: and call 
> that from your standard init, or return an error stating a missing value is 
> needed.
> 
> Your init should always call down tithe most specific init.
> 
> Specific examples of this are available as best practice in several cocoa and 
> design pattern books.

I think you've misunderstood what I was asking.

If I use a setter (in the most specific init), then I don't need to recode 
(even the most specific init) if I change how the property is implemented.

If I don't use the setter, I do.

What I was asking was why you would want to avoid using setters in the init 
method... Is there some safety issue I've missed?

Bob___

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: Regarding MVC design pattern

2010-05-20 Thread Barry Skidmore
If you need to have it set you should create an initWithOptionName:  
and call that from your standard init, or return an error stating a  
missing value is needed.


Your init should always call down tithe most specific init.

Specific examples of this are available as best practice in several  
cocoa and design pattern books.


Sent from my iPhone

On May 20, 2010, at 9:40 AM, Thomas Davie  wrote:



On 20 May 2010, at 15:24, mmalc Crawford wrote:



On May 19, 2010, at 4:38 am, Sherm Pendley wrote:

If you set the ivars directly, as above, the synthesized setters  
will

NOT be called. For that to happen, you need to use dot-syntax, like
this:

- (void) dealloc {
 self.beginButton = nil;
 self.endButton = nil;
 // etc...
 [super dealloc];
}

You do not *need* to use the dot syntax to invoke the accessors  
synthesised for a property. You can also use the corresponding  
accessor method using [] syntax, e.g.


   [self setBeginButton:nil];

However, you should typically not invoke accessor methods in init  
or dealloc methods.


Can I ask why you shouldn't use them in init?  It makes a lot of  
sense to not use them in alloc/dealloc, but I'm not using them in  
init... after all, what if I replace the ivar with a derived  
property from another object? Why should I have to recode my init?


Bob___

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/atri%40me.com

This email sent to a...@me.com

___

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

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

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

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


Re: Regarding MVC design pattern

2010-05-20 Thread Thomas Davie

On 20 May 2010, at 15:24, mmalc Crawford wrote:

> 
> On May 19, 2010, at 4:38 am, Sherm Pendley wrote:
> 
>> If you set the ivars directly, as above, the synthesized setters will
>> NOT be called. For that to happen, you need to use dot-syntax, like
>> this:
>> 
>> - (void) dealloc {
>>   self.beginButton = nil;
>>   self.endButton = nil;
>>   // etc...
>>   [super dealloc];
>> }
>> 
> You do not *need* to use the dot syntax to invoke the accessors synthesised 
> for a property. You can also use the corresponding accessor method using [] 
> syntax, e.g.
> 
>   [self setBeginButton:nil];
> 
> However, you should typically not invoke accessor methods in init or dealloc 
> methods.

Can I ask why you shouldn't use them in init?  It makes a lot of sense to not 
use them in alloc/dealloc, but I'm not using them in init... after all, what if 
I replace the ivar with a derived property from another object?  Why should I 
have to recode my init?

Bob___

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


Changing the view that's used for a print operation

2010-05-20 Thread Gideon King
It appears that when you create a print operation, it is directly associated 
with a view. In my print accessory, I can make changes that would make it much 
easier to render the data that the user is requesting by using a different 
view. Is there any way to change the view or maybe swap out the print operation 
for another one with a different view when the user makes these changes in the 
print setup?

I guess it would be possible to do something nasty like adding a subview and 
adjusting the pagination if I can't just replace it with a different view 
altogether, but I am hoping to avoid such ugliness.

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: Regarding MVC design pattern

2010-05-20 Thread mmalc Crawford

On May 19, 2010, at 1:48 am, Sai wrote:

> 1. Look at the awakeFromNib method of Controller, my output of the retain
> count to the console are
> myModel retain count: 5
> controller retain count: 17
> both number are very surprised me, why is that? I suppose they should be 2
> or 1?
> Can anyone explain please?
> 
The documentation is abundantly clear on this issue:



mmalc

___

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: Regarding MVC design pattern

2010-05-20 Thread mmalc Crawford

On May 19, 2010, at 4:38 am, Sherm Pendley wrote:

> If you set the ivars directly, as above, the synthesized setters will
> NOT be called. For that to happen, you need to use dot-syntax, like
> this:
> 
> - (void) dealloc {
>self.beginButton = nil;
>self.endButton = nil;
>// etc...
>[super dealloc];
> }
> 
You do not *need* to use the dot syntax to invoke the accessors synthesised for 
a property. You can also use the corresponding accessor method using [] syntax, 
e.g.

[self setBeginButton:nil];

However, you should typically not invoke accessor methods in init or dealloc 
methods.

mmalc

___

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


Binding CoreData Managed Object to NSTextFieldCell subclass

2010-05-20 Thread Nial Giacomelli
I have an NSTableView which has its first column set to contain a custom
NSTextFieldCell. My custom NSTextFieldCell needs to allow the user to edit a
"desc" property within my Managed Object but to also display an "info"
string that it contains (which is not editable). To achieve this, I followed
this tutorial (
http://www.timisted.net/blog/archive/custom-cells-and-core-data/). In a
nutshell, the tutorial suggests editing your Managed Objects generated
subclass to create and pass a dictionary of its contents to your
NSTableColumn via bindings.

This works well for read-only NSCell implementations, but I'm looking to
subclass NSTextFieldCell to allow the user to edit the "desc" property of my
Managed Object. To do this, I followed one of the articles comments, which
suggests subclassing NSFormatter to explicitly state which Managed Object
property you would like the NSTextFieldCell to edit. I've posted the code of
my NSFormatter subclass here (http://pastebin.org/257930) for reference.

This seems to work, but is extremely patch. On occasion, clicking to edit a
row will cause its value to nullify. On other occasions, the value you enter
on one row will populate other rows within the table.

I've been doing a lot of reading on this subject and would really like to
get to the bottom of this. What's more frustrating is that my
NSTextFieldCell is rendering exactly how I would like it to. This editing
issue is my last obstacle! If anyone can help, that would be greatly
appreciated.
___

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

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

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

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


Re: Simulating Text Input

2010-05-20 Thread Eiko Bleicher
Sure, CGEventCreateKeyboardEvent was the first obvious way (and probably the 
one I'll stick with).

Just be warned that the codes are different for each keyboard layout, so 
already the stock code

CGEventRef event1, event2, event3, event4;
event1 = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)56, true);
event2 = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)6, true);
event3 = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)6, false);
event4 = CGEventCreateKeyboardEvent (NULL, (CGKeyCode)56, false);

will produce varying results - "Z" on English QUERTY keyboards, "Y" on German 
QUERTZ ones. Given many many different layouts it is at least not trivial to 
get the characters / strings you need...

Eiko


Am 20.05.2010 um 15:55 schrieb Flavio Donadio:

> Paul and Eiko,
> 
> 
> I just checked OSXvnc's source code. Their code led me to the right place, 
> but it's fairly complex for a beginner (like myself) to learn how to post 
> keyboard events (generate keystrokes or simulating keyboard input).
> 
> The functions needed for this are in Quartz / Core Graphics. OSXvnc still 
> uses CGPostKeyboardEvent, which is now deprecated in 10.6. Apple suggests 
> CGEventCreateKeyboardEvent as a substitute.
> 
> Check Developer Documentation for more information. There's a code snippet in 
> CGEventCreateKeyboardEvent's reference that makes things very clear.
> 
> 
> Cheers,
> Flavio
> 
> On 19/05/2010, at 16:53, Paul Sanders wrote:
> 
>>> I am interested in simulating text input (maybe via generating keystrokes), 
>>> but never found an example for that.
>> 
>> Well VNC must simulate keystrokes somewhere along the line, although finding 
>> it may take a bit of digging around in the sources.  As you say, mapping all 
>> the various keycodes is likely to be painful.
>> 
>> 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: NSData from CGPDFPageRef

2010-05-20 Thread Christian Ziegler
Thanks for your reply Kyle!

Well, I don't know the exact data structure of pdfs but I'm just figuring it 
out step by step. Anyways, what I am trying to achieve is, to create a kind of 
fingerprint of a pdf page and it should be as performant as possible and as 
platform independent as possible (that may be too much too ask but we'll see). 
I would assume extracting a page and creating a new document is not very 
efficient? I just want to avoid parsing, but it looks like I won't get around 
that. I'll just have to figure out whether parsing every single object/operator 
in the stream(s) of a page is necessary.

Cheers,
Chris

On 20.05.2010, at 15:26, Kyle Sluder wrote:

> On May 20, 2010, at 4:25 AM, Christian Ziegler  wrote:
> 
>> unfortunately that is not what I'm looking for. I want to be able to load an 
>> existing pdf file and create some byte representation of each page.
> 
> This doesn't really make any sense. How is a PDF page meaningful outside of a 
> PDF document? What would a "data representation" of a page contain?
> 
> You could extract the page into its own document and get a data 
> representation of that.
> 
> --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: Simulating Text Input

2010-05-20 Thread Flavio Donadio
Paul and Eiko,


I just checked OSXvnc's source code. Their code led me to the right place, but 
it's fairly complex for a beginner (like myself) to learn how to post keyboard 
events (generate keystrokes or simulating keyboard input).

The functions needed for this are in Quartz / Core Graphics. OSXvnc still uses 
CGPostKeyboardEvent, which is now deprecated in 10.6. Apple suggests 
CGEventCreateKeyboardEvent as a substitute.

Check Developer Documentation for more information. There's a code snippet in 
CGEventCreateKeyboardEvent's reference that makes things very clear.


Cheers,
Flavio

On 19/05/2010, at 16:53, Paul Sanders wrote:

> > I am interested in simulating text input (maybe via generating keystrokes), 
> > but never found an example for that.
> 
> Well VNC must simulate keystrokes somewhere along the line, although finding 
> it may take a bit of digging around in the sources.  As you say, mapping all 
> the various keycodes is likely to be painful.
>  
> 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


[iPhone] How to scale a UITextView Properly with typing text shown

2010-05-20 Thread Tharindu Madushanka
I use following code in UITextView Delegate method to resize the text view.
I want it to look like iPhone Messages.

Still this doesn't show the already typed text on top. I mean it doesn't
scroll to the correct typing position in text view. Could anyone kindly
correct this code ? To scroll the text view properly to typing text when
scaling.

- (void)textViewDidChange:(UITextView *)textView {

CGSize textSize = [textview.text sizeWithFont:textview.font
constrainedToSize:textview.contentSize
lineBreakMode:UILineBreakModeWordWrap];

int rtxtHeight = textview.contentSize.height - 16.0f;

int noOfLines = rtxtHeight / 21;

NSLog(@"No Of Lines: %d content:%f", noOfLines,
textview.contentSize.height);

CGRect tbframe = tableview.frame;

float changeHeight = rtxtHeight + 16.0f;

CGRect tframe = textview.frame;

NSLog(@"[MessageViewController] change:%f
contentHeight:%f",changeHeight, textSize.height);
if (changeHeight != tframe.size.height && noOfLines > 0 && noOfLines <
5) {

if (tframe.size.height > changeHeight) {
tframe.origin.y += 21.0f;
tbframe.size.height += 21.0f;

} else {
tframe.origin.y -= 21.0f;
tbframe.size.height -= 21.0f;
}


tframe.size.height = changeHeight;

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.3f];
tableview.frame = tbframe;
textview.frame = tframe;
//textview.frame = tframe;
[UIView commitAnimations];


}

}

Tharindu
___

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: Regarding MVC design pattern

2010-05-20 Thread Kyle Sluder
On Thu, May 20, 2010 at 5:44 AM, Joanna Carter
 wrote:
> Le 20 mai 2010 à 13:24, Alexander Spohr a écrit :
> Yes, because the ivar is synthesised, addressing myFoo would send the release 
> message to the property, which is not recommended.

No. "Send the release message to the property" is a meaningless
phrase. Only objects can receive release messages, and the property
accessor returns the same address that is stored in the ivar, so the
same object would receive the -release message. Also, property
accessors are only called with either dot or method syntax; plain old
`myFoo = bar` will not call -setFoo:.

> Apparently, self->myFoo is capable of reaching the synthesised ivar.

Alexander is correct that plain old `myFoo` will also access the
synthesized ivar. There used to be a GCC bug in which synthesized
ivars were inaccessible (at least through self-> syntax; now I can't
recall whether they were wholly inaccessible). That, combined with the
fact that there is no declaration of the ivar in scope, has led me to
always use self-> syntax. I can't even recall seeing it documented
that @synthesize myFoo; puts the myFoo symbol in scope; if it has ever
been documented, I can't find it now.

--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: NSData from CGPDFPageRef

2010-05-20 Thread Kyle Sluder
On May 20, 2010, at 4:25 AM, Christian Ziegler   
wrote:


unfortunately that is not what I'm looking for. I want to be able to  
load an existing pdf file and create some byte representation of  
each page.


This doesn't really make any sense. How is a PDF page meaningful  
outside of a PDF document? What would a "data representation" of a  
page contain?


You could extract the page into its own document and get a data  
representation of that.


--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: Original iPhone animation performance

2010-05-20 Thread Rafael Cerioli
I would advise you to check the transparency in your image. Compositing is not 
a simple task to do. And with the Core Animation Instrument, you can see your 
FPS and you can color layers that are rendered offscreen. That might give you 
some clues. 



Rafael Cerioli

 
Le 19 mai 2010 à 18:51, Andrew a écrit :

> Hi Ricky,
> 
> that is interesting, for some reason I assumed that the presentation layer 
> would take care of caching the presented view.
> 
> ok, I will try that and see how it goes, thanks.
> 
> 
> is there anything else you can think of that might make a difference?
> 
> 
> - Andrew Bush
> 
> 
>> 
>>> Im writing some code to animate an image moving up the display, just a 
>>> simple thing moving from the bottom to the top.
>>> 
>>> the image is 75x75, and Im displaying that in a CALayer sized to 45x45 by 
>>> setting its .contents property to the .CGImage of the UIImage.
>> 
>> This could be the issue.  On iPhone OS, try your best not to scale any 
>> images repeatedly.  Thus, you should create an alternate version of your 
>> image at 45 x 45 and then animate that.
>> 
>>> on the newer phones this runs very smoothly, even if I have more than one 
>>> of those CALayers animating at once, but on an older (original) iPhone I am 
>>> testing on the animation is slightly rough/jerky even with only a single 
>>> image moving.
>>> 
>>> 
>>> The iPhone is running 3.1.3 and I am performing the animation using this 
>>> code:
>>> 
>>> CABasicAnimation* animation = [CABasicAnimation animation];
>>> animation.keyPath = @"position.y";
>>> 
>>> CGFloat from=self.position.y;
>>> CGFloat to=self.position.y-[self.calculator 
>>> distanceForAnimationStartingAt:from];
>>> 
>>> animation.fromValue = [NSNumber numberWithFloat:from];
>>> animation.toValue = [NSNumber numberWithFloat:to];
>>> 
>>> CGFloat distance=to-from;
>>> 
>>> animation.duration = [self.calculator timeToTravelDistance:distance];
>>> animation.repeatCount = 1;
>>> animation.autoreverses = NO;
>>> animation.timingFunction = [CAMediaTimingFunction functionWithName: 
>>> kCAMediaTimingFunctionEaseInEaseOut];
>>> animation.removedOnCompletion = NO;
>>> animation.fillMode = kCAFillModeForwards;
>>> animation.delegate=self;
>>> [self addAnimation:animation forKey:@"animateUp"];
>>> 
>>> 
>>> so, obviously the older phone is basically just less capable, but is it 
>>> likely to be possible to smooth things out?  are there any known tricks or 
>>> things I can do that might improve things on the older hardware?
>>> 
>>> 
>>> Thanks for any help.
>>> 
>>> 
>>> - Andrew Bush
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> ___
>>> 
>>> 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/rsharp%40mac.com
>>> 
>>> This email sent to rsh...@mac.com
>> 
>> ___
>> Ricky A. Sharp mailto:rsh...@instantinteractive.com
>> Instant Interactive(tm)   http://www.instantinteractive.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/rafael.cerioli%40gmail.com
> 
> This email sent to rafael.ceri...@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: Regarding MVC design pattern

2010-05-20 Thread Joanna Carter
Le 20 mai 2010 à 13:24, Alexander Spohr a écrit :

> Why not just using myFoo without the self->?
> To make it visible that you talk to an ivar?

Yes, because the ivar is synthesised, addressing myFoo would send the release 
message to the property, which is not recommended.

Apparently, self->myFoo is capable of reaching the synthesised ivar.

Joanna

--
Joanna Carter
Carter Consulting

___

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: Regarding MVC design pattern

2010-05-20 Thread Alexander Spohr

Am 19.05.2010 um 19:12 schrieb Kyle Sluder:

> On Wed, May 19, 2010 at 4:38 AM, Sherm Pendley  
> wrote:
> If you synthesize your ivars, you can get at the ivar using the self-> syntax.
> 
>  self->myFoo = [aFoo retain];
>  [self->myFoo release];

Why not just using myFoo without the self->?
To make it visible that you talk to an ivar?

atze

___

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: NSData from CGPDFPageRef

2010-05-20 Thread Christian Ziegler
Hi Gustavo,

unfortunately that is not what I'm looking for. I want to be able to load an 
existing pdf file and create some byte representation of each page.

Cheers,
Chris


On 20.05.2010, at 12:08, Gustavo Pizano wrote:

> Hello Christian
> 
> This method was given to me yesterday by Jack Nutting... I dunno if its what 
> you are looking for.
> 
> 
> 
> 
> On Wed, May 19, 2010 at 12:07 PM, Gustavo Pizano
>  wrote:
>> Hello all.
>> 
>> I would want to know if I can render pdf  into iPad using quartz, or I have 
>> to use UIWebView... or whats the way to achieve this?
>> 
>> 
> 
> The basics are very simple:
> 
> - (NSData *)pdfDataForView:(UIView *)myView inRect:(CGRect)bounds {
>  // set up PDF rendering context
>  NSMutableData *pdfData = [NSMutableData data];
> 
>  UIGraphicsBeginPDFContextToData(pdfData, bounds, nil);
>  UIGraphicsBeginPDFPage();
> 
>  // tell our view to draw
>  [myView drawRect:bounds];
> 
>  // remove PDF rendering context
>  UIGraphicsEndPDFContext();
> 
>  return pdfData;
> }
> 
> If you need to do a multipage document, it will get more complicated.
> 
> HTH,
> 
> -- 
> // jack
> // http://nuthole.com
> // http://learncocoa.org
> On 20.5.2010, at 11:59, Christian Ziegler wrote:
> 
>> Hi all,
>> 
>> can anyone think of a way to get an NSData object out of a CGPDFPageRef?
>> 
>> Cheers,
>> 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/gustavxcodepicora%40gmail.com
>> 
>> This email sent to gustavxcodepic...@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: NSData from CGPDFPageRef

2010-05-20 Thread Gustavo Pizano
Hello Christian

This method was given to me yesterday by Jack Nutting... I dunno if its what 
you are looking for.




On Wed, May 19, 2010 at 12:07 PM, Gustavo Pizano
 wrote:
> Hello all.
> 
> I would want to know if I can render pdf  into iPad using quartz, or I have 
> to use UIWebView... or whats the way to achieve this?
> 
> 

The basics are very simple:

- (NSData *)pdfDataForView:(UIView *)myView inRect:(CGRect)bounds {
 // set up PDF rendering context
 NSMutableData *pdfData = [NSMutableData data];

 UIGraphicsBeginPDFContextToData(pdfData, bounds, nil);
 UIGraphicsBeginPDFPage();

 // tell our view to draw
 [myView drawRect:bounds];

 // remove PDF rendering context
 UIGraphicsEndPDFContext();

 return pdfData;
}

If you need to do a multipage document, it will get more complicated.

HTH,

-- 
// jack
// http://nuthole.com
// http://learncocoa.org
On 20.5.2010, at 11:59, Christian Ziegler wrote:

> Hi all,
> 
> can anyone think of a way to get an NSData object out of a CGPDFPageRef?
> 
> Cheers,
> 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/gustavxcodepicora%40gmail.com
> 
> This email sent to gustavxcodepic...@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


NSData from CGPDFPageRef

2010-05-20 Thread Christian Ziegler
Hi all,

can anyone think of a way to get an NSData object out of a CGPDFPageRef?

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