Re: +bundleForClass: category question

2012-07-21 Thread Uli Kusterer
On 16.07.2012, at 04:30, Graham Cox wrote:
> If I create a category on a standard framework class as part of another 
> framework, and I use +[NSBundle bundleForClass:] to load an image resource 
> for use by that category, does that work, i.e. does it load the bundle of the 
> framework containing the category, or the bundle containing the original 
> class being extended?


 You'll always get the bundle where the class was originally defined, not your 
category's. A workaround that I occasionally do in categories is that I define 
a dummy "anchor" class next to the category and call -bundleForClass: on that. 
Very useful for code that is used on iOS (there are no frameworks) and on the 
Mac (in a framework). It'll always grab the bundle to which someone added that 
source file, and the assumption is whoever did that also copied along the 
resources.

-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.masters-of-the-void.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: Cell in Selected NSTableView Not Redrawn

2012-07-21 Thread Keary Suska
On Jul 20, 2012, at 9:36 PM, Quincey Morris wrote:

> On Jul 20, 2012, at 19:03 , Keary Suska wrote:
> 
>> In an NSTableView I am providing custom cells via 
>> tableView:dataCellForTableColumn:row:, based on values represented in other 
>> columns. The cell is usually determined when a value is specified via 
>> NSPopupButtonCells in two other columns. When an effecting value is changed, 
>> I call reloadDataForRowIndexes:columnIndexes: to refresh the cell(s) in 
>> question. The problem is that even thought the delegate method is properly 
>> called to return the changed NSCell, the NSTableView will not redraw the 
>> cell until the row is deselected or is refreshed by some other means--such 
>> as obscuring the tableview with another window or clicking in the cell (but 
>> only when it's data cell is editable). I have also tried calling 
>> setNeedsDisplayInRect:, but that doesn't work either.
>> 
>> Oddly, it seems to work fine when called from an action method assigned to 
>> the NSMenuItems level of a particular NSPopupButtonCell, but not when called 
>> from an action method assigned to the NSPopupButtonCell itself. Although I 
>> did try to specify the action for the individual NSMenuItems in the other 
>> popup, but that didn't work either. The main difference between the two is 
>> that one is specified via Interface Builder and the other is generated in 
>> code.
> 
>> - (IBAction)selectComparator:(id)sender
>> {
>>  // clear operand
>>  [[self clauseExpressionForRow:[queryTableView selectedRow]] 
>> setOperand:[ClauseOperand nullOperand]];
>> 
>>  // comparator changes may change operand displays
>>  [queryTableView reloadDataForRowIndexes:[NSIndexSet 
>> indexSetWithIndex:[queryTableView selectedRow]] columnIndexes:[NSIndexSet 
>> indexSetWithIndex:4]];
>> }
> 
> So, to clarify, when it fails, are you saying:
> 
> 1. It doesn't get to 'selectComparator:'.

No, it does.

> 2. It gets there, but 'dataCellForTableColumn:' doesn't get called for column 
> 4 (at least, not until later, at the point where the row really redraws).

NSLog shows that the delegate method *is* called, and the expected data cell is 
being returned for column 4.

> 3. It gets to 'dataCellForTableColumn:' for the right row/column combinations 
> at the expected time, but the display just doesn't redraw.

Exactly.

> What happens if you simply 'reloadData' instead of trying to be specific, 
> and/or what happens if you simply 'setNeedsDisplay:' instead of trying to be 
> specific?

I tried reloadData, to no effect. I just tried the setNeedsDisplay: and that 
didn't work either.

> Also, I notice that if '[queryTableView selectedRow]' isn't what you are 
> expecting, when 'selectComparator:' is called, you'd get precisely the 
> behavior you describe.

NSLogs show that it is returning expected values. I agree that it "feels" a 
little fragile but I don't know what other options I have--doing this in the 
setObjectValue delegate call seems even more fragile.

Curiously, the following workaround works:

Change reloadDataForRowIndexes to:

  [self performSelector:@selector(refreshCellAtRect:) withObject:[NSValue 
valueWithRect:[queryTableView frameOfCellAtColumn:4 row:[queryTableView 
selectedRow]]] afterDelay:0.0];

With:

- (void)refreshCellAtRect:(NSValue *)rectValue;
{
  [queryTableView setNeedsDisplayInRect:[rectValue rectValue]];
}

So there must be something with redraw and the event loop. Anyway, this almost 
seems like a bug, but I wanted to be sure before I report it. 

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


___

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

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

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

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


saving images

2012-07-21 Thread H. Miersch
hi.

i just started a new ios project where i want to download images using 
NSimage's initwithcontentsofURL: method. 
now i also want to write those images to permanent storage, but how do i do 
that? as far as i can tell, NSImage has no method for writing images to disk. 
is there something i missed? should i download them into an NSData object and 
save that? but if i do that, will initwithcontentsoffile: read them properly? 
questions, questions, questions...

any help will be appreciated. thanks.
___

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

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

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

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


Re: saving images

2012-07-21 Thread Nick Zitzmann

On Jul 21, 2012, at 10:03 AM, H. Miersch wrote:

> i just started a new ios project where i want to download images using 
> NSimage's initwithcontentsofURL: method. 
> now i also want to write those images to permanent storage, but how do i do 
> that?

You could always download the data given the URL using NSData, and use the 
NSData to initialize the image. Then you can just save the NSData to storage.

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

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


Re: saving images

2012-07-21 Thread H. Miersch

On 21. Jul 2012, at 17:37, Nick Zitzmann wrote:

> 
> On Jul 21, 2012, at 10:03 AM, H. Miersch wrote:
> 
>> i just started a new ios project where i want to download images using 
>> NSimage's initwithcontentsofURL: method. 
>> now i also want to write those images to permanent storage, but how do i do 
>> that?
> 
> You could always download the data given the URL using NSData, and use the 
> NSData to initialize the image. Then you can just save the NSData to storage.

thought so. and when i load it again, i'd have to load it into an NSData object 
and create the image from that, correct?

___

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

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


Fwd: Cell in Selected NSTableView Not Redrawn

2012-07-21 Thread Keary Suska
>> On Jul 20, 2012, at 19:03 , Keary Suska wrote:
>> 
>>> In an NSTableView I am providing custom cells via 
>>> tableView:dataCellForTableColumn:row:, based on values represented in other 
>>> columns. The cell is usually determined when a value is specified via 
>>> NSPopupButtonCells in two other columns. When an effecting value is 
>>> changed, I call reloadDataForRowIndexes:columnIndexes: to refresh the 
>>> cell(s) in question. The problem is that even thought the delegate method 
>>> is properly called to return the changed NSCell, the NSTableView will not 
>>> redraw the cell until the row is deselected or is refreshed by some other 
>>> means--such as obscuring the tableview with another window or clicking in 
>>> the cell (but only when it's data cell is editable). I have also tried 
>>> calling setNeedsDisplayInRect:, but that doesn't work either.
>>> 
>>> Oddly, it seems to work fine when called from an action method assigned to 
>>> the NSMenuItems level of a particular NSPopupButtonCell, but not when 
>>> called from an action method assigned to the NSPopupButtonCell itself. 
>>> Although I did try to specify the action for the individual NSMenuItems in 
>>> the other popup, but that didn't work either. The main difference between 
>>> the two is that one is specified via Interface Builder and the other is 
>>> generated in code.

For posterity, it is actually not quite the case that one action method works 
while the other doesn't. It turns out that it works only the first time a 
change is made. Subsequent changes, using either action method, do not redraw.

Best,

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


___

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

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

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

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


Re: saving images

2012-07-21 Thread Conrad Shultz
NSImage is for OS X. You need to use UIImage on iOS. One difference is that 
UIImage doesn't have an -initWithContentsOfURL: method. 

Note that UIImage conforms to NSCoding, so once you've loaded a UIImage through 
whichever means you prefer (NSData, the URL loading system, etc.) you can 
archive the image to an NSData (and of course unarchive) in the usual manner. 

(Sent from my iPhone.)

--
Conrad Shultz

On Jul 21, 2012, at 9:03, "H. Miersch"  wrote:

> hi.
> 
> i just started a new ios project where i want to download images using 
> NSimage's initwithcontentsofURL: method. 
> now i also want to write those images to permanent storage, but how do i do 
> that? as far as i can tell, NSImage has no method for writing images to disk. 
> is there something i missed? should i download them into an NSData object and 
> save that? but if i do that, will initwithcontentsoffile: read them properly? 
> questions, questions, questions...
> 
> any help will be appreciated. thanks.
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/conrad%40synthetiqsolutions.com
> 
> This email sent to con...@synthetiqsolutions.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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: saving images

2012-07-21 Thread Nick Zitzmann

On Jul 21, 2012, at 10:41 AM, H. Miersch wrote:

> 
> On 21. Jul 2012, at 17:37, Nick Zitzmann wrote:
> 
>> 
>> On Jul 21, 2012, at 10:03 AM, H. Miersch wrote:
>> 
>>> i just started a new ios project where i want to download images using 
>>> NSimage's initwithcontentsofURL: method. 
>>> now i also want to write those images to permanent storage, but how do i do 
>>> that?
>> 
>> You could always download the data given the URL using NSData, and use the 
>> NSData to initialize the image. Then you can just save the NSData to storage.
> 
> thought so. and when i load it again, i'd have to load it into an NSData 
> object and create the image from that, correct?


Well, once it's on disk, you can use -[NSImage initWithContentsOfURL:] with the 
file URL and you won't have to make an NSData object if you want to skip that 
step.

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

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


Re: 10.7 Full-Screen transition animation corrupts my UI - how to avoid?

2012-07-21 Thread Motti Shneor
Hi, the header-file  documentation for the suggested delegate method tells the 
following:
---
1.  windowWillResize:toSize: Tells the delegate that the window is being 
resized (whether by the user or through one of the setFrame... methods other 
than setFrame:display:).

2. The frameSize contains the size (in screen coordinates) sender will be 
resized to. To resize to a different size, simply return the desired size from 
this method; to avoid resizing, return the current size. sender’s minimum and 
maximum size constraints have already been applied when this method is invoked.

While the user is resizing a window, the delegate is sent a series of 
windowWillResize:toSize: messages as the window’s outline is dragged. The 
window’s outline is displayed at the constrained size as set by this method.
--

Maybe I don't understand the docs right --- but my understanding is that 
minimum and maximum sizes are already constrained by this method --- which 
means there is no reason for me to implement it in my delegate, as my 
implementation won't do anything different than the standard implementation. 

I'll give it a try, but obviously something is wrong either in the 
documentation, my understanding of it, or Cocoa full-screen animation 
implementation.

On 19 ביול 2012, at 18:09, Kyle Sluder wrote:

> On Jul 19, 2012, at 5:17 AM, Motti Shneor  wrote:
> 
>> Hi Steve
>> 
>> How can a view disregard resizing request? It is simply resized
> 
> Try -[ windowWillResize:toSize:].
> 
> --Kyle Sluder

Motti Shneor
e-mail: motti.shn...@gmail.com
phone: +972-8-9267730
mobile: +972-54-3136621

Ceterum censeo Microsoftinem delendam esse



___

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

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

Re: KVG generic enough?

2012-07-21 Thread Chris Hanson
On Jul 18, 2012, at 4:46 PM, William Squires  wrote:

> For example, an effect could be called "fireball" and do 1d6 HP to a player 
> caught in the blast radius. My 'effect' class has an @property of type 
> NSMutableArray (which holds 'codons' in NSStrings) of the form:
> 
> 
> 
> and the parser will check the  for '=', '+=', '-=', '*=' and 
> '/=', evaluate the  portion, and pass those on to the player object 
> via valueForKey: (to get the property's initial value before the assignment, 
> and setValue:forKey: to set the new value.

This sounds kind of like a rule system, like WebObjects used to include in 
DirectToWeb (D2W), as a feature atop KVC and EOQualifier.

Rather than using strings you need to parse as your model for something like 
this, things will be easier if you use a distinct class.

For example, you could create a class that has a key path and an NSExpression 
used to generate a value based on parameters passed in (such as the original 
value at the key path). Then not only do you not have to do the parsing, you 
also get more features "free" because you can use everything NSExpression 
provides.

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

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


Re: saving images

2012-07-21 Thread Graham Cox

On 22/07/2012, at 2:58 AM, Conrad Shultz wrote:

> Note that UIImage conforms to NSCoding, so once you've loaded a UIImage 
> through whichever means you prefer (NSData, the URL loading system, etc.) you 
> can archive the image to an NSData (and of course unarchive) in the usual 
> manner. 


UIImage seems somewhat different, but on the Mac (NSImage) this is a really bad 
idea.

iOS has some utility functions such as UIIMageJPEGRepresentation() which 
converts a UIImage to data in JPEFG format, and there are others for PNG, etc. 
Be nice if NSImage had these as well, though there are more long-winded ways to 
achieve same.

If you can track and save the original NSData for the image, that's optimal, 
but if you can't, one of these functions should sort you out.

--Graham




___

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

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

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

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


Given NSString containing a letter like Ç, how do I convert that to a C?

2012-07-21 Thread Alex Kac
I'm creating an index for a table that we're sorting. Sorting using localized 
compare will properly compare ç with c. But then my index shows both c and ç. 
Given that I'm simply taking the first character of the string, how can I get 
the letter "C" when the string starts with "Ç"?



___

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

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

Re: Given NSString containing a letter like Ç, how do I convert that to a C?

2012-07-21 Thread David Duncan
On Jul 21, 2012, at 6:26 PM, Alex Kac  wrote:

> I'm creating an index for a table that we're sorting. Sorting using localized 
> compare will properly compare ç with c. But then my index shows both c and ç. 
> Given that I'm simply taking the first character of the string, how can I get 
> the letter "C" when the string starts with "Ç"?


You will probably want to do your comparisons based on strings that you've 
folded via -stringByFoldingWithOptions:locale:, and i fyou fold with diacritic 
insensitivity then you should fold out the cedillas.
--
David Duncan


___

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

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

Re: Given NSString containing a letter like Ç, how do I convert that to a C?

2012-07-21 Thread Alex Kac
Yup. That's what I was looking for. The word "Folding" just didn't register 
with me as what I was looking for as I searched the docs. Thanks! 

On Jul 21, 2012, at 8:57 PM, David Duncan  wrote:

> On Jul 21, 2012, at 6:26 PM, Alex Kac  wrote:
> 
>> I'm creating an index for a table that we're sorting. Sorting using 
>> localized compare will properly compare ç with c. But then my index shows 
>> both c and ç. Given that I'm simply taking the first character of the 
>> string, how can I get the letter "C" when the string starts with "Ç"?
> 
> 
> You will probably want to do your comparisons based on strings that you've 
> folded via -stringByFoldingWithOptions:locale:, and i fyou fold with 
> diacritic insensitivity then you should fold out the cedillas.
> --
> David Duncan
> 

Alex Kac - President and Founder
Web Information Solutions, Inc.

"Patience is the companion of wisdom."
--Anonymous





___

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

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

Where do you specify the string that explains why your app wants push notifications?

2012-07-21 Thread Gavin Stokes
I just saw this somewhere today and now can't find it.  There's a place (in
the Apple Provisioning Portal somewhere maybe) where you can specify a
string that will be presented to the user (in place of the default one)
when the app asks for permission to use push notifications.

Anybody know where this is?

Thanks!
___

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

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

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

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