Pop Up Menu in NSTableView

2013-03-24 Thread Pascal Harris
I have a table which has a list of items on which multiple actions can be 
performed.  Initially, I thought to use check box cells (there are only two 
possible actions that can be performed on each item right now - so the list of 
columns is manageable)  I thought a little further about the problem and it 
became apparent to me that, whilst there are only two possible actions right 
now, there might be twenty in the future - and, given the limited amount of 
space available to the table, twenty columns might become unmanageable.

My idea, and whether it's good or not remains to be seen, is to use an 
NSPopUpButtonCell in the NSTableView instead.  When an action is selected from 
the NSPopUpButtonCell the check mark against its name would be toggled 
(multiple selections would be permitted, so multiple items in the menu might 
have a check mark next to their names).  In this manner, the table would only 
have two columns (item and menu) and the whole thing would be far more 
manageable.

SO: 
Question 1. Is this possible, and am I even using the correct tool to do the 
job?
Question 2. Are there any examples of how to achieve what I am trying to do?

At the moment, my code looks like this (nothing is happening yet - I'm just 
trying to see if I can get the toggle to work - and I can't):
- (IBAction)cellPreferenceChanged:(id)sender
{
[[sender selectedItem] setState:NSOnState];
}

cellPreferenceChanged is bound to the NSPopUpButtonCell in IB.  Oddly, despite 
this binding, this code results in [NSTableView selectedItem]: unrecognized 
selector sent to instance.  Why is this?  Surely, since it is the 
NSPopUpButtonCell that is bound it should be the NSPopUpButtonCell instance for 
the selected row that is sent?

I am utterly perplexed, and clearly grasping the wrong end of the stick.  Any 
help would be most gratefully received.
___

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

Please do not post 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


Localization of Help

2012-12-07 Thread Pascal Harris
A weird issue this.  I'm trying to Localize my app - and, mostly, it's worked 
like a charm.  For some reason though, the help always gets delivered in the 
English version.  I have tried reindexing the help files - and now I'm out of 
ideas (Google wasn't much help either!).  Can anyone point me to a good 
resource on problems with Localizing help files - or even, perhaps, suggest 
what the problem might be?

Regards,

Pascal
___

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

Please do not post 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: Localization of Help

2012-12-07 Thread Pascal Harris
Top advice - and one step closer.  I now have help in English and in Spanish.  
Sadly, my French help is also in Spanish - which is rather confusing!


On 7 Dec 2012, at 13:54, Markus Spoettl ms_li...@shiftoption.com wrote:

 On 12/7/12 2:34 PM, Pascal Harris wrote:
 A weird issue this.  I'm trying to Localize my app - and, mostly, it's worked
 like a charm.  For some reason though, the help always gets delivered in the
 English version.  I have tried reindexing the help files - and now I'm out of
 ideas (Google wasn't much help either!).  Can anyone point me to a good
 resource on problems with Localizing help files - or even, perhaps, suggest
 what the problem might be?
 
 If you're building a help bundle, what you absolutely must have in order to 
 get help pick up your localized version is (for each individual localization) 
 a InfoPlist.strings containing (at a minimum)
 
 HPDBookTitle = YOUR LOCALIZED HELP TITLE;
 
 Without this, you'll always get the development language.
 
 Regards
 Markus
 -- 
 __
 Markus Spoettl
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post 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/45rpmlists%40googlemail.com
 
 This email sent to 45rpmli...@googlemail.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


Code Signing for Mountain Lion

2012-09-02 Thread Pascal Harris
I'm just updating one of my more useful little tools (Locamatic) so that it is 
code signed for Mountain Lion.  I know in advance that this program won't be 
suitable for the app store, firstly because it's a Preference Pane and secondly 
because it schedules shell scripts (packaged within the pref pane) to execute 
when certain conditions are met (gateway changes).  I'd like to code sign it so 
that users can download it from my website and use it without breaching the 
default gatekeeper configuration though.

I have two questions regarding this:
1.  Do the internal shell scripts have to be signed separately (and as a 
corollary, can shell scripts be signed)?
2.  When I sign the preference pane (using codesign) everything appears to be 
successful.  When I verify with codesign, it returns nothing (which I 
understand to be a good thing).  However, when I then download my finished 
prefpane to my test vm, also with Mountain Lion, it fails to pass GateKeeper 
(can't be opened because it is from an unidentified developer).  What am I 
doing wrong?

Thanks as always, and regards,

Pascal
___

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

Please do not post 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


NSDocument window opens - even if the document didn't read properly.

2012-07-29 Thread Pascal Harris
I hope that someone here might be able to help me with a couple of queries. 

1. I'm trying to open a document (NSDocument).  If the file is good then my 
program opens it without problem.  If the document fails to parse correctly 
then the NSDocument window still opens - but it opens empty.  Of course, if 
parsing of the document fails then I want the document window not to open at 
all.  The document data gets read as so and if it fails then I return NO - the 
document window still opens though.  Can anyone suggest what I might have 
missed or messed up?

- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError 
**)outError
{
BOOL success = NO;

success = [self loadTextViewWithInitialData: data]; 
if (!success)
{
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, 
NSUserDomainMask, YES);
NSString* URLString = [[[paths objectAtIndex:0] 
stringByAppendingString:[self 
fileURL].lastPathComponent]stringByAppendingString:@.bad];
NSURL* destinationURL =  [NSURL URLWithString:[URLString 
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
BOOL success = [[NSFileManager defaultManager] copyItemAtURL:[self 
fileURL] toURL:destinationURL error:nil];
}

return success;
}

2.  If the document fails to open then I want to copy it to a new location, 
with a new extension (see above).  This fails.  I can't think why!






___

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

Please do not post 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: NSDocument window opens - even if the document didn't read properly.

2012-07-29 Thread Pascal Harris
Mike,

Thanks for taking time on a Sunday to reply promptly.  I'm very grateful.  
Taking each point
 
On 29 Jul 2012, at 19:10, Mike Abdullah cocoa...@mikeabdullah.net wrote:

 Hello, there are many things wrong with your code. I’m noting them below.
 
 On 29 Jul 2012, at 18:53, Pascal Harris wrote:
 
 I hope that someone here might be able to help me with a couple of queries. 
 
 1. I'm trying to open a document (NSDocument).  If the file is good then my 
 program opens it without problem.  If the document fails to parse correctly 
 then the NSDocument window still opens - but it opens empty.  Of course, if 
 parsing of the document fails then I want the document window not to open at 
 all.  The document data gets read as so and if it fails then I return NO - 
 the document window still opens though.  Can anyone suggest what I might 
 have missed or messed up?
 
 - (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName 
 error:(NSError **)outError
 {
   BOOL success = NO;
 
   success = [self loadTextViewWithInitialData: data]; 
 
 Uh-oh, if this call failed, you’re returning NO without filling in the error 
 pointer. This will either blow up or provide a poor message to the user. 
 Hopefully your -loadTextView… method can report why it failed.
Good point - I've now fixed this.  That still doesn't explain why the 
window stays open though.  When I fix this problem, it doesn't provide an error 
message to the user either.  Perhaps this is connected to the reason that the 
window opens anyway, even if the data can't be read.

NSMutableDictionary *errorDetail = [NSMutableDictionary dictionary];
[errorDetail setValue:@This file is corrupted and could not be read. 
forKey:NSLocalizedDescriptionKey];

*outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:1 
userInfo:
 errorDetail];


 
   if (!success)
   {
   NSArray* paths = 
 NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, 
 YES);
 
 Cocoa has URL-based methods for this in NSFileManager these days; you should 
 consider adopting them.
Thank you - I will.  But I want to get this working first.  By examining the 
path provided in the string, I can see that the destination is valid - and I've 
used code like this successfully in the past.  Is the problem that the file 
being copied is also the file that I'm attempting (unsuccessfully) to open?  Is 
it that there's a temporary lock on the file that prevents it from copying 
successfully?


 
   NSString* URLString = [[[paths objectAtIndex:0] 
 stringByAppendingString:[self 
 fileURL].lastPathComponent]stringByAppendingString:@.bad];
 
 This is some seriously mangled code. Cocoa provides path 
 manipulation-specific string routines. USE THEM.
 
   NSURL* destinationURL =  [NSURL URLWithString:[URLString 
 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
 
 This is NOT how you convert from a path to a URL. Use +fileURLWithPath: 
 instead.
Again, it's worked in the past.  I changed it to fileURLWithPath - but the end 
result is the same.

 
   BOOL success = [[NSFileManager defaultManager] copyItemAtURL:[self 
 fileURL] toURL:destinationURL error:nil];
 
 You’ve just stored success into a *new* variable. I’m guessing you wanted to 
 store it into the existing success variable. Unless you’ve changed the 
 default compiler settings, the compiler should be warning you here that the 
 success variable is unused. Compiler warnings are useful. HEED THEM.
I do use the variable - just not in that little example I gave.  And rest 
assured that I heed all compiler warnings, and deal with them.

___

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

Please do not post 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: Watching a variable in Xcode 4.3

2012-04-16 Thread Pascal Harris
Thanks for your thoughts and advice.  I really thought that you might be onto 
something with stack overflow page - I tried all the suggestions, cleaned my 
project and tried again.  Boom!  Crash.

I then tried a completely new project and…  No luck.  Boom and crash again.

Is no one else having this problem with Xcode 4.3.2 on Lion 10.7.3?  Am I 
really the only one?  This is consistently reproducible on both my Macs - a Mac 
Pro 4,1 with 12GB RAM and a MacBook Air 2010 with 4GB RAM.

Sadly, I can't see how I can move forward with my project until this Xcode 
problem is fixed. Fingers crossed for a quick update or solution :-D

On 14 Apr 2012, at 21:28, Evadne Wu wrote:

 Is it only happening on this project or also for new projects?  Works for me 
 on new project.
 
 Again, 
 http://stackoverflow.com/questions/6189879/xcode-4-crashes-when-opening-project
  might help.
 
 This is not funny.
 
 On Apr 15, 2012, at 3:43 AM, Pascal Harris 45rpmli...@googlemail.com wrote:
 
 Easy enough - I just follow the instructions on 
 http://stackoverflow.com/questions/5632477/where-is-the-expression-window-in-xcode-4
   exactly, and Bang! On both my computers it results in an instant crash.  
 Even before I start running my code.
 
 Process: Xcode [1313]
 Path:/Applications/Xcode.app/Contents/MacOS/Xcode
 Identifier:  com.apple.dt.Xcode
 Version: 4.3.2 (1177)
 Build Info:  IDEApplication-1177~6
 App Item ID: 497799835
 App External ID: 7171108
 Code Type:   X86-64 (Native)
 Parent Process:  launchd [143]
 
 Date/Time:   2012-04-14 15:54:16.576 +0100
 OS Version:  Mac OS X 10.7.3 (11D50)
 Report Version:  9
 
 Crashed Thread:  0  Dispatch queue: com.apple.main-thread
 
 Exception Type:  EXC_CRASH (SIGABRT)
 Exception Codes: 0x, 0x
 
 Application Specific Information:
 ProductBuildVersion: 4E2002
 ASSERTION FAILURE in 
 /SourceCache/IDEDebugger/IDEDebugger-1185/PlugIns/DebuggerUI/VariablesView/DBGVariablesViewContentProvider.m:329
 Details:  Assertion failed: selectedRow = 0
 Object:   DBGVariablesViewContentProvider: 0x40227dfe0
 Method:   -addOrEditExpression:
 Thread:   NSThread: 0x40010a220{name = (null), num = 1}
 Hints:   None
 Backtrace:
 0  0x00010851db9f -[IDEAssertionHandler 
 handleFailureInMethod:object:fileName:lineNumber:messageFormat:arguments:] 
 (in IDEKit)
 
 
 Very odd.  And very annoying.  I mean, I guess that this does normally work 
 - it's too high profile, and too dramatic, for Apple to have shipped code 
 that does this for everyone, all of the time.  But it's strange that it 
 should happen on both my computers, of very different type, so consistently.
 
 
 On 14 Apr 2012, at 19:37, Evadne Wu wrote:
 
 That’s too bad.  Would you please post a minimal test case that crashes 
 Xcode? -ev
 
 On Apr 14, 2012, at 10:26 PM, Pascal Harris 45rpmli...@googlemail.com 
 wrote:
 
 



___

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

Please do not post 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: Watching a variable in Xcode 4.3

2012-04-14 Thread Pascal Harris
Evadne,

I saw that before - sadly, it doesn't seem to work for me.  For a start, Xcode 
(4.3.2) always crashes when I try this - and it doesn't matter whether I try on 
my MacBook Air or my Mac Pro (with a fresh, clean, install of Xcode).

Most perplexing.

On 12 Apr 2012, at 20:50, Evadne Wu wrote:

 http://stackoverflow.com/questions/5632477/where-is-the-expression-window-in-xcode-4
  might help.
 
 On Apr 13, 2012, at 3:02 AM, Pascal Harris 45rpmli...@googlemail.com wrote:
 
 I've got the weirdest bug.  I have a matrix of views (iOS development, by 
 the way) and all of them work correctly except for the object at 0, 0.
 
 The 0,0 view is initialised correctly, but loses its settings at some point 
 (although methods that don't rely on those settings still work - the view 
 hasn't been deallocated).
 
 There is nothing in my code designed to alter these settings after 
 initialisation.  Clearly there's a bug - in order to hunt the bug down I 
 thought it'd be a good idea to set a break point when one of the variables 
 changes and then see what made the change.  My question is, how do I do this 
 in Xcode 4.3?  I'm sure I've done this in the past - but I can't remember 
 how!
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post 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/ev%40monoceroi.com
 
 This email sent to e...@monoceroi.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


Watching a variable in Xcode 4.3

2012-04-12 Thread Pascal Harris
I've got the weirdest bug.  I have a matrix of views (iOS development, by the 
way) and all of them work correctly except for the object at 0, 0.

The 0,0 view is initialised correctly, but loses its settings at some point 
(although methods that don't rely on those settings still work - the view 
hasn't been deallocated).

There is nothing in my code designed to alter these settings after 
initialisation.  Clearly there's a bug - in order to hunt the bug down I 
thought it'd be a good idea to set a break point when one of the variables 
changes and then see what made the change.  My question is, how do I do this in 
Xcode 4.3?  I'm sure I've done this in the past - but I can't remember how!
___

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

Please do not post 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


NSAffineTransform on iOS

2012-04-09 Thread Pascal Harris
I'm trying to write some code for iOS and Wow!  I didn't expect it to be so 
unfamiliar.  Kind of like walking into a familiar city, like London, and 
discovering that everyone is speaking Dutch and no one speaks English.  Weird.  
I'm slowly getting to grips with the differences and similarities - but I'm a 
bit perplexed by transforms.  As I say, I'm writing a tile based game and the 
following code works very nicely in Mac OS X:

NSGraphicsContext *context = [NSGraphicsContext currentContext];
[context saveGraphicsState];

id transform = [NSAffineTransform transform];
[transform translateXBy:NSMidX(tileFrame) yBy:NSMidY(tileFrame)];
[transform concat];

[self drawTile:tileFrame];

[context restoreGraphicsState];


Unfortunately, my iOS version doesn't work. That isn't to say that it crashes - 
it just doesn't produce the expected output.

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);

CGAffineTransform transform;
CGAffineTransformTranslate(transform, CGRectGetMidX(tileFrame), 
CGRectGetMidY(tileFrame));
CGContextConcatCTM(context, transform);

[self drawTile:tileFrame];

CGContextRestoreGState(context);

I'm sure that my error will be obvious to anyone who isn't a complete newb, but 
I am - so it isn't obvious to me!

And are there any books that you'd recommend that cover these kind of issues, 
books to assist a Mac OS X developer write for iOS?
___

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

Please do not post 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


makeObjectsPerformSelector on a sub class

2012-03-21 Thread Pascal Harris
I'm doing a little development on iOS (but hopefully this will apply equally to 
Mac OS X, so fingers crossed that someone will be able to help me out here), 
and I'm having a little bother with makeObjectsPerformSelector.

I've created a custom view (which will be a tile in my game) as follows:

@interface gameTile : UIView

And I've successfully drawn my tiles onto the iOS Simulator screen.

Now I want to scramble the state of each of the tiles.  In the game controller, 
I'm using the following code:

[[self.view subviews] makeObjectsPerformSelector:@selector(scrambleState)];

I've put a breakpoint in scrambleState - and it never gets called. I'm guessing 
that 'makeObjectsPerformSelector' fails to work because scrambleState is not a 
method in UIView. Question is, what do I need to do in order to ensure that 
this code gets called?

I'm hoping that you can help me out, and regards,

Pascal


___

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

Please do not post 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


Playing Music in Objective C

2012-02-12 Thread Pascal Harris
My game is playable - so I'm polishing the hell out of it right now.  I've 
never written a game before though so, whilst I can manage the graphics okay 
(it's a puzzle, so NSMatrix does nicely), I'm utterly perplexed as to how to 
play sound effects and music.  The music isn't written yet, but I was planning 
on MP3.  

The sound effects will most likely be short WAVs. I've investigated OpenAL - 
and the example that Apple provides is impressively complex.  Googling gives a 
lot of iOS suggestions, but none for Mac OS X.

So my question is, if you were me, how would you play music?  I'm not 
interested in surround sound or other fanciness - I just want the music and 
effects files to play easily.  Can anyone point me in the direction of a primer 
or a short example?

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: Loading Typeface from NSBundle

2012-02-04 Thread Pascal Harris
Thanks for this - I shall try it at the first opportunity.

With regards to legality, I'm quite sure that I'm on solid ground with regards 
to redistributability.  I'm the designer of the typeface.

(Geeky background information) Nearly twenty years ago, I got a copy of 
Fontographer 3.something in a bundle - I wanted a custom typeface for my App, 
so I suspect that when I finish my App it will possibly be the only modern OS X 
App which was partially created on an LCIII!  I can't afford a new version of 
Fontographer, so getting my old Mac down from the loft was the easiest way of 
creating my typeface.

-- Pascal

On 4 Feb 2012, at 05:01, Jens Alfke wrote:

 
 On Feb 3, 2012, at 7:05 PM, John Joyce wrote:
 
 Does this work for you...?
 http://stackoverflow.com/questions/2444717/embed-font-in-a-mac-bundle
 
 That’s a better answer than mine, since I’d forgotten about needing to set 
 the ATSApplicationFontsPath key.
 
 Also, heed the reminder to make sure it’s legal to redistribute the font this 
 way. Even free fonts may have a license agreement that prohibits them from 
 being used for commercial purposes, or embedded in an app.
 
 —Jens


___

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

Please do not post 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

Loading Typeface from NSBundle

2012-02-03 Thread Pascal Harris
I'm trying to load a custom typeface from my application bundle (a TrueType 
font of my own design).  Hunting around on the web reveals only methods which 
are deprecated to the extent of not working under OS X Lion (FMActivateFonts):

#import QD/Fonts.h

---

NSString *fontsFolder = [[NSBundle mainBundle] resourcePath];
if (fontsFolder) {
NSURL *fontsURL = [NSURL fileURLWithPath:fontsFolder];
if (fontsURL) {
FSRef fsRef;
FSSpec fsSpec;
(void)CFURLGetFSRef((CFURLRef)fontsURL, fsRef);
OSStatus status = FSGetCatalogInfo(fsRef, kFSCatInfoNone, NULL,
   NULL, fsSpec, NULL);
if (noErr == status) {
FMGeneration generationCount = FMGetGeneration();
status = FMActivateFonts(fsSpec, NULL, NULL,
 kFMLocalActivationContext);
generationCount = FMGetGeneration() - generationCount;
if (generationCount) {
NSLog(@app - %@ added %u font file%s, name, 
generationCount,
  (generationCount == 1 ?  : s));
}
}
}
}


My question is (I hope) simple.  How does one load fonts from the Application 
Bundle in Lion?

___

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

Please do not post 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


Problem opening large files into NSDocument

2010-06-09 Thread Pascal Harris
Weird one this - especially since I can't find any documentation which covers 
it.  

I'm trying open a (very) large file (4GB) into an NSDocument.  Small files open 
file.  The monster fails with the error: The document test.pst could not be 
opened.  The file is too large.  What gives - and how do I overcome it?  What 
is the maximum size that I can open using NSDocument?

Thanks for any help you can provide - even just a link to a document that I may 
have overlooked.___

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

Please do not post 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


OutlineView Wierdness - 'item' not being stored.

2010-05-26 Thread Pascal Harris
I'm trying to populate an OutlineView.  I've had success in the past but
now, apparently, I'm unable to do it!

Looking at this code:

- (id)outlineView:(NSOutlineView *)outlineView child:(int)index
ofItem:(id)item
{
if (item == nil)
{
   [mailListDict writeToFile:@/test.plist atomically:YES];
   item = mailListDict;
}

if ([item isKindOfClass:[NSArray class]])
{
return [item objectAtIndex:index];
}
else if ([item isKindOfClass:[NSDictionary class]])
{
[item writeToFile:@/test2.plist atomically:YES];
return [item objectForKey:[[item allKeys] objectAtIndex:index]];
}

return nil;
}

- (id)outlineView:(NSOutlineView *)outlineView
objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
if ([[[tableColumn headerCell] stringValue] compare:@Key] ==
NSOrderedSame)
{

id parentObject = [outlineView parentForItem:item] ? [outlineView
parentForItem:item] : mailListDict;

if ([parentObject isKindOfClass:[NSDictionary class]])
{
return [[parentObject allKeysForObject:item] objectAtIndex:0];
}
else if ([parentObject isKindOfClass:[NSArray class]])
{
return [NSString stringWithFormat:@Item %d, [parentObject
indexOfObject:item]];
}
}
else
{
if ([item isKindOfClass:[NSString class]])
{
return item;
}
else if ([item isKindOfClass:[NSDictionary class]])
{
[mailListDict writeToFile:@/test3.plist atomically:YES];
[item writeToFile:@/test4.plist atomically:YES];
return [item objectAtIndex:0];
}
else if ([item isKindOfClass:[NSArray class]])
{
id parentObject = [outlineView parentForItem:item] ?
[outlineView parentForItem:item] : mailListDict;

return [[parentObject allKeysForObject:item] objectAtIndex:0];
}
}

return nil;
}


Test, Test2 and Test3 get written correctly but Test4 is empty.  This is
rather frustrating - does anyone have any ideas why item seems to be empty
by the time Test4 is reached?
___

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

Please do not post 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: OutlineView Wierdness - 'item' not being stored.

2010-05-26 Thread Pascal Harris
Thanks for this - I've done as you suggested and it works fine.  Serves me
right for attempting to learn from examples on the web ;)

On Wed, May 26, 2010 at 1:27 PM, Graham Cox graham@bigpond.com wrote:


 On 26/05/2010, at 10:12 PM, Pascal Harris wrote:

  - (id)outlineView:(NSOutlineView *)outlineView
  objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
  {
 if ([[[tableColumn headerCell] stringValue] compare:@Key] ==
  NSOrderedSame)
 {


 I'm not sure what the problem is, but the code is a mess, which will
 probably explain much of it.

 If you can't reduce this method to:

 - (id) outlineView:(NSOutlineView*) outlineView
 objectValueForTableColumn:(NSTableColumn*) tableColumn byItem:(id) item
 {
 return [item valueForKey:[tableColumn identifier]];
 }

 Then your controller design should be looked at and reorganised until you
 can. It might mean wrapping up certain elements of your data model into
 presentable objects that can be passed to the outline view and treated
 consistently. Outline views become ultra-easy when you do this.

 I'd also be very wary of writing files in any of these methods, even for
 test purposes.

 --Graham



___

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

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

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

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


Re: Getting filename in NSDocument readFromData

2010-04-29 Thread Pascal Harris
Sometimes, I find, I get so fixated on one particular solution that I  
can't see the wood for the trees.  Thanks for your response though -  
it did, at least get me thinking.


So, if anyone else has the same (slightly numpty) query, the answer is  
to forget NSData - remember that we're talking about an NSDocument  
window.  So [self fileURL] will provide the answer.  Sorry for wasting  
your time!


-Pascal

On 28 Apr 2010, at 19:40, Kyle Sluder wrote:


On Wed, Apr 28, 2010 at 11:37 AM, Pascal Harris
45rpmli...@googlemail.com wrote:
How do I get the filename of the source document when using  
NSDocument readFromData?


Just override -readFromURL:ofType:error: instead. The documentation is
quite clear about this method's implementation simply being a wrapper
around -readFromFileWrapper:ofType:error, which in turn is documented
to just be a wrapper for -readFromData:ofType:error:.

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


Getting filename in NSDocument readFromData

2010-04-28 Thread Pascal Harris
How do I get the filename of the source document when using NSDocument 
readFromData?

By and large, readFromData works excellently.  My app is able to get the NSData 
object and process it and all works well.  But now I want to write a refinement 
which would require my app to pass details (i.e. the file name and path) of 
files that it can't understand natively to a helper application (if present).  
In order to do this I need to know how to get the filename and path within 
readFromData.  Given that NSDocument displays the name and path (when command 
clicking) of documents that it can read in the window title, this information 
is clearly somewhere!

- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError 
**)outError
{
BOOL success = NO;
success = [self loadTextViewWithInitialData: data]; // I need to either 
perform the check and processing here or in loadTextViewWithInitialData
return success;
}

Thanks in advance, Pascal___

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

Please do not post 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: OS X Game Programming

2010-04-08 Thread Pascal Harris
Wow.  What a fantastic collection of resources for me to digest.  Thank you all 
so much.  I'm very grateful.

On 7 Apr 2010, at 21:52, Raffael Cavallaro wrote:

 
 On Apr 7, 2010, at 3:58 PM, Jens Alfke wrote:
 
 On Apr 7, 2010, at 11:08 AM, Raffael Cavallaro wrote:
 
 At the top of the page it says:
 
 Clone this repository (size: 959.4 KB): HTTPS / SSH
 $ hg clone http://bitbucket.org/snej/geekgameboard/;
 
 This means you need mercurial:
 
 No you don't — you can just click the get source button at the top right 
 and download as zip or tar.
 
 Sorry about the misinformation - I only saw the hg clone line up top, so 
 that's how I got the source.
 
 warmest regards,
 
 Ralph
 
 
 Raffael Cavallaro
 raffaelcavall...@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/45rpmlists%40googlemail.com
 
 This email sent to 45rpmli...@googlemail.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


OS X Game Programming

2010-04-07 Thread Pascal Harris
I've never programmed games before, although I've got a fair bit of useful OS X 
utility software under my belt.  I've now had a few ideas that I'd like to 
implement - and I'm stuck at almost the first hurdle.  I've managed to create 
an OpenGL view (by way of experimentation) and chuck a few graphics into it 
(triangles, circles (well, the closest OpenGL can get to a circle anyway!) and 
so forth).  But I can't work out how to get that OpenGL view to accept 
keystrokes from my event loop.  When it comes to tile based games I'm at a 
complete loss.

Obviously, there are various resources out there (SDL, Blitz etc), but I'd 
rather not use those because I want to understand the ins and outs of my 
engine.  I've googled and come up with plenty of resources for Windows game 
programming - but not so many for the Mac.  In fact, the only book that 
approaches what I'm after (with friendly examples) is Pangea Software’s 
Ultimate Game Programming Guide for Mac OS X - but that's rather out of date.

What I really want is something like the excellent guides written by luminaries 
like Kochan or  Hillegass, but focussed on game programming for OS X.  Does 
anyone know if such a guide exists?  Failing that, is anyone able to suggest a 
noddy guide to programming games that I might be able to find on the 'net 
(because so far my efforts have been rather below par).

Sorry to post such a non-technical question - I didn't know who else to 
ask.___

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

Please do not post 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: Saving position in NSTextView

2010-01-02 Thread Pascal Harris
Okay, I think I have this kind of sorted (courtesy of this source and, of
course, Google) - so if anyone else needs to do this in the future, they can
do it with this code:

To save position:

NSPoint containerOrigin = [textViewLarge textContainerOrigin];
NSRect visibleRect = [textViewLarge visibleRect];
visibleRect.origin.x -= containerOrigin.x; // convert from view coordinates
to container coordinates
visibleRect.origin.y -= containerOrigin.y;
NSRange visibleGlyphs = [[textViewLarge layoutManager]
glyphRangeForBoundingRect:visibleRect

inTextContainer:[textViewLarge textContainer]];

return visibleGlyphs;


To retrieve position:

[textViewLarge scrollRangeToVisible:scrollRange];


In these 'examples', of course, the NSTextView being considered is called
textViewLarge.

I do have one proviso though - and that is that this isn't perfect.  If you
can guarantee that your NSTextView will always be the same size (xy) and
that the size (or font) of the text will never change, then this should work
without problems.  If, however, you cannot guarantee those things then it'll
be a little unreliable.  Unreliable isn't good, but I don't have any better
ideas so it'll have to do.  After all, a bookmark within a few pages of the
page you actually want marking is better than no bookmark at all.

On Fri, Dec 4, 2009 at 6:02 PM, Douglas Davidson ddavi...@apple.com wrote:


 On Dec 4, 2009, at 9:30 AM, Pascal Harris wrote:

  I am writing an application which, amongst other things, can be used to
 read text files.  These text files are rather long (could be more than 1MB),
 which isn't convenient for anyone to read in one sitting.  The text files
 are not editable.  I would like to be able to save the position in the text
 file so that a reader can come back to file at a later time and not have to
 hunt for the last sentence that they read.

 My research shows that I can do half of what I need using NSRange - using
 scrollRangeToVisible it seems that I can scroll to a given range (allowing
 the reader to resume where they left off).  Sadly, I can't work out how I
 can save a range without the reader selecting text in the window first
 (hardly user friendly!).  I need this to work invisibly - i.e. the user
 closes the window, or the app, and when the window is reopened Presto!  the
 window contains the same view of the text as it did previously.


 If I understand correctly, what you want to be able to determine is the
 range of text that is currently visible.  This can be a bit tricky, since
 depending on the arrangement of text, the visible text might not be a single
 contiguous range in the document, but one way to do this is to get the text
 view's visibleRect, convert it into container coordinates (by subtracting
 the textContainerOrigin), ask the layout manager for
 glyphRangeForBoundingRect:inTextContainer:, and convert the resulting glyph
 range to a character range.

 Douglas Davidson


___

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

Please do not post 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


Saving position in NSTextView

2009-12-04 Thread Pascal Harris
I am writing an application which, amongst other things, can be used to read 
text files.  These text files are rather long (could be more than 1MB), which 
isn't convenient for anyone to read in one sitting.  The text files are not 
editable.  I would like to be able to save the position in the text file so 
that a reader can come back to file at a later time and not have to hunt for 
the last sentence that they read.

My research shows that I can do half of what I need using NSRange - using 
scrollRangeToVisible it seems that I can scroll to a given range (allowing the 
reader to resume where they left off).  Sadly, I can't work out how I can save 
a range without the reader selecting text in the window first (hardly user 
friendly!).  I need this to work invisibly - i.e. the user closes the window, 
or the app, and when the window is reopened Presto!  the window contains the 
same view of the text as it did previously.  

Perplexed.  Any help that you can provide would be most welcome.  
___

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

Please do not post 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


Efficient searching of an NSArray of NSDictionary

2009-09-29 Thread Pascal Harris
I have an application with an NSArray of NSDictionary (with 18 keys) which
populates an NSTableView.  I am concerned that my method of accessing the
contents of my array are sub-optimal and I'm therefore seeking advice from
the experts.

My current method is to iterate through the array, searching for a match for
a particular key.  I suspect that there may be a faster way - but I cannot
find a tutorial (especially since all the example code seems to have gone
AWOL in Snow Leopard).

This has come to a particular head because I need to implement an
NSSearchField and I would like to be able to search for any instance of a
string in any key of any array entry.

At this stage I would rather not use Core Data (even if this is the most
optimal method) because I don't yet have a manual for it.

Help!  And thanks, in advance.
___

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

Please do not post 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