Re: Sending multiple files via Bluetooth using GameKit

2011-01-20 Thread Ricky Sharp
You can but keep in mind the following:

The max packet size is 87K so for larger blocks of data, you will have to break 
things up.

You will need a mini state machine to keep track of what was sent vs. what is 
left to send. 

And will of course need all the logic to handle error conditions, retries, etc. 

What is your specific goal?  Perhaps using GameKit is not the correct choice. 

Sent from my iPhone

On Jan 19, 2011, at 11:58 PM, charisse napeÿf1as cnape...@yahoo.com wrote:

 Hello Guys,
 
 Is there any way I can send multiple files via Bluetooth transfer using 
 GameKit? 
 I have already done the single
 file transfer but how about if I send multiple files without sacrificing 
 speed? 
 Can I do it synchronously? I am new to this so maybe somebody can point me to 
 the right direction?
 
 Thanks,
 Charisse
 
 
 ___
 
 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
___

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: UITableView with only 1 row selectable

2010-12-24 Thread Ricky Sharp

On Dec 24, 2010, at 4:01 AM, Roland King wrote:

 Why not do it the other way around. Set allowsSelection to YES and then 
 implement the delegate method tableView:willSelectRowAtIndexPath: to return 
 nil for any row you do NOT want selected (see the documentation). That seems 
 to be apple's designed way to do this. 

Actually, tableView:shouldSelectRow: should be used instead.  Have it return 
YES only for rows that are selectable.  I'll also assume that the OP is 
presenting the non-selectable rows differently (e.g. dimming them) to ensure 
that users will understand what is selectable and what is not.

 On 24-Dec-2010, at 5:23 PM, Remco Poelstra wrote:
 
 Hi,
 
 I've an UITableView with allowsSelection=NO; I was wondering whether it's 
 possible to do allow selection of a specific row. Is there some way I can 
 detect a touch of a row and simulate a select in software?
 Thanks in advance.

___
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/archive%40mail-archive.com

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


Re: UITableView with only 1 row selectable

2010-12-24 Thread Ricky Sharp

On Dec 24, 2010, at 11:28 AM, Remco Poelstra wrote:

 Hi,
 
 I'm unable to find that method. Is it still available?
 
 Kind regards,
 
 Remco
 
 Op 24 dec. 2010 om 14:01 heeft Ricky Sharp rsh...@mac.com het volgende 
 geschreven:
 
 
 On Dec 24, 2010, at 4:01 AM, Roland King wrote:
 
 Why not do it the other way around. Set allowsSelection to YES and then 
 implement the delegate method tableView:willSelectRowAtIndexPath: to return 
 nil for any row you do NOT want selected (see the documentation). That 
 seems to be apple's designed way to do this. 
 
 Actually, tableView:shouldSelectRow: should be used instead.  Have it return 
 YES only for rows that are selectable.  I'll also assume that the OP is 
 presenting the non-selectable rows differently (e.g. dimming them) to 
 ensure that users will understand what is selectable and what is not.

Very sorry for this bad info; when searching for APIs, I had both Mac OS X and 
iOS doc sets enabled.

tableView:willSelectRowAtIndexPath: as was pointed out earlier is what you want.

___
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/archive%40mail-archive.com

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


Re: Function-Key Unicodes

2010-12-22 Thread Ricky Sharp

On Dec 22, 2010, at 1:44 PM, k...@highrolls.net wrote:

 I call:
 
   NSString *chars = [theEvent charactersIgnoringModifiers];
 
 in -keyDown
 
 The docs say
 
 Function-Key Unicodes
 
 These constants represent Unicode characters (0xF700–0xF8FF) that are 
 reserved for function keys on the keyboard. Combined in NSStrings, they are 
 the return values of the NSEvent methods characters and 
 charactersIgnoringModifiers and may be used in some parameters in the NSEvent 
 methodkeyEventWithType:location:modifierFlags:timestamp:windowNumber:context:characters:charactersIgnoringModifiers:isARepeat:keyCode:.
 
 
 what is the proper way to see if chars is NSLeftArrowFunctionKey or 
 NSRightArrowFunctionKey?


NSString* theEventCharacters = [anEvent charactersIgnoringModifiers];

if ([theEventCharacters length]  0)
{
unichar theChar = [theEventCharacters characterAtIndex:0];

if (theChar == NSLeftArrowFunctionKey)
{
...



___
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/archive%40mail-archive.com

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


Re: Text rendering/editing on OSX iOS

2010-12-21 Thread Ricky Sharp

On Dec 21, 2010, at 7:04 AM, Kenneth Baxter wrote:

 Hi, I have an application which I plan to roll out on both iOS and MacOS X, 
 and it needs to display text in various places on a series of views. I am 
 doing all the drawing using the Core technologies (CGContext drawing) to make 
 the maximum reuse of code. I've done most of the graphical stuff and am just 
 moving on to the text.

You should probably re-evaluate your approach.  While it may be absolutely 
necessary in your case to step down to a low level, you may find it better to 
use higher-level platform-specific code.

For my main application, the only code that is truly shared are model objects 
and to some extent, certain types of support controllers.  All view code and 
the majority of controller code is completely different.  And, for iOS, it's 
often the case where controllers and/or views are further different between 
iPad vs. iPhone/iPod touch.

Another huge difference in my app is that the Mac OS X code leverages massive 
amounts of bindings.  That simply doesn't exist in iOS.  Thankfully, the 
relevant bindings code in my models (e.g. keyPathsForValuesAffectingFoo) are  
easily ifdef'd out when compiling on iOS.

 Sometimes the user needs to edit the text, so I am planning to add a subview 
 (NSTextView / UITextView) while they are editing, but I need to be sure that 
 it's going to be exactly the same rendering size, position, wrapping etc. 
 between the text views and the core drawing.
 
 Is there anything special I need to look out for to ensure that it's the 
 same? Is this the best way for me to achieve my goal of maximum reuse and 
 seamless switching between the drawn text and the text view for editing?


I'm not sure what you mean by it's the same.  Do you mean pixel for pixel 
accuracy between Mac OS X and iOS?  I don't thing that may be possible (at 
least at a high level) as there may be different rendering techniques.  Default 
fonts between the systems are different and perhaps there's also subtle 
anti-aliasing differences, etc. Also, iPhone 4 introduced the Retina display, 
so output on such screens will provide much higher-quality output.

Behaviors in the UI between both systems are also very different, so attempting 
to share code to manage behaviors will prove to be problematic.
___
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/archive%40mail-archive.com

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


Re: NSKeyedArchiver on iOS and Cocoa

2010-12-20 Thread Ricky Sharp

On Dec 20, 2010, at 8:22 PM, lorenzo7...@gmail.com wrote:

 Are these two compatible? Can something archived one platform be unarchived 
 on the other? I can't find anything in docs that addresses this, but I'm 
 havig trouble doing precisely this (archived on iPhone, unarchived on 
 MacOSX). I get the NSInvalidUnarchiveOperationException.

There was a thread similar to this back in August:

http://www.cocoabuilder.com/archive/cocoa/291877-nskeyedarchiver-on-osx-to-nskeyedunarchiver-ios.html

___
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/archive%40mail-archive.com

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


Re: assign property behaves differently from simple instance variable???

2010-12-13 Thread Ricky Sharp

On Dec 13, 2010, at 1:31 PM, Wim Lewis wrote:

 
 On 13 Dec 2010, at 11:01 AM, Matt Neuburg wrote:
 How can this seemingly minor change make such a big difference? I'm not even 
 *using* the synthesized accessor! Yet its mere presence breaks the project. 
 How can this be? m.
 
 PS A new discovery: changing the name of the ivar / property to fr solves 
 the problem. So it appears that the problem is that I'm synthesizing 
 accessors for the *name* firstResponder. It is as if this name was being 
 used under the hood in some way I'm unaware of, and synthesizing an accessor 
 breaks its use. But how can *that* be?
 
 Perhaps it stomps on the -isFirstResponder method? KVC access for 'foo' 
 checks (among other things) '-isFoo', presumably so that boolean properties 
 feel natural; perhaps synthesizing a 'foo' property likewise causes the 
 object to respond to 'isFoo'.
 
 Hmm, also, it appears that UIResponder has some undocumented methods 
 -firstResponder and -_firstResponder, which your synthesized property would 
 also interfere with.


A collision is most likely the case here.  That is why several years ago I 
adopted a coding practice of ensuring all my methods, keys, properties, etc. 
are completely unique.  For the specific case of properties and methods, I do 
this:

BOOL firstResponder_II;

- (BOOL)firstResponder_II;

- (void)someMethod_II:(int)anInt with:(int)foo multiple:(int)bar 
parameters:(int)baz;  

___
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/archive%40mail-archive.com

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


Re: Getting nextKeyView to work

2010-12-10 Thread Ricky Sharp

On Dec 9, 2010, at 9:25 PM, Stevo Brock wrote:

 Hi All,
 
 I'm having trouble getting things set up so that I can tab between my 
 NSTextViews properly.  I have a window that has a TabView as the only 
 top-level view.  When I put 3 TextViews in the first tab, I have not yet been 
 able to get their nextKeyView to work.  I've looked online about making sure 
 that the initialFirstResponder is set and also about how to actually set up 
 the nextKeyView and it looks like it is all done correctly (if the TextViews 
 are in the Content View of the the window, everything works great).
 
 How do I set up the tab order of Text Views that are in a Tab View?

Depending upon your UI layout and how complex it is, you may need to 
programatically re-wire the key loop when the tabs change.

Part of my app (Mac OS X) uses a tabless tab view.  Contents of each tab are 
custom controls which work correctly when full keyboard access is turned on/off.

There were some edge cases that occurred where my key loop would end up 
breaking, so I implemented:

- (void)tabView:(NSTabView*)aTabView 
didSelectTabViewItem:(NSTabViewItem*)aTabViewItem
{
int theSelectedTabIndex = [aTabView indexOfTabViewItem:aTabViewItem];

switch (theSelectedTabIndex)
{
case 0:
 //rewire controls on first tab.
 break;
...
}

___
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/archive%40mail-archive.com

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


Re: Obscuring an NSString

2010-12-05 Thread Ricky Sharp

On Dec 5, 2010, at 4:31 PM, Adam Gerson wrote:

 Thanks to all who responded. Let me explain my situation a little
 better. I am storing several string values into an XML file. I want to
 obscure one of them. When I encrpyt the NSString to an NSdata I can
 store the data as a string in XML, however when I read the string back
 in I dont know how to convert it back to NSData to decrypt.


input string (NSString) -- UTF-8 representation (NSData) -- optional 
encryption such as XOR -- hex string (NSString)

this is fully reversible of course.

___
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/archive%40mail-archive.com

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


Re: Getting current mouse position after scroll

2010-12-01 Thread Ricky Sharp

On Dec 1, 2010, at 9:19 PM, Rick Mann wrote:

 I have a view that shows the coordinates of the current mouse location in it. 
 I update this via -mouseMoved: But if the user scrolls the view with a scroll 
 ball, I don't get mouse moved events.
 
 1) What's the best way to react to scroll changes? I'm currently observing 
 the NSViewBoundsDidChangeNotification.
 2) How can I get the mouse position at this point? I don't have an NSEvent to 
 check.



See:
 
- (void)scrollWheel:(NSEvent *)theEvent

___
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/archive%40mail-archive.com

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


Re: iPad: UI Implications

2010-11-26 Thread Ricky Sharp

On Nov 26, 2010, at 9:02 AM, Phillip Mills wrote:

 I don't have any specific questions or problems associated with this but I'm 
 curious about attitudes, techniques, patterns, or tools that others have 
 found helpful going from Mac to iOS.

At a high level, you don't go from Mac to iOS.  i.e. you don't attempt to 
port, clone the UI, etc.

Start with a mission statement of what you want to do with the iOS app.  Keep 
it simple.  Perhaps start with the mission statement of your Mac version, then 
trim it down to what makes sense to have in a mobile environment.

Then, storyboard your app.  Do not even reference your Mac version; think about 
the best possible ways to provide your features.  Trust me, don't get hung up 
on how the Mac version presents itself.  Rethink everything.

There is room to share though, but leave that to your business logic.

FWIW, here's my setup for all my apps:

(1) A set of foundation classes (utilities, common models, etc.).  These are 
shared* between all apps for Mac OS X and iOS.

(2) A shell app.  There's one for Mac OS X and one for iOS.  All apps I write 
sit upon one or both of these.

(3) Business logic for each individual app.  These are shared between Mac OS X 
and iOS.

(4) Individual projects for Mac OS X vs. iOS.  Here, they sit upon the 
appropriate shell and reference all common code.  Graphical assets, nibs, 
etc. are then unique to each individual project.


* sharing has had its downsides.  The original Mac version was baselined to Mac 
OS X 10.4 (pre Objective-C 2.0).  Thus, that set of code isn't yet using things 
like the newer property syntax.  My newer individual projects though do.

Also, know that in iOS, there is no GC.  So either create dual code to handle 
both cases (you can then drive things with compile-time macros), or stick with 
non-GC code everywhere.

___
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/archive%40mail-archive.com

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


Re: NSString/NSFont/Dingbats and the SnowFlake symbol

2010-11-24 Thread Ricky Sharp

On Nov 24, 2010, at 1:58 PM, Kyle Sluder wrote:

 On Wed, Nov 24, 2010 at 11:35 AM, Stephen Blinkhorn
 stephen.blinkh...@audiospillage.com wrote:
 On 24 Nov 2010, at 12:56, Murat Konar wrote:
 
 Beware the user that has removed all fonts that contain a snowflake...
 
 Yeah, I did wonder about such a thing.  But why would anyone do a thing like
 that!?
 
 Does it matter?
 
 If you need to guarantee the existence of a snowflake glyph, provide
 one yourself.


Or, render the glyph in black on a white background (then save to an image to 
bundle with your app)

Use that image as a mask while drawing colored swatches.  There are other ways 
to do too via the various blending modes.
___
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/archive%40mail-archive.com

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


Re: Help with Basics (Was: help with bindings)

2010-11-21 Thread Ricky Sharp

On Nov 21, 2010, at 2:59 AM, Rounak Jain wrote:

 Thanks Jerry,
 I have used the dictionaryWithObjectsAndKeys: method.
 I have implemented your suggestions regarding convenience constructors and 
 myKeys object. Regarding your comment about making everything mutable, I 
 think, at the moment, it has to be that way. 
 What's next?

As Jerry pointed out, you need to learn the basics; please read up on the 
basics to include memory management.

The way you've now written things will cause your app to crash.  I'll leave the 
reason for the crash as an exercise for you to figure out.

 #import Cocoa/Cocoa.h
 
 @interface ComboscAppDelegate : NSObject NSApplicationDelegate {
   IBOutlet NSComboBox *countryCombo;
 NSMutableDictionary *theCountries;
   NSMutableArray *myKeys;
   IBOutlet NSWindow *window;
 }
 @property (assign) IBOutlet NSWindow *window;
 - (void)applicationWillFinishLaunching:(NSNotification *)notif;
 @end
 
 
 
 #import ComboscAppDelegate.h
 @implementation ComboscAppDelegate
 
 @synthesize window;
 - (void)applicationWillFinishLaunching:(NSNotification *)notif {
theCountries = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSMutableArray 
 arrayWithObjects:@AAABBB, @AABBB, @AAACCC, nil], @A,
[NSMutableArray 
 arrayWithObjects:@BBBAAA, @, @BBBCCC, nil], @B,
[NSMutableArray 
 arrayWithObjects:@CCCDDD, @CCFGGGFF, @CCCDDDFFF, nil], @C, nil];
 
   myKeys = [NSMutableArray arrayWithObjects: [theCountries allKeys], nil];
 }
 @end

___
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/archive%40mail-archive.com

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


Re: Declaring a property named private and ObjC++

2010-09-28 Thread Ricky Sharp

On Sep 28, 2010, at 6:19 PM, Nick Zitzmann wrote:

 Okay, I tried searching, and didn't find anything pertinent...
 
 How do I create a property for a class named private and not have the 
 Objective-C++ compiler trip on it?
 
 Here's what I first tried:
 
 @property(assign,getter=isPrivate) BOOL private;
 
 That @property declaration works just fine when compiling Objective-C code, 
 but when the header is imported into Objective-C++ code, I get the following 
 error twice:
 error: expected unqualified-id before 'private'
 
 I know the word private is used as a keyword in C++ to mark the private 
 section of a class. So I tried rephrasing that property declaration to try 
 and get the compiler to treat the word private as a property name and not 
 as a C++ keyword. I thought this might work:


Why do you need to use the exact name of private?  You should never name 
things using reserved words.

How about simply adding a suffix or prefix?

___
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/archive%40mail-archive.com

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


Re: UIView animation

2010-09-02 Thread Ricky Sharp

On Sep 2, 2010, at 5:11 PM, Christian Ziegler wrote:

 I could use your help because I'm running out of ideas!
 
 Here's the situation. I got this custom view on screen which I want to remove 
 from the screen by moving it outside the left border of the screen. However 
 at the same time, I want to move it back in from the right side but at a 
 different y-Coordinate. So for instance it moves out at y=44 and at the same 
 time it moves back in from the other side at y=0. 
 
 I tried several approaches and the most promising (I reckon) is to create a 
 copy of the view. This is not so easy though because UIView does not 
 implement NSCopying. My custom view also has subviews and well the animation 
 apparently gets a little confused if you animate two different (equal but 
 different object) views which share the same subviews.
 
 Has anybody the slightest idea how I could achieve this? Every tip is welcome 
 :)!

Capture the view you want to animate into a UIImage.  Add two image views with 
that image to the view hierarchy.  One will be directly over your original view 
and the other will offscreen to the right.

Hide your original view.  Then, animate both image views as needed.  When 
animation ends, unhide the original view, then remove both image views.

Other notes...

You may want to ensure that when your original view is hidden, its container 
view has say a black background (or whatever background you want during the 
animation).

Note that by taking static images of your original view, no animations on that 
view itself will run during the overall animation.  Probably a good thing 
though.

___
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/archive%40mail-archive.com

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


Re: NSCoding between iOS and Mac OS X

2010-08-25 Thread Ricky Sharp
A similar question came up recently. 

While some objects (e.g. NSNumber) things should be binary compatible. But you 
may run into issues.

Also depends upon what objects you are coding. Mac OS X uses NSColor whereas 
iOS uses UIColor. 

I would recommend using an intermediate normalized format instead. Then write 
independent code for each platform. 

If archiving colors, capture normalized values like color mode (ARGB, HSL), 
color components, etc. Then, rebuild up objects as needed. 

For text data, I would use UTF-8 with the original text being normalized. 

Sent from my iPhone

On Aug 25, 2010, at 8:43 AM, Nathan Day nathan_...@mac.com wrote:

 Does anybody know whether NSCoding can be used to transfer data between iOS 
 and Mac OS X. Is this documented as guaranteed to work. I have tried to do a 
 google search but I got nothing, probably searching for the wrong thing.
 
 Nathan Day
 http://homepage.mac.com/nathan_day/
 
 ___
 
 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
___

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] How to change Default.png Image Dynamically

2010-08-21 Thread Ricky Sharp

On Aug 21, 2010, at 7:39 AM, Tharindu Madushanka wrote:

 But it seems like iPhone Phone app has some different Default.png images..
 When you exit from Keypad menu.. it will load one image..
 
 When you exit from other tabs, Default image is some other.. Is it possible
 to do similar thing ???
 
 Keeping several Default images..


As others have pointed out already, this is _not_ possible.

The whole point of the default image is to make it look like your app is 
launching quickly. For some apps, this is simply a blank background image.  For 
my own app, this also includes buttons and other controls that are void of text.

Keep in mind that with fast-app switching on iOS4, your app may come back into 
view exactly how it was when it was suspended.  Note that is only a _may_ and 
not a guarantee.  Should the OS have to terminate your app (to free up 
resources), the next time your app is launched, it will display the original 
default image (since it's once more doing a normal launch).

I highly recommend viewing Sessions 105 and 109 from WWDC 2010 (Adopting 
Multitasking Parts 1 and 2).  They list some tips on how to keep your app 
resident in memory as long as possible.

___
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/archive%40mail-archive.com

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


Re: NSKeyedArchiver on OSX to NSKeyedUnarchiver iOS

2010-08-11 Thread Ricky Sharp

On Aug 11, 2010, at 4:32 PM, glenn andreas wrote:

 
 On Aug 11, 2010, at 3:53 PM, Sandro Noël wrote:
 
 Greetings
 
 I'm having problems unarchiving my data in the iphone.
 
 here is the workout.
 
 1: I archive a AttributedString to my CoreData NSData property using 
 NSKeyedarchiver
 2: Transfer the database to the iphone.
 3: load the data using NSKeyedUnarchiver on the iphone.
 NSAttributedString *as = (NSAttributedString*)[NSKeyedUnarchiver 
 unarchiveObjectWithData:attributedStringData];
 
 that crashes saying:
 -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class 
 (NSFont)
 
 I understand that the NSFont is UIFont on the iphone, or has similarities.
 so i implemented a Delegate method to replace the class.
 //--
 - (Class)unarchiver:(NSKeyedUnarchiver *)unarchiver 
 cannotDecodeObjectOfClassName:(NSString *)name originalClasses:(NSArray 
 *)classNames{
  if ([name isEqualToString:@NSFont])
  return [UIFont class];
 
  return nil;
 }
 
 but that never gets called because the class method does not allow for a 
 delegate and instantiating the unarchiver class confuses me in how I should 
 trigger the decoding once it is instantiated.
 
 Any pointers ?
 
 You're going to run into worse problems - UIFont is not NSFont, nor can you 
 trivially substitute one for the other.
 
 In general, while you can archive an NSAttributedString on OS X and unarchive 
 it on iOS, it's not going to work the way you want it to.  Any of the 
 interesting properties that define things like appearance of the string, 
 are platform specific.  There is no NSForegroundAttributeName, for example, 
 on iOS, and even if you explicitly look for appropriate key, on OS X this 
 will contain an NSColor, which, of course, does not exist on iOS (and UI 
 color is similar, but the encoding of NSColor is undocumented, so even if you 
 attempt to manually handle the decoding and try to make a UIColor, it would 
 require that undocumented information - not to mention that there are parts 
 of NSColor such as color space that don't exist at all on iOS).  Similarly 
 for font information, paragraph style (including alignment, tabs, margins), 
 embedded images, etc...
 
 You might be able to get away with using CoreText and it's attributes (which 
 are based on CG/CT objects like CGColor and CTFont), but obviously that's not 
 what you're going to get from AppKits default attributed string support. So 
 you'll probably have to give up on using AppKit's NSAttributedString 
 extensions all together, and switch to the CoreText ones (and take advantage 
 of the CFAttributedString/NSAttributedString toll free bridging).


What you could do is continue to use the best possible API on both OS flavors.  
Then, instead of archiving platform-specific objects, archive primitives that 
describe the object instead.

For example, if you have an NSColor on Mac OS X, archive the color components, 
etc. as needed.  Then, when unarchiving on iOS, rebuild up an appropriate 
UIColor.

This is I think the only thing you can do to basically future-proof your code 
(or come very close to it).  Attempting to pick a set of objects that just 
happen to be archived the same exact way between OS flavors just seems too 
fragile.  And, using those objects may not be the simplest thing to do on each 
specific OS.
___
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/archive%40mail-archive.com

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


Re: six things I wasn't able to do with Cocoa

2010-05-28 Thread Ricky Sharp

On May 28, 2010, at 11:20 AM, Bill Appleton wrote:

 on printing, the problem is that i have to port an enterprise application
 that expects to be able to call a fx for the page layout and the page setup
 dialog, a fx to begin/end a page, and a fx to begin/end printing.
 
 so Cocoa has this amazing system where you initiate printing and the
 printing system CALLS YOU with these requirements, but i need something
 where i CALL THEM because i have to port lots of other code.


Have you considered creating a go-between object that would implement the 
APIs your code expects.  And, would also implement the required Cocoa delegate 
APIs?  Your app code then sets info/state on your object which in turn can be 
passed along when the Cocoa delegate methods get called.

Note that this may be an extreme simplification.  I have no idea on the order 
of operations of both APIs and thus don't know if they will work well together 
using this approach.

Maintaining state in your go-between object may also get tricky.
___
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/archive%40mail-archive.com

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


Re: -[NSMutableSet randomObject]

2010-05-25 Thread Ricky Sharp

On May 25, 2010, at 11:49 AM, Michael A. Crawford wrote:

// If the array is empty, throw an exception.  The caller should know 
 better.
// If there is only one, return object zero every time.
// If there are only two, alternate with every access.
// If there are three or more, randomize but never provide the same object
// twice in a row.


These are definitely strange rules...  please note the following which 
describes basically all rules where n  1

In your starting state, nothing is picked.  You then pick something at random 
from the set. But, that item is not placed back in the set.  The 2nd pick comes 
from the new set.  The original item that was picked is now put back into the 
set.  So part of what's going on is a pick without replacement as well as 
pick with replacement.

Having said that, depending upon your needs, I highly recommend the Mersenne 
Twister algorithm for your psuedo-random generator.  Depending upon speed 
constraints, you may also want to experiment with a Fisher-Yates shuffle of the 
array, then grab the 0th element as the next random object.

___
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/archive%40mail-archive.com

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


Re: Original iPhone animation performance

2010-05-19 Thread Ricky Sharp

On May 19, 2010, at 3:01 AM, Andrew wrote:

 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/archive%40mail-archive.com

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


Re: Cracks in image using NSDrawThreePartImage

2010-05-19 Thread Ricky Sharp

On May 19, 2010, at 4:30 PM, Ken Ferry wrote:

 File a bug with a test case that shows the problem.
 
 I would expect there to be seams due to rounding error if you look in pixie,
 but I have never seen a case where it was visible to the eye at actual
 scale.


I only recall seeing this when the UI scaling factor was something other than 
1.0

Could also be the case where you're not drawing on pixel boundaries?

___
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/archive%40mail-archive.com

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


Re: [iPhone] File coping application

2010-04-26 Thread Ricky Sharp

On Apr 26, 2010, at 11:40 AM, Kyle Sluder wrote:

 On Mon, Apr 26, 2010 at 9:04 AM, Arun arun...@gmail.com wrote:
 Is it possible to copy files form iPhone on to a Mac when iPhone is
 connected to USB?
 
 No.


Just to add though that you _can_ transfer files via WiFi.  But of course, only 
for those files that your particular app works with.
___
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/archive%40mail-archive.com

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


Re: iPad: UIImagePickerController

2010-04-07 Thread Ricky Sharp

On Apr 7, 2010, at 3:37 PM, Development wrote:

 How do you use the image picker controller on the iPad? My iphone version 
 works fine but I get a UI Mess on the iPad.


 And now it crashes telling me I have to use a popover:
 
 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
 reason: 'On iPad, UIImagePickerController must be presented via 
 UIPopoverController'


That's because on iPad, image pickers must be used within a popover (just what 
the exception instructs).  I strongly suggest you read the iPad Human Interface 
Guidelines as well as the corresponding programming guide.

Also, a potential better forum for UIKit questions is the dedicated iPhone OS 
forums at developer.apple.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/archive%40mail-archive.com

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


Re: Hot to move focus to a button?

2010-03-07 Thread Ricky Sharp

On Mar 7, 2010, at 3:53 AM, Joanna Carter wrote:

 Hi Kyle
 
 Buttons don't accept keyboard focus. See the documentation for
 -[NSView canBecomeKeyView] and the related conceptual documentation.
 
 I realise this to be what the docs say but, if you use -makeFirstResponder: 
 the focus ring is applied to the chosen button and pressing the spacebar 
 calls the connected action, which is, surely, the desired end result of 
 setting focus.


All you need to do is properly set up the key view loop in IB.  i.e. connect 
the 'nextKeyView' outlets.

If your UI is something like this:

Prompt: [edit field]

(button1) (button2)


set 'nextKeyView' of 'edit field' to 'button1'.  Then, 'button1' to 'button2' 
and finally 'button2' back to the 'edit field'.

Also, ensure to set the first responder as needed.

When Full Keyboard Access is off, users will only be able to tab amongst 
controls that are text boxes or lists.  Otherwise, when on, they will be able 
to tab amongst all controls.

You should get automatic behavior 99% of the time (i.e. you never have to call 
makeFirstResponder: manually).  There are cases where you need to do so when 
you have very complex UI involving tabless tabviews (usually nested).  In 
response to selected tab changes, you can rewire the keyloop manually as 
needed and re-establish the current control that should have focus.
___
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/archive%40mail-archive.com

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


Re: iPhone and OS X apps question

2010-02-11 Thread Ricky Sharp
I would begin with Apple's picture-sharing sample code. I think that  
sample has two parts - server and client. Ther is also an iPhone  
sample dealing with locating Bonjour services.


Basically Bonjour is used to have the server (Mac app) and client  
(iPhone) discover each other. Then use whatever networking protocol  
you want to send data.


This setup works extremely well in the simulator. When working with  
real hardware you will need to connect it (and your Mac) to the same  
wifi network. There is currently no public APIs to talk to a docked  
iPhone OS device.


Sent from my iPhone

On Feb 11, 2010, at 10:29 AM, Eric E. Dolecki edole...@gmail.com  
wrote:


I am looking at prototyping something and would like an iPhone app  
to be
able to talk with a desktop OS X app. Do something on the iPhone  
app, it's
reflected in the OS X application. And vice-versa. Where might I  
start for a

project like this?

Eric
___

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

___

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: Using NSKeyedArchiver to save and restore state on iPhone apps

2010-02-10 Thread Ricky Sharp

On Feb 10, 2010, at 12:40 PM, Jason Bobier wrote:

 As many of you know, saving and restoring complex navigation hierarchies on 
 the iPhone can be a real chore. So, I had this brilliant idea of setting up 
 my app delegate like this:
 
 applicationDidFinishLaunching
   if userdefaults contains an archived navcontroller
   unarchive controller and retain
   else
   load nib with controller and retain
   add navcontroller view to window
 
 applicationWillTerminate
   archive nav controller and save to user defaults
 
 and then make all of my view controllers NSCoding compliant
 
 In theory, the archived navcontroller should contain my complex view 
 controller hierarchy and all of the related views, so this should work.
 
 However, when I unarchive and add to view to the window, the subviews rarely 
 have all of their values set correctly despite being supposedly NSCoding 
 compliant. (For example, I have a button that fails to have it's target and 
 action set)
 
 Am I missing something here or is this just buggy NSCoding compliant code on 
 apple's part?


You don't want to take this approach at all.

The proper thing to do is to archive model data (as others have pointed out).  
Note that this will now also be faster too since it will be a much smaller data 
set.

For nav-based apps, this set of data often includes a screen ID of what 
screen the user left off at.  Upon app launch, you can basically just push 
whatever screen you need to on the nav controller's stack.

This is exactly what I do in my own iPhone OS apps.  I also have an 
infrastructure to pass an NSDictionary filled with parameters as users hop from 
screen to screen.

This allowed me to do stuff like this:

In MyScreenA...

- (IBAction)someAction:(id)sender
{
NSDictionary* = parameters = ...;

[self pushScreen:MyScreenBID withParameters:parameters animated:YES];
}

If users exit the app while on Screen B, I simply store the fact that I was on 
that screen (and any other metadata I need to preserve selections, scroll 
position, etc.)

Then, on app launch, if such a freeze-dried state exists, I ultimately build up 
a set of parameters just like I did in the action method above.  Then push the 
appropriate screen with those parameters (and set animated flag to NO).  This 
will give the appearance of the app launching directly to the screen the user 
left off.

But, under the covers, this is what actually occurs on app launch:

- app launch routines
- nav controller created; main nib loaded and set as top view
- code that senses you have a saved state
- push appropriate view controller to go to last used screen

All the standard nib-loading occurs and things just work.



___
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/archive%40mail-archive.com

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


Re: Make sheets open instantly

2010-01-18 Thread Ricky Sharp

On Jan 18, 2010, at 7:19 PM, Chris Hanson wrote:

 On Jan 18, 2010, at 2:43 PM, David Catmull wrote:
 
 Is there any way to make sheets open instantly, instead of animating? I'd 
 just like to speed up my unit tests.
 
 Why do your unit tests need to bring up sheets?


Can't speak for the OP, but it may be for acceptance tests.  I have two types 
of tests myself; units and acceptance.  The latter are scenario-based and hit 
the UI to perform a scenario just as a user would.

I also had to add a flag to my iPhone OS code so that all animations occurred 
instantly for the sake of keeping test runs short.

___
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/archive%40mail-archive.com

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


Re: Dead iPhone Simulator :-(

2010-01-14 Thread Ricky Sharp

On Jan 14, 2010, at 3:27 PM, Michael Rogers wrote:

 I'm running Mac OS X 10.6.2, and just installed the iPhone SDK 3.1.2.  When I 
 launch anything in the simulator, it crashes, and I get a message complaining 
 about the Telephony state (which I believe is California :-)
 
 Jan 14 15:25:01 michael-rogerss-macbook-pro SpringBoard[17946]: Unable to 
 create CFServerConnection. Telephony state may be incorrect.

This is harmless; I get this all the time too.

 Jan 14 15:25:01 michael-rogerss-macbook-pro SpringBoard[17946]: Launchd 
 returned an unexpected type or didn't return a value for job label 
 UIKitApplication:com.apple.mobilesafari[0xfe93] with job key PID

I didn't get this one though when launching Safari.

You should follow-up though on the dedicated iPhone dev forums, or possibly the 
xcode mailing list.

___
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/archive%40mail-archive.com

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


Re: Resolution Independence

2010-01-05 Thread Ricky Sharp

On Jan 5, 2010, at 2:50 PM, Todd Heberlein wrote:

 A friend of mine loves her new 27 iMac but has complained at how small 
 everything is. Searching around on the net I found that it has about a 109 
 dpi pixel density. I also saw today that the new Nexus phone has a pixel size 
 of 800x480 (as opposed to my iPhone's 480x320 pixel size), and the two 
 together got me thinking more seriously about resolution independence again. 
 Other than making big icons for my apps, I had pretty much ignored the 
 resolution independence issue.
 
 Today I fired up Quartz Debug to set the UI Resolution to a bigger scale, and 
 I am happy that my applications did OK.
 
 
 But how accurate of a test is this compared to real-world resolution 
 independence?
 
 Or in other words, is there real resolution independence built into Snow 
 Leopard for apps? Can I (or my friend with her 27 iMac) set a scale factor 
 on an application without using Quartz Debug?

RI, unfortunately, is not yet 100%.  My app is fully ready to go; got it done 
back in the days of Tiger developer seeds.

However, my app uses its own UI (no Aqua).  Thus, I had full control over 
graphics (100% vector-based PDF) as well as drawing primitives.

Having said that, Quartz Debug is definitely a very useful tool to flush out RI 
issues.  There is no user-level setting currently in the OS; you need Quartz 
Debug from devtools.

My app works at all scaling factors (to include the non-integral ones such as 
1.333), but I found that the Aqua UI was not up to the same degree of 
compliance.  Integral scale factors turned out somewhat OK (e.g. 2.0), but you 
could tell where bitmapped art was still being used.  Non-integral scaling 
factors were awful for Aqua.

I was hoping that Leopard would be the debut and then later Snow Leopard, but 
alas not yet.

 Is there something similar for iPhone development?

No.  For iPhone OS, you really should use art in the most optimum format.  This 
is currently PNG (i.e. bitmapped).  Scaling things on-the-fly ends up eating 
cycles which means more power consumption.  Granted, not nearly as much power 
as cellular/network communication, but still a waste.

 Or is the Xcode mailing list a better place for this question?


No, most RI threads have been on this list.  Definitely search the archives for 
other notes or tips/tricks.

___
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/archive%40mail-archive.com

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


Re: Localization strategies?

2009-12-23 Thread Ricky Sharp
 
On Tuesday, December 22, 2009, at 09:59PM, Kyle Sluder 
kyle.slu...@gmail.com wrote:
On Tue, Dec 22, 2009 at 11:54 AM, Ricky Sharp rsh...@mac.com wrote:
 (2) Externalize all strings from the nibs and put them into 
 Localizable.strings.  This allows me to have a single file to hand off to 
 translators.  I can also group like-items together and fill in nice 
 contextual comments.

This shouldn't be necessary; see man ibtool for arguments you can use
to generate strings files from your nibs automatically.

Been there; done that.  The issue with storing strings in nibs is that I cannot 
place contextual comments anywhere.

 * No plural forms (while allowing plurals can be handled, it's not worth the 
 effort IMO)

Don't cop out with text like One or more items… or There are 5
document(s) open. That looks unprofessional and very un-Mac.

No, I'm not doing anything like that.  Example:

Instead of 10 problems, use Problems: 10.

Apple actually makes use of this strategy, thought only for certain languages.  
For their English localization, they pretty much stick with the plural forms.  
But, for languages such as Russian, they use the colon approach.  I didn't 
want to have two methods of doing things, so just removed plural forms in their 
entirety.  I've worked with languages with 6 plural forms and it's just not 
worth the effort.

This also leads to a lower translation cost.

 * No fragmented sentences (i.e. pieces of sentences across multiple UI 
 elements)

Is this going to work in Preference panes? If you're already going the
multiple-nib route, does doing this really pose a problem?

I'm sure you could get this to all work out, but just wanted to keep things 
simple.

--
Rick Sharp
Instant Interactive(tm)

___

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: Localization strategies?

2009-12-23 Thread Ricky Sharp

On Dec 23, 2009, at 7:38 AM, Jerry Krinock wrote:

 
 Well, Ricky I see you're one of the few who has really thought through all 
 the issues.
 
 On 2009 Dec 22, at 19:59, Kyle Sluder wrote:
 
 On Tue, Dec 22, 2009 at 11:54 AM, Ricky Sharp rsh...@mac.com wrote:
 * No plural forms (while allowing plurals can be handled, it's not worth 
 the effort IMO)
 
 That's good, because I read somewhere that in some languages, for example 
 Arabic, there are actually different forms for one, two, and three or 
 more.

At my day job, we're moving a very large product to Arabic.  We definitely 
didn't want to deal with its 6 plural forms.

Official rules can be found here:

http://unicode.org/cldr/data/charts/supplemental/language_plural_rules.html


 But not using plural forms at all -- I would find that to be very difficult.

Not as bad as you may think.  At my day job, we removed over 3,000 occurrences 
of plural forms to include (s).  Took just three of us about a week.

 NSString has support for this with the syntax Blah %1$@ blah %2$@.
 Bizarrely, it starts at 1, not 0.
 
 You're correct Kyle, but I have enough trouble typing %1$@ myself.  There 
 it just took me about 10 seconds.  When I discovered this feature a few 
 years ago, I decided that either localizers were going to frequently type it 
 wrong, or use some kind of automated typing that would frequently type in the 
 wrong one.  So I wrote my own localized string function which does it the way 
 that it was done in Classic Mac OS, with simply %0, %1, %2, and is 
 type-agnostic.  That's what I use now, and it seems to be bug-free at this 
 point.

Yea, ended up writing my own utility as well.

___
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/archive%40mail-archive.com

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


Re: Localization strategies?

2009-12-22 Thread Ricky Sharp
Thank you all for the replies.

Here's my final plan:

(1) Have separate nibs for each language.  I agree with those that say you 
cannot have a one-size-fits-all layout.  Each nib will thus carry layout, font 
size, style, etc. that makes sense for a particular language.

I've already pseudo-localized the nibs to hopefully address 90% plus of any 
truncation issues.

(2) Externalize all strings from the nibs and put them into 
Localizable.strings.  This allows me to have a single file to hand off to 
translators.  I can also group like-items together and fill in nice contextual 
comments.

Nibs will still contain text for buttons, etc. but will all be in the form {s} 
(a string wrapped in curly braces).

(3) For runtime creation of fonts (e.g. boldSystemFontOfSize), call into my 
special Font factory.  I ended up creating a fonts.plist localized file.  
Each version will contain two attributes per key (font size and whether or not 
its bold).  At runtime, I now read in the appropriate plist and gather the 
metrics for the fonts I need to create.

(4) Leverage my existing automated-test infrastructure to do a full product 
walkthrough (setting up proper data along the way) and generating screen-shots. 
 Such screen shots can now be viewed by the localization company's QA team to 
ensure all text is valid within its context.

Furthermore, the walkthrough script will mine all text on the screen and look 
for curly braces.  That will mean that either an outlet isn't connected or its 
localized string key is either missing or malformed.

The walkthrough script will also be generating HTML files (which will provide 
links to all screenshots).  This will allow everyone to view screenshots 
side-by-side (comparing original English to a second language)


Finally, here's some other things I have already done to ensure translation 
will be as smooth as possible:

* No plural forms (while allowing plurals can be handled, it's not worth the 
effort IMO)
* No fragmented sentences (i.e. pieces of sentences across multiple UI elements)
* No hardcoded ordering of parameters.  i.e. template strings like Blah {0} 
blah {1}. may be {1} blah blah {0} in other languages.  Each placeholder is 
always matched to the appropriate vararg argument.

___
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/archive%40mail-archive.com

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


Localization strategies?

2009-12-20 Thread Ricky Sharp

In getting quotes from many localization companies, I've found that some have 
different processes.  For example, one company would prefer if I just provide 
.string files.  During their QA process, they'll then run the app and look at 
everything in context.

While generating .strings from nibs is easy to do, there's a problem in that 
there seems to be no method of putting contextual comments into a nib.  And 
there's no way I would hand-edit comments in the generated .strings files.

Thus, I'm wondering if it would ultimately be worth it to externalize all 
strings from my nibs and just put everything in my single .strings file.  This 
will clearly involve me adding tons of IBOutlet ivars just so that at runtime I 
can set their text with NSLocalizedString APIs.

I still plan on having separate nibs though for each language (to account for 
text bounds, font sizes, etc.)

How have others tackled localization?

___
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/archive%40mail-archive.com

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


Re: Button width should accomodate localized string

2009-11-30 Thread Ricky Sharp

On Nov 29, 2009, at 9:52 AM, glenn andreas wrote:

 On Nov 29, 2009, at 9:38 AM, Symadept wrote:
 
 How can I scale my button or Label to be able to accomodate the localized
 string?
 
 That's the whole purpose of being able to localize the nib/xib...

Exactly.  It's not possible to create a single nib such that its layout and 
control sizes will be appropriate for every language.

Beyond control sizes being different, I've also found the following things to 
consider between flavors of your nibs:

* Font size and/or style may need to change.
* Directionality would need to change (if localizing to right-to-left languages)

___
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/archive%40mail-archive.com

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


Re: Locale based font

2009-11-23 Thread Ricky Sharp
I am about to play around with something similar. In my iPhone app, I  
have some calls with boldSystemFontOfSize. But, for certain locales,  
it should be a plain font and the size may need to be tweaked.


I then had an idea to write a static method to obtain a font style and  
size based on locale. My thought was to come up with a key for each  
style and then have a localized property list file to store the  
styles for each locale.


Kinda like how you often have a CSS file for each locale your web site  
is localized to.


Sent from my iPhone

On Nov 23, 2009, at 7:00 AM, Symadept symad...@gmail.com wrote:


Hi,

I found out the way to show custom font.

1. First give information in info.plist, under the identifier,  
Application

fonts resource path.
2. Add this file into the Resources folder.
3. Invoke using this method. [NSFont fontWithName:CP_FONT_NAME size: 
11],

NSFontAttributeName,

Works fine. But what I want is to use this font file only in english  
locale

and in other locales it should fallback to the system fonts of the
corresponding controls.

Any pointers highly appreciable.

Regards
Mustafa
___

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

___

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: Where are the interface builder components?

2009-11-17 Thread Ricky Sharp

On Nov 16, 2009, at 9:28 PM, Sandro Noël wrote:

 I guess i'll have to make my own.
 I just find it sad to have to duplicate work, it's unproductive.


True, but keep in mind the amount of effort that Apple would need to do if they 
provided the custom control, etc:

* Must work with localized content
* Must work with accessibility
* For particular controls, probably need to have multiple sizes (large, small, 
mini)
* Probably will need to expose custom bindings
* Should work in resolution independence.
* Probably some other things I'm missing.

Definitely file an enhancement request though.  I'm sure Apple will strongly 
look into providing something if several developers end up asking for the same 
type of controls.

___
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/archive%40mail-archive.com

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


Re: sizeWithAttributes Cutting Off Drop Shadow, Italic Mask?

2009-10-30 Thread Ricky Sharp


On Oct 30, 2009, at 10:10 AM, Chunk 1978 wrote:

does sizeWithAttributes not take into account the offset of an  
NSDropShadow
or italic font mask?  i have a dictionary of attributes for a  
string, and
i'm trying to produce an image for the drag that doesn't crop the  
image with

these attributes.



It doesn't consider the shadow metrics.  I filed this in 2004:

rdar://3910767 Cocoa string drawing doesn't take shadow metrics in  
account


The workaround is to use the shadow metrics and modify the size  
value.  I do the following myself:


width modified by (shadow x offset plus blur radius)
height modified by (shadow y offset plus blur radius)

I believe the Italic issue also needs a workaround (search this list  
archives because that has come up before)


___
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/archive%40mail-archive.com

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


Re: language based scaning

2009-10-15 Thread Ricky Sharp


On Oct 15, 2009, at 1:11 PM, Nz Gmail wrote:

 what I'm trying to do is sort of Twitter client, in which the  
tweets can be English or Arabic so in  case of Arabic the alignment  
should be from right to left, i hope I made it clear this time

cheers



In that case, you can probably scan the text for a Unicode code point  
within the ranges 0x0600 to 0x06FF and 0x750 to 0x77F.   Hopefully  
that should cover it.


However, should the Arabic text also contain presentation forms, code  
points can also fall within 0xFB50 to 0xFDFF and 0xFE70 to 0xFEFF.



Now, I'm not sure about your exact content, but you may have blocks of  
text that are primarily English with Arabic content and visa versa.   
So, maybe just scan the first character and drive the layout based on  
that?


e.g.

[English block of text with arabic phrase here.whitespace]
[whitespace.english phrase here with text of block Arabic]

An exception arises if an Arabic block of text begins with Western  
Arabic digits; you may have to continue scanning until you reach the  
first alphabetic character.


___
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/archive%40mail-archive.com

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


Re: Language based scanning

2009-10-13 Thread Ricky Sharp
You probably do not want to approach things this way. Arabic is  
bidirectional and you may have situations where you have a mixture of  
languages.


What you should look at instead is to just localize your app to  
Arabic. In the Arabic version of your nibs, make the necessary  
adjustments.


Sent from my iPhone

On Oct 13, 2009, at 6:16 AM, Nz Gmail nassers...@gmail.com wrote:


Hi,
Is there is a way to figure out the occurance of Arabic chars so the  
label's alignment would be set accordingly (right to left)? 
___


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

___

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

2009-10-10 Thread Ricky Sharp


On Oct 10, 2009, at 9:36 AM, DKJ wrote:

I've got an NSArray that I initialise with data from a plist stored  
on a remote webserver. I've been doing it like this:


	NSURL *url = [NSURL URLWithString:@http://www.server.com/ 
data.plist];

NSArray *myArray = [NSArray arrayWithContentsOfURL:url];

which has been working just fine so far.

But now I'm reading through the URL Loading System docs, and  
wondering if I should be using all the NSURLRequest stuff instead.  
It's more complicated, so are there any advantages it would have  
over what I'm doing now?



arrayWithContentsOfURL: is a blocking call.  Typically, when working  
with data over networks, it's best to do things asynchronously.


When going the async route, you're going to get much better error- 
handling too.  The call you're currently using will simply return nil  
upon any error.  You then wouldn't know if the URL is bad, timeout  
occurred, file is bad, etc.


___
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/archive%40mail-archive.com

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


Re: UIControl touchInside property

2009-09-29 Thread Ricky Sharp

I believe there is some slop area for controls in general.

For example, the Edit button in the nav bar in Mail when in a list of  
messages. The initial tap must be within the defined bounds. But when  
tracking off or back in, the bounds used to determine in vs out is  
larger. That property appears to know another the larger area.


Sent from my iPhone

On Sep 29, 2009, at 9:31 AM, Roland King r...@rols.org wrote:

cocoa touch question - I have searched devforums with the usual  
total lack of result.


UIControl has a 'touchInside' readonly property which, according to  
the documentation returns
   A Boolean value that indicates whether a touch is inside the  
bounds of the receiver. (read-only)



but it doesn't really seem to do that. Experiments calling it each  
time I get called on continueTrackingWithTouch:withEvent: shows that  
it stays YES until the touch moves quite some distance from the  
control (like about an inch on the iphone screen). Logging  
touchInside along with a hitTest on the event, the touchInside and  
hitTest are both YES inside the control, the hitTest instantly moves  
to NO as I cross the border but touchInside stays YES for some  
distance, eventually they both become NO. (code and output below).


Should I consider 'touchInside' to be more of a 'user-interface'  
flag which is telling me that a touch has moved far enough from the  
control that standard control behavior says we're now far enough  
away to be considered 'outside' and 'inside' is really an area both  
inside and some distance from the control? I'm fine with that if  
that means my controls will act like the standard controls.


Anyone come across this and had similar thoughts? I'm happy to file  
a documentation radar if I think I understand what's really going on  
here.




-(BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent  
*)event

{
   CGPoint locInView = [ touch locationInView:self ];
   NSLog( @continue tracking: %d : %d, [ self isTouchInside ],  
[ self hitTest:locInView withEvent:nil ] == self );

   return YES;
}

2009-09-29 22:16:26.525 Buttonz[62084:207] begin tracking: 0 : 1
2009-09-29 22:16:28.754 Buttonz[62084:207] continue tracking: 1 : 1
2009-09-29 22:16:28.887 Buttonz[62084:207] continue tracking: 1 : 1
2009-09-29 22:16:29.188 Buttonz[62084:207] continue tracking: 1 : 1

... move to the edge ...

2009-09-29 22:16:31.126 Buttonz[62084:207] continue tracking: 1 : 0
2009-09-29 22:16:32.697 Buttonz[62084:207] continue tracking: 1 : 0
2009-09-29 22:16:32.763 Buttonz[62084:207] continue tracking: 1 : 0

... keep moving until about 1 away from the edge ...

2009-09-29 22:16:36.254 Buttonz[62084:207] continue tracking: 0 : 0
2009-09-29 22:16:36.272 Buttonz[62084:207] continue tracking: 0 : 0

... finger up ...

2009-09-29 22:16:36.472 Buttonz[62084:207] continue tracking: 0 : 0
2009-09-29 22:16:36.757 Buttonz[62084:207] end tracking: 0

___

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

___

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 to Mac Synchronization

2009-09-24 Thread Ricky Sharp
This is possible, but only over WiFi. I'm currently working on a  
feature to do bi-directional syncing between the Mac and iPhone  
versions of my app. I'm also using Bonjour for self-discovery (if you  
go this route, make sure to register your service at www.dns-sd.org)


Feel free to file an enhancement request to allow a connection to be  
made over the dock connector.


Sent from my iPhone

On Sep 24, 2009, at 8:20 AM, Gerriet M. Denkmann  
gerr...@mdenkmann.de wrote:


I am thinking about an iPhone app which (while it is running)  
collects data and stores it into some file.
And there should be a Mac app, which, when the iPhone is connected  
to the computer, transfers the collected data to the Mac.


Like iPhoto does with photos.

Is this possible? Or are iTunes and iPhoto the only apps which can  
synchronize data between Mac and iPhone?



Kind regards,

Gerriet.

___

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

___

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: UITableView Custom cell with image

2009-09-22 Thread Ricky Sharp
Please post your code. One app I have displays a list of 1,089 items.  
Three rows are visible on the screen and each row displays an image of  
size 89 x 128.


I use the standard method of reusing table cells and simply assign the  
image only when the cell is to be displayed. There is some stuttering,  
but only if I try to flick through the list very fast. Normal swipes  
are fluid. This is also on a 3G iPhone.


Sent from my iPhone

On Sep 22, 2009, at 2:26 PM, Development developm...@fornextsoft.com  
wrote:


I have a UITableViewCell with a UIImageView that's 44X44 pixels. I'm  
loading three different tables with a total of around 200 images  
none of which are more than 100k.
So. My problem is memory warnings that cause the app to quit quite  
unceremoniously. I have tried loading the image when the cell is  
viewed. That makes an ugly stutter. And no help with memory  
warnings. I have tried storing the image in memory and simple adding  
the image to the UIImageView when the cell is returned. Same  
problem, lots of stutter and memory warnings.


What can I do to have the image in the cell, without the memory  
problems?

___

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

___

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: Build Issue?

2009-09-01 Thread Ricky Sharp


On Sep 1, 2009, at 4:10 PM, Thomas Willson wrote:

Is there anything else I can include to help someone answer my  
question? My next step might have to be reinstalling the OS.


Begin forwarded message:


From: Thomas Willson thomas.will...@me.com
Date: August 31, 2009 10:53:50 PM PDT
To: cocoa-dev@lists.apple.com
Subject: Build Issue?

I am having a really odd issue while developing my program. I was  
developing my program and went to build. It built fine but when I  
ran it, I got no data back from an NSTask. If I copy the XCode  
project to my other mac, it builds fine. A copy built on the other  
computer works fine on both and a copy built on the first computer  
doesn't work on either. I have since upgraded to Snow Leopard and  
XCode 3.2 on the first computer and still experience the same  
problem.



Without any sort of code, logs, etc., it's going to be difficult.  One  
really wild guess would be are you making any assumptions about your  
user id?

___
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/archive%40mail-archive.com

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


Re: Disabling Exposé in SystemUIMode

2009-08-06 Thread Ricky Sharp


On Aug 5, 2009, at 9:39 PM, Pierce Freeman wrote:

Which version of OS X are you using?  With the latest of Leopard, it  
just

doesn't seem to work.



When writing my initial response to this thread, it was 10.5.7.

Just tested with 10.5.8 and all is still well (no Expose, no process  
switching).


___
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/archive%40mail-archive.com

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


Re: Disabling Exposé in SystemUIMode

2009-08-06 Thread Ricky Sharp


On Aug 6, 2009, at 10:10 AM, Pierce Freeman wrote:

Yeah, I completely copied his code and inserted it into my project.   
Even
odder, it doesn't allow the Apple-Tab function (which is what it is  
supposed

to do) but lets Exposé work just fine.

I don't mean that it broke in the latest version of Leopard, as the  
old
version I was using still did not have it enabled.  I was wondering  
if it
worked on Leopard at all, and based on your reply it does.  So I  
don't have

much idea as to what to try now.



Hmm, I wonder if it has something to do with how I create my windows?

I create blanking windows and put one of those on each screen  
(borderless window covers entire screen).  Then, I create a content  
window (also borderless) that is then set to appropriate size (1024 x  
768 in my case), centered on, and made a child of, the blanking window  
on the main screen.


The call to SetSystemUIMode is made in applicationDidFinishLaunching:  
before I create windows.


Both the blanking and content windows are subclasses of NSWindow.

Blanking window's designated initializer is just a thin wrapper around  
NSWindow's initWithContentRect:styleMask:backing:defer:


- styleMask is NSBorderlessWindowMask
- backing is NSBackingStoreBuffered
- defer is NO

I then set these additional attributes:

- hidesOnDeactivate (YES)
- releasedWhenClosed (NO)
- movableByWindowBackground (NO)
- hasShadow (NO)
- optimizedDrawing (YES)
- opaque (YES)

I also override canBecomeKeyWindow (returns NO) and  
canBecomeMainWindow (also returns NO).



In my content window subclass, same setup as blanking window (in terms  
of attributes listed above).  And, overrides to canBecomeKeyWindow and  
canBecomeMainWindow return YES.



___
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/archive%40mail-archive.com

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


Re: Disabling Exposé in SystemUIMode

2009-08-05 Thread Ricky Sharp


On Aug 5, 2009, at 8:45 PM, Pierce Freeman wrote:

I am wondering if anyone knows of a way to disable Exposé in  
SystemUIMode.
I am using this class to create a kiosk-based application and don't  
want the
user to be able to switch between other windows.  If there isn't a  
way to do

this inside the class, is there another class that can accomplish this
instead?



Using SetSystemUIMode disables Expose in my app just fine.  I call it  
with these parameters:


OSStatus status = SetSystemUIMode (kUIModeAllHidden,  
kUIOptionDisableProcessSwitch);


There's a technote here which covers the options (although seems a bit  
outdated)


http://developer.apple.com/technotes/tn2002/tn2062.html

___
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/archive%40mail-archive.com

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


Re: Borderless window and focus

2009-07-21 Thread Ricky Sharp


On Jul 21, 2009, at 4:56 PM, ss2 cire wrote:

I have the following code to initialize a borderless window for  
fullscreen


- (void)initFullScreenWindow
{
NSScreen *theScreen = [[NSScreen screens] objectAtIndex:0];
	NSRect screenRect = NSMakeRect(0, 0, [theScreen frame].size.width,  
[theScreen frame].size.height);


fullScreenWindow = [[NSWindow alloc] initWithContentRect:screenRect

   styleMask:NSBorderlessWindowMask

 backing:NSBackingStoreBuffered

   defer:YES];
}


I would recommend creating a subclass of NSWindow.  In its designated  
initializer, call initWithContentRect as above.  You may also want  
to set the following properties:


[self setMovableByWindowBackground:NO];
[self setHasShadow:NO];
[self useOptimizedDrawing:YES];


Also provide these in your subclass:

- (BOOL)canBecomeKeyWindow
{
return YES;
}

- (BOOL)canBecomeMainWindow
{
return YES;
}


In your code that creates the instance of this custom window, issue a  
makeKeyAndOrderFront on that instance.  Things should then work a-ok.



then i have this code to show/hide the menubar and do my  
fullscreen window magic:


- (IBAction)showHideMenubar:(id)sender
{
if(fullScreenWindow == nil) {
[self initFullScreenWindow];
}
if([NSMenu menuBarVisible]) {
[NSMenu setMenuBarVisible:NO];
[RSCWindow orderOut:self];
[fullScreenWindow setContentView:rsWebView];
[fullScreenWindow makeKeyAndOrderFront:self];
} else {
[fullScreenWindow orderOut:self];
[RSCWindow setContentView:rsWebView];
[RSCWindow makeKeyAndOrderFront:self];
[rsWebView setFrame:rsWebViewNormalWindowFrame];
[NSMenu setMenuBarVisible:YES];
}
}


You can also use the SetSystemUIMode API to control the visibility of  
menu bar and/or dock.



___
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/archive%40mail-archive.com

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


Re: Where to release in UIView

2009-07-18 Thread Ricky Sharp


On Jul 18, 2009, at 1:09 PM, DKJ wrote:


On 18-Jul-09, at 8:50 , Fritz Anderson wrote:

You have to release shadingAreas. You alloc'ed it, you own it.



Yes, I realise that. What I'm wondering is where to do it, since  
it's initialised in the awakeFromNib method, rather than in  
initWithFrame:.



You really should read up on memory management.  It does not matter  
where you created that object.  If your view will own that object, it  
should release it in dealloc.

___
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/archive%40mail-archive.com

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


Re: Japanese Language

2009-07-15 Thread Ricky Sharp


On Jul 15, 2009, at 5:36 PM, Development wrote:

Ok, I lucked out and got a great chance at releasing a bit of  
software in japan. The problem is that it is 50/50 client to web. My  
primary concerns are string translation from iPhoneOS to data being  
stored in a mysql database. I have spent quite a bit of time  
googling and am still not sure but is the japanese data that will be  
sent from my application to my server utf-8? Or is it utf-16 as I  
for some reason thought. Everything sent to the server is pre  
encoded for transport, stored and then unencoded by the app so I  
feel at least a level of confidence that if I encode with the  
correct string encoding my server side will just accept and store  
the data. I dunno. Maybe I'm completely confused.



You'll want to first understand the encoding of your endpoints and  
then pick an appropriate transport encoding.


In terms of MySQL, you can define the encoding of a column to be  
something like this:


varchar(100) character set UTF8

Or, pick whatever encoding you deem appropriate (perhaps UTF-16?)

On the iPhone, all textual data in memory (e.g. NSString) will be  
UTF-16.  If you store data in files on the iPhone, you'll want to  
store them in some well-known encoding.  This will typically be UTF-16  
especially if you simply archive NSString objects.


As for the transport, I would highly recommend UTF-8 as no  
byteswapping is needed.  For most Latin-based data, the number of  
bytes taken up in UTF-8 will be less than what is used by UTF-16.  For  
Japanese (and many other languages), the number of bytes of UTF-8 will  
be more than UTF-16.  Just wanted to point that out in case you have  
insanely strict bandwidth requirements.


Then, it's just a matter of calling the correct APIs at each endpoint  
to ensure you don't mangle the text.



___
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/archive%40mail-archive.com

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


Re: Clarification on accessors? (was: Yet another memory management question)

2009-07-09 Thread Ricky Sharp


On Jul 8, 2009, at 10:16 PM, Jeff Laing wrote:


No, it doesn't.  It would in fact violate the encapsulation principle
if your -dealloc method required your accessors to not rely on  
certain

state.


The ability to override accessors violates encapsulation because  
it adds additional restrictions to the accessor that the superclass  
is not aware of.


If you can't write your override of an accessor in such a way that  
you don't place additional restrictions on the superclass, you  
shouldn't do it.  Because its not possible for you to make the  
assumption that the superclass will never care - without making  
(unjustifiable) assumptions about the superclasses implementation.


My response was to someone presumably writing about Design Patterns,  
I believe who wanted to know what was the best approach to take.  My  
opinion is that you should *not* assume that subclassers are idiots,  
because it doesn't matter how much bullet-proofing you put in,  
there's always going to be a worse idiot come along.  Better to make  
them all have to work carefully, than to avoid using things *they*  
might screw up.



I'll agree with Jeff on his points here.

In my personal situation, I'm the only person working on code at my on- 
the-side home business.


But, although I'm the only author, I have never had the need to  
subclass any accessors.  And, I've always called accessors from within  
init and dealloc (as well as copyWithZone: and encodeWithCoder:).   
Such code is in shipping apps (Mac OS X and later iPhone OS) starting  
in 2004.  The benefits of bottlenecking code through accessors like  
this is it can really help in debugging.  I know for a fact that every  
access to a property does so via one line of code; easy to instrument  
and only one breakpoint needed.


However, I also know that subclassing accessors may be needed. And in  
those cases, I'm going to assume that the coder(s) will understand the  
pitfalls.


In my opinion, this is one of those all depends situations.

___
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/archive%40mail-archive.com

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


Re: Yet another memory management question

2009-07-05 Thread Ricky Sharp


On Jul 5, 2009, at 4:02 AM, Benjamin Dobson wrote:



On 5 Jul 2009, at 05:10:12, mmalc Crawford wrote:

If you manipulate an instance variable anywhere other than in an  
initialiser or a dealloc method, you should use a suitable accessor  
method.


Does this apply to instance variables that are not objects too?



Yes.

___
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/archive%40mail-archive.com

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


Re: What is the best way to store some kind of identifying string in an interface builder object?

2009-06-18 Thread Ricky Sharp


On Jun 18, 2009, at 5:15 PM, Chilton Webb wrote:


Hi Greg!

Thanks for writing back.

On Jun 18, 2009, at 4:52 PM, Greg Guerin wrote:
Is there a way to add a tag an IB object in such a way that it is  
not visible to the user, but in such a way that I could reference  
it from my app?
Maybe the -tag method: it returns a 32-bit integer..  It's settable  
in IB as the control's tag value.  I don't know if iPhone has it.


Since it's only 32-bits I don't know how useful it would be for  
your intended purpose.  But IB has no inherent use for it, and it  
is readable from the app.


It *would* be useful, but IB doesn't let you set it to a string in  
Cocoa. It's limited to numeric values, which makes it less useful  
for humans.


For a bit of perspective, this is doable in *CARBON* apps, via the  
'Command' attribute in Interface Builder. You can only use 4  
characters, but it's damned useful. It's commonly used to create  
interfaces that don't require hard linkage between the code and the  
view. Somewhat ironically, despite that MVC is the law of the land  
in Cocoa, this option is not available to Cocoa apps.


I was sure I was mistaken about this! Any other suggestions?



As was suggested, probably a utility app.

I know when I moved one of my apps from Carbon to Cocoa, I also  
created IB palettes (later plugins) for all the UI.  I put conversion  
APIs around the 'tag' attributes.  I could then enter/display four- 
char codes.


___
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/archive%40mail-archive.com

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


Re: Touchscreens and control scaling

2009-06-04 Thread Ricky Sharp


On Jun 4, 2009, at 2:51 AM, Joe Ranieri wrote:



On Jun 4, 2009, at 03:44, Ben wrote:


Hi list,

I've been sketching out an application and could do with a little  
advice on which cocoa-direction to take. It's a full-screen (kiosk)  
type app, running in a very controlled environment (not for wide  
release) but which would run on an external touchscreen monitor.


While I can make buttons and labels big enough for fingers to poke,  
I'm concerned about controls like table headers and scrollers being  
large enough to make finger-size targets. I'm asking sooner rather  
than after testing the usability in case there are special  
considerations I should take before writing the first lines of code.


The only options I can think of are:

1. Make a normal app and use quartz debug to scale *everything* up
2. Subclass and/or redraw any controls too small for finger taps
3. Shut up and try it out first


I don't think option 1 will work well. Apple hasn't done too much to  
make anything resolution independent. Try running stuff on a non-1.0  
scale factor to see. We ended up going with option 2, partially for  
usability, and partially because we wanted an entirely themed kiosk  
environment anyways.



For a kiosk, you should definitely consider your own UI.  That's what  
I have done.  You'll also find that if your app will be exclusively  
used in touch environments, some of the Aqua controls may not fit well  
at all (since they were designed primarily for point-and-click).   
(Same thing goes for iPhone OS UI; totally different set of controls  
and behaviors).


In terms of resolution independence, note that while Apple's own Cocoa  
controls may not yet be RI-ready, the underlying frameworks are  
basically all there.  I actually submitted an app for the design  
awards back in Tiger days that was RI-savvy.  It not only worked with  
integral scale factors, but the fractional values as well.


___
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/archive%40mail-archive.com

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


Re: drawing image

2009-05-04 Thread Ricky Sharp


On May 4, 2009, at 6:45 PM, Mike Manzano wrote:

It's inverted because of differences in coordinate systems between  
the image and the view it's being draw into.


Before you draw the image, invert it:

[[self image] setInverted:YES] ;



Before doing that, you should first ask the cell's view if it's  
flipped (see isFlipped).


Cells can be contained by views in which isFlipped will return  
different results.


___
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/archive%40mail-archive.com

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


Re: Best way to get a non-repeating random number?

2009-04-14 Thread Ricky Sharp


On Apr 13, 2009, at 7:58 PM, Eric E. Dolecki wrote:

For an example I might want to generate numbers from 1 to 10 over  
and over.
All I want to do is when I generate a new number is not allow it to  
equal
the previously held value. I can imagine a few approaches but I just  
wanted

to make sure I was using the most accepted way of doing it.


Coming in late to this thread...

Personally, for all things random, I now use the Mersenne Twister  
algorithm.  You can license that for free; just put in the specified  
acknowledgement text somewhere in your app/docs.


And, for shuffling, I use the Fisher-Yates algorithm.


For the specific problem above, you sort of have a modified pick  
without replacement scenario.


Assume you start with an array of 10 values where the values are set  
from 1 to 10.


The first time you pick a number, you randomly generate the index of  
the number (so 0..9).


That first value then becomes picked.  Your array is then modified  
to contain the 9 remaining values.


The 2nd, 3rd, etc. time you pick a number, you basically just pick  
from the nine remaining indexes. Then, put back the item you picked in  
the previous iteration and pull out the item you picked this iteration.


___
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/archive%40mail-archive.com

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


Re: Need localization-proof method of transporting dates.

2009-04-08 Thread Ricky Sharp
You can always specify the specific locale to use in a custom sorting  
method.


Sent from my iPhone

On Apr 8, 2009, at 6:46 AM, Graham Cox graham@bigpond.com wrote:



On 08/04/2009, at 2:45 PM, Graham Cox wrote:

Thanks for all your help - just remains to be seen now if certain  
users can now open my app! ;)




It occurs to me that there is another potential problem that I've  
overlooked. System locale affects sorting, right? At least the  
comment in the System Preferences  International suggests that to  
be the case, and it makes sense of course.


So when I hash a dictionary, I sort the keys to ensure a consistent  
order for the items, but if the sorting can vary with locale, I'm  
going to be stuffed. Is there a locale-proof way to sort the keys?  
The current code is:


@implementation NSDictionary (GCHash)

- (NSData*)gc_hash
{
   NSMutableData*data = [NSMutableData data];
   NSMutableArray*keys = [[self allKeys] mutableCopy];

   [keys  
sortUsingSelector:@selector(caseInsensitiveCompare:)];//  
--- potential problem


   NSEnumerator*iter = [keys objectEnumerator];
   idkey;
   idobj;

   while(( key = [iter nextObject]))
   {
   [data appendData:[key gc_hash]];

   obj = [self objectForKey:key];
   [data appendData:[obj gc_hash]];
   }
   [keys release];

   return data;
}

@end



--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/rsharp%40mac.com

This email sent to rsh...@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: IB Plugin help

2009-04-04 Thread Ricky Sharp


On Apr 3, 2009, at 7:39 PM, jmun...@his.com wrote:

I have one more question:  How does one replace the blue cube object  
icon that tags on the text field with my formatter's graphic?



That, I do not know how to do.   I'll definitely update the my example  
though if I or someone else figures it out.


___
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/archive%40mail-archive.com

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


Re: IB Plugin help

2009-04-04 Thread Ricky Sharp


On Apr 3, 2009, at 8:28 PM, jmun...@his.com wrote:


OK, now I have one more question.

I'd like to install and use my plug-in.  However, when accessing  
IB's preferences-Plug-ins and attempting to add the plug-in I get:   
1) when simply adding the ibplugin an error that states the file is  
missing necessary resources and to reinstall the bundle, or 2) when  
opening the framework folder no error but also nothing else either.


What else did I miss



This actually depends on what you'd like to do.  For my own apps, I do  
what is documented in the ReadMe file from my sample plugin (see the  
'Installation' section).


In my case, I put the IBPlugin into the framework's resources folder:

+ MyIBPluginFramework.framework
  + Versions
+ A
  + Resources
+ MyIBPlugin.ibplugin

NOTE: There are other files/folders too; above just shows specifically  
where the plugin resides.


___
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/archive%40mail-archive.com

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


Re: IB Plugin help

2009-04-03 Thread Ricky Sharp


On Apr 3, 2009, at 6:43 PM, jmun...@his.com wrote:

I found one mistake where I didn't change the IBInspector class of  
File's Owner in the Inspector.xib to my Inspector subclass.  Doing  
that gave me an entry in the bottom box of the library, but no  
object in the middle pane...  How do I fix that?  Also, the image  
isn't displaying either.  I'm still getting the book entries under  
the Formatter name.


That being said, I also notice that my Inspector subclass doesn't  
have any sort of reference to my Formatter object.  Is it supposed  
to?  I should think it may need one.  The dox don't really go into  
that so I don't know for certain.  So, do I code it into the .h?   
And also the .m?


Boy, I wish there was an example to follow...



See the following for an example:

http://www.instantinteractive.com/private/samplecode/MyIBPlugin.zip

___
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/archive%40mail-archive.com

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


Re: Automatically replacing part of text in a text label

2009-03-17 Thread Ricky Sharp


On Mar 17, 2009, at 3:33 PM, Peter Ammon wrote:



On Mar 15, 2009, at 11:20 PM, Peter Zegelin wrote:

I have some text labels in a registration dialog that contain the  
application name eg


xxx Demonstration
Thank you for purchasing xxx

and so on.

I would like this registration dialog to be general enough that I  
can use it in multiple applications. Is there a simple way to  
replace the xxx with the actual application name at runtime? At the  
moment I'm thinking I'll have to wire every label up to my  
registration controller and do it in awakeFromNib, but I was hoping  
for something easier.


Thanks!

Peter


You could create a subclass of NSTextField that does its own  
replacement.  That would save you from having to create outlets.



What I've been doing (in Mac OS X as well as iPhone OS) is to store a  
string template in my localized strings file.  Then, use NSBundle APIs  
to fill in the app name at runtime.


For example:

[NSString stringWithFormat:NSLocalizedString (@Welcome to %@, @some  
comment),
[[NSBundle mainBundle]  
objectForInfoDictionaryKey:@CFBundleName]];


___
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/archive%40mail-archive.com

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


Re: UIView hidden - still drawing the subviews?

2009-03-17 Thread Ricky Sharp


On Mar 17, 2009, at 4:32 PM, Jelle De Laender wrote:


I've a UIView with some subviews (most of them are UIButtons).

When I hide an UIView  (setHidden:YES), I expect that the subviews  
are also hidden (not drawed)... but the subviews are still visible  
when I run my code.


How can I hide the subviews when I hide a UIView? Should I create a  
subclass and overwrite the setHidden: method (and recall setHidden  
on every subview) or is there a better way to do this?



Are you positive that your buttons are really subviews of your main  
view?  Sounds like they are simply siblings of your view instead.


A hidden view (UIView/NSView) will always hide all its subviews; no  
extra coding needed.


___
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/archive%40mail-archive.com

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


Re: What is using up so much memory here?

2009-03-10 Thread Ricky Sharp


On Mar 10, 2009, at 8:13 PM, James Cicenia wrote:

Yes, I realized I would need a different approach. I got too used to  
web gif/png and just doing overlays.
I have already told my designer to give me just bounded states with  
a spreadsheet of what he chopped
off from the top and left. This will then be inputted into the  
spreadsheet then into sqlite.



Are these images of each state perhaps always a solid color?  If so, I  
would highly recommend creating paths for each state and just filling  
the path as needed.


Any zooming will also give you great results as you'd be scaling  
vector-based content and not bitmapped content.


___
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/archive%40mail-archive.com

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


Re: How do I debug iPhone restarts?

2009-03-09 Thread Ricky Sharp
You should send such questions to the dedicated iPhone portal  
discussion forums.


In fact, many of your questions should have gone there instead of this  
list as they were not general Cocoa.


Sent from my iPhone

On Mar 9, 2009, at 10:41 AM, James Cicenia ja...@jimijon.com wrote:


Hello -

While testing on my phone, the iPhone just quits my app and doesn't  
write a crash log or such.


How does one debug this?

Thanks
James Cicenia

___

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

___

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: Core Data reads xml store value @ as @

2009-02-20 Thread Ricky Sharp


On Feb 20, 2009, at 6:45 PM, Jerry Krinock wrote:

There is an attribute in my Core Data document-based app whose  
string value can legitimately be a single single utf8 0x20 space  
character, @ .  (It's a user-selectable delimiter.)


When I save a document with this attribute value, reading the XML  
store file with BBEdit shows that it is a single space character,  
like this:


  attribute name=firstname type=string /attribute



I'd file that as a bug.  The XML above, while legal, will most likely  
always result in a value of attribute being an empty string.   
Whitespace is typically trimmed by XML parsers.


e.g. if you had:

attribute ...[NEW LINE]
[TAB][SPACE][NEW_LINE]
/attribute

You'd typically still get an empty string.

The solution is to wrap the value in a CDATA block.  But, I'm not  
familiar enough with CoreDate to know if that is some setting  
somewhere or an API call you need to make.


___
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/archive%40mail-archive.com

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


Re: Responding to view controller memory warnings (was Re: Outlets / IBOutlet declarations)

2009-02-19 Thread Ricky Sharp


On Feb 19, 2009, at 2:18 PM, James Montgomerie wrote:

Returning to this months-old thread...  Apologies for the length of  
the mail, I thought it best to summarise what went before.



I now have shipping iPhone OS apps and during all my tests and  
analyzing things in Instruments (connected to real hardware), I didn't  
see a reason to put the proposed code in.


Perhaps this is just how I've coded things, but I've seen views get  
unloaded and reloaded perfectly without any leaks.  This included my  
main screen view that was currently on the bottom of a nav  
controller stack (not the current view).  When I popped the current  
screen, it was appropriately re-loaded.  All IBOutlets re-wired, etc.


My dealloc code is doing stuff like:

self.someIBOutlet = nil;
self.someOtherIvar = nil;
...
[super dealloc]


I'm _definitely_ not trying to be argumentative or propose that others  
avoid the proper solution.  Just wanted to point out that in my real- 
world situation, I just haven't had the need for it.


___
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/archive%40mail-archive.com

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


Re: Responding to view controller memory warnings (was Re: Outlets / IBOutlet declarations)

2009-02-19 Thread Ricky Sharp


On Feb 19, 2009, at 3:52 PM, mmalc Crawford wrote:



On Feb 19, 2009, at 1:41 PM, Ricky Sharp wrote:

Perhaps this is just how I've coded things, but I've seen views get  
unloaded and reloaded perfectly without any leaks.



This isn't the issue.

The issue is how much memory can you free up in response to a memory  
warning.
If you don't follow this pattern, then you won't be freeing up as  
much as you could to.


If your app isn't getting memory warnings, you won't encounter this  
at all.



OK, things have finally clicked :)

Yes, I have never had memory warnings.  Just unused objects at this  
moment unloaded to make room for more.



___
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/archive%40mail-archive.com

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


Re: Responding to view controller memory warnings (was Re: Outlets / IBOutlet declarations)

2009-02-19 Thread Ricky Sharp


On Feb 19, 2009, at 3:57 PM, James Montgomerie wrote:


I feel like I may have opened a can of worms here.


Nope; my fault.  All this time I had misread the whole point of the  
threads.  My app has never received low-memory warnings.  So my  
observations in turn have nothing to do with it.


I will re-add the proper refactor to my to-do list.  There's a chance  
my particular apps will continue to never receive the warnings.  But,  
I want them to be good citizens should they ever occur.


___
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/archive%40mail-archive.com

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


Re: how to receive some string from iphone's app to stanalne app on mac?

2009-02-09 Thread Ricky Sharp
Bonjour is just for discovery. You need to add in network code to send  
and receive data. Check out the PictureSharing sample code. Not sure  
of exact names, but there are a few samples you will ultimately need  
that should have PictureSharing in their name.


Sent from my iPhone

On Feb 9, 2009, at 8:08 AM, Carlo Gulliani carlogulli...@yahoo.com  
wrote:



hi, everybody, i've 2 apps: ipone's app and app on my mac.

i wanna receive some message from iphone to my mac's app.

for example, my iphone's app has 2 buttons:

-(IBAction) first
{
// here i should send message FIRST to mac's app
}

-(IBAction) second
{
// here i should send message SECOND to mac's app
}

i prepared buttons for mac's app with bonjour service and iphone's  
bonjour service. when i launch mac's app  iphone's app, i seeing  
that my mac's app has found iphone's app via bonjour, now i should  
send message, but i don't know 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:
http://lists.apple.com/mailman/options/cocoa-dev/rsharp%40mac.com

This email sent to rsh...@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: iPhone Vibrate

2009-01-24 Thread Ricky Sharp


On Jan 24, 2009, at 5:31 PM, David Blanton wrote:


I want to be sensitive to battery usage in the iPhone.

When calling

AudioServicesPlayAlertSound ( kSystemSoundID_Vibrate  );

How much battery does this use?  I may be calling this 'alot' in my  
application.



Reposting messages will not get them answered any quicker.  In fact,  
you risk them not being answered at all.


Having said that, this is really the wrong forum for iPhone-specific  
questions such as this one.  It's best to ask on the dedicated iPhone  
developer forums when you log in to your iPhone dev account.


___
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/archive%40mail-archive.com

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


Re: Disabled button looks like enabled

2009-01-12 Thread Ricky Sharp
Do not do this. Users will be very frustrated when they cannot  
interact with that button.


Why do you think you need this?

Sent from my iPhone

On Jan 12, 2009, at 5:55 AM, Donnie Lee lpr...@gmail.com wrote:


Hi!

I'd like to create a disabled button that looks like enabled. If I
just set enabled to no, I got grayed button. Instead I do
[[theButton cell] setHighlightsBy:NSNoCellMask]; and it looks like
disabled but continues to receive events. Is there a way to make a
disabled button that looks like enabled? Thanks in advance!

Donnie.
___

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

___

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: A Data Object in Cocoa

2009-01-10 Thread Ricky Sharp


On Jan 10, 2009, at 6:45 AM, Alastair Houghton wrote:


On 10 Jan 2009, at 00:11, Adam Foltzer wrote:

I've noticed a pattern in some Apple code where the instance  
variables are
all prefixed with an underscore, but the property name, and  
therefore the

accessors, are what you'd expect.


Except that there's a long-standing rule that we shouldn't use  
leading underscores for either member variable names or private  
method names because names beginning with underscore are reserved  
for Apple's own use (even member variable names, IIRC).  So if  
you're going to use a prefix, it's probably best to pick something  
like m (for member).


But in general I think it's better not to prefix the names of member  
variables, and then in your initialisers, to use a different name  
for the argument.



My personal pattern is to leave the ivars as-is.  Then, for  
parameters, I prefix with 'a' or 'an'.  Local variables are prefixed  
with 'the':


'value' is the name of the ivar...

- (void)incrementBy:(int)aValue
{
int theOldValue = value;

value = aValue;

if (aValue != theOldValue)
...
}

___
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/archive%40mail-archive.com

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


Re: A Data Object in Cocoa

2009-01-09 Thread Ricky Sharp


On Jan 9, 2009, at 8:28 PM, Adam Foltzer wrote:

I stand corrected; I've seen this many times before, and have never  
had
problems. I'm guessing it's one of those patterns that causes  
problems under

specific circumstances?


Yes, only under certain situations.  I've been personally calling  
accessors from both init and dealloc in shipping apps over the past 5  
years.  However, in my specific case, I'm the sole author so have  
complete control over how the code is called.


I do have a todo in my eventual list of tasks to refactor the code.


On Fri, Jan 9, 2009 at 7:40 PM, Kyle Sluder kyle.slu...@gmail.com  
wrote:


On Fri, Jan 9, 2009 at 7:11 PM, Adam Foltzer acfolt...@gmail.com  
wrote:

- (id)initWithInt:(int)foo
{
  if (![super init])
  return nil;
  [self setFoo:foo];
  return self;
}


Do not use getters and setters in -init.  You should be accessing the
ivars directly.


___
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/archive%40mail-archive.com

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


Re: Reversing a String

2008-12-31 Thread Ricky Sharp


On Dec 31, 2008, at 10:52 AM, Michael Ash wrote:


The key is the usage of -rangeOfComposedCharacterSequenceAtIndex:.
Without calling this method or doing the equivalent to what it does,
your code will suffer the problems I described above.

I tested that code with the string @abcdéf턞g (that's an  
accented e

using a combining diacritical before the f, and the aforementioned
musical note at the end) and it worked as expected.

I don't guarantee that my code will work on everything. Unicode is
weird enough and covers enough weird languages that there are probably
situations where this will still fail. But it covers most of the
tricky bits, and at least will always produce valid unicode output.



Reversing a string only really makes sense for certain languages  
anyhow.  Perhaps even just English.  The rendering of reversed strings  
may also get a bit weird for text involving positional variants.


Anyhow, attempting to construct a universal solution will either be  
too difficult or perhaps not possible.  The original poster should  
provide some extra clues as to what the output will be used for.


I'm all for 100% Unicode support by applications, but there are some  
situations where working with plain 'ol ASCII still makes sense.  In  
that specific case, reversing a string becomes trivial.


___
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/archive%40mail-archive.com

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


Re: modifier key query

2008-12-31 Thread Ricky Sharp


On Dec 31, 2008, at 11:36 AM, Sean McBride wrote:


Wesley Smith (wesley.h...@gmail.com) on 2008-12-26 3:04 AM said:


Is there a way to know if a modifier key (shift, ctrl, option, cmd,
etc) is pressed?  Obviously, there's this:
NSUInteger modifierFlags = [theEvent modifierFlags];

but what if you need to know this information independent of an
NSEvent?  Anyway to get it?  So far I haven't seen anything
encouraging in the docs.


There's GetCurrentKeyModifiers(), which is superbly documented in
CarbonEventsCore.h.  But sticking with NSEvent, if you can, if  
probably

better.



There's really nothing wrong with relying upon certain Carbon APIs.   
If or when Apple ever removes Carbon, I foresee APIs moving to new  
homes.


It's not like the current system has two shared libraries (Carbon/ 
Cocoa) and when Carbon goes, all APIs go with it.  In many cases,  
Carbon APIs are just wrappers over lower-level code.


If there are key pieces of functionality that you can do in Carbon,  
but not Cocoa, definitely file enhancement requests to add those APIs  
to Cocoa.

___
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/archive%40mail-archive.com

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


Re: NSSpeechRecognizer and Speech Recognition calibration

2008-12-27 Thread Ricky Sharp


On Dec 26, 2008, at 4:56 AM, Christopher Corbell wrote:

I'm working on an accessibility app for the visually impaired and  
was hoping

to use NSSpeechRecognizer.

I've found it extremely difficult to get NSSpeechRecognizer to behave
predictably on my system.  Does anyone on the list have experience  
with this
class  success with the Speech Recognition system preference  
panel?  Any

tips or tricks?

I find that that calibration dialog for the Speech Recognition  
settings
doesn't work at all for me.  I'm using a pretty standard external  
microphone
(built-in to a Logitech Webcam) with an intel Mac Mini.  I can see  
my signal
just fine and I'm speaking clearly in as accent-neutral a way as I  
can, and

still none of the test sentences ever highlights.  Is a headset mic
typically required, or is there some other gotcha here?


It must be your particular setup.  I've been doing SR ever since it  
debuted (Mac OS 8.x days) and have not had trouble when words/phrases  
are unique enough (as yours clearly are).


When I give NSSpeechRecognizer a very small and unambiguous command  
set, I
find it badly misses the mark.  For example I might have Play,  
Next, and
Stop in my command set, and it will interpret Next as Play,  
but it
will never interpret Play as a command - pretty unusable, I'm  
hoping it's

just a calibration issue.


Since the calibration dialog isn't working for you, it's not  
surprising that it's getting your phrases confused.  Make sure to get  
your setup working in the calibration area first.


One last note - is there any way to do proper dictation with this  
class or
will it only recognize the preset command list you give it?  I'm  
thinking
for example of prompting for a file name to save to, or a term to  
search on

- it would be nice to have true dictation, otherwise I'll resort to
providing an alphabet as a command set so the user can spell it out
(assuming I can get that to work).


No.  And, you definitely do _not_ want to add letters to your language  
model.  English letters have too many cases where sounds are extremely  
similar: 'B', 'C', 'D', 'E', 'G', 'P', 'T', 'V', 'Z' for probably the  
largest set.


When I worked on numeric input, I had to offer two modes (two  
different speech models driven by user-preference).  For example,  
'sixteen' and 'sixty' were often confused.  This got better over time  
though, but still not 100%.  For users that had trouble, they could  
switch to the other model in which they needed to speak individual  
digits instead: 'one six' and 'six zero'.  Now the phrases were unique  
enough to remove any confusion.


You really only have two options: (1) The user has a 3rd-party  
dictation solution or (2) your solution uses words/phrases for letter  
input.  For example the military alphabet (alpha, bravo, charlie,  
etc.) which was designed to work over very low-quality audio situations.


___
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/archive%40mail-archive.com

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


Re: Sorting an NSMutableArray

2008-12-20 Thread Ricky Sharp


On Dec 20, 2008, at 6:15 AM, Jacob Rhoden wrote:

How do you sort an NSMutableArray, when the difference between the  
two objects is determined by information not contained completely  
within the objects themselves. ie in Java you can implement a  
Comparator that takes two objects to compare then. Is this similar  
in Cocoa?


ie in this case I need to apply a mathematical algorithm using  
information from each object to determine which one is greater than  
the other.



See sortUsingSelector:


What I then personally do is to create a Sorting category on  
whatever object it is that the collection will contain.  For example:


@interface MyObject (Sorting)
- (NSComparisonResult)myCustomCompare:(MyObject*)rhs;
@end

Then, LHS is self and RHS is the param coming in.


___
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/archive%40mail-archive.com

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


Re: Newbie Question: implementing a stack

2008-12-19 Thread Ricky Sharp


On Dec 19, 2008, at 1:22 PM, Steve Wetzel wrote:

I am new to this list and new to mac programming as well.  I am  
working on implementing a stack as a category of NSMutableArray.  I  
want this stack to be able to store objects.  This is what I have so  
far:


//
//  Stack.h
//  Stack implements a basic stack object in an NSMutableArray object.

#import Foundation/Foundation.h

@interface NSMutableArray (Stack)
-(void)push:(id)obj;//push obj of on the stack
-(id)pop;   //pop top item off the 
stack
-(id)peek;  //look at the top item 
on the stack
-(void)clear;   //remove all objects from the 
stack
-(NSUInteger)size;  //return the number of items on 
the stack
@end


If I were doing this, I would actually create an object (subclass of  
NSObject) that would contain an NSMutableArray as an attribute.  That  
way, your API would be very clean.


What you have above would allow users to call any of the NSArray*  
suite of APIs in addition to yours above.  Sometimes too many APIs on  
an object can lead to issues.


My question involves storing objects on the stack.  As I understand  
it when I store an object on the stack, I am simply storing a  
pointer to the object on the stack.  If I create an NSString object  
called foo and do the following:


NSString *foo = [[NSString alloc] initWithString:@foo text];
[FractionStack push:foo];

I have put a copy of the pointer to foo on the stack.  If I now  
change foo, the top element on the stack changes also.  I do not  
want this to happen but I am not sure as to the best approach to  
make sure this does not happen.


In this specific case, you cannot change foo since NSString is  
immutable.  If you find yourself adding (pushing) items that are  
immutable, it would be best to make a copy or mutable copy as needed.


Also, I am thinking I likely will need to release these objects when  
I pop them and when I clear the stack.  Is that correct?


Just read up more on the memory management rules.  You can also decide  
on object-ownership rules.  Typically, the container objects retain  
objects added to them.  Then release them when removed.  That's all  
you should be concerned about.  It's then up to the original owner of  
the object to do the right thing.


___
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/archive%40mail-archive.com

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


Re: Drawing in a NSView out side of drawRect

2008-12-19 Thread Ricky Sharp


On Dec 19, 2008, at 6:20 PM, David Alter wrote:

I want to draw in a NSView but not when drawRect is called. To do  
this I
understand that I need to call lockFocus before drawing and  
unlockFocus
after. The drawing appears to happen but it is not until I  
deactivate the
window do I see my results. How can I get it to refresh once I have  
done my

drawing?
To test this out I have sub classed NSView and overloaded mouseDown.  
I added

the following code.

- (void)mouseDown:(NSEvent *)theEvent ;

{

   NSPoint loc = [[self window] mouseLocationOutsideOfEventStream];

   loc = [self convertPoint:loc fromView:[[self window] contentView]];

CGContextRef myContext =
(CGContextRef)[[NSGraphicsContext currentContext]graphicsPort];

   [self lockFocus];

   CGContextSetRGBFillColor (myContext, 1, 0, 0, 1);

   CGContextFillRect (myContext, CGRectMake (loc.x, loc.y, 10, 10 ));

   [self unlockFocus];

}

This will draw a box for each mouse click, but not until I  
deactivate my

window.



What you should do is do all drawing in drawRect:.  What happens when  
your drawRect: is called?  I bet you won't see any of the rects you  
had when clicking around.


Instead, maintain a list of rects that need to be drawn.  mouseDown:  
then simply adds a new rect to the list and calls setNeedsDisplay:.   
Or, if you profile things and need more speed, setNeedsDisplayInRect:


If you want things such that only one rect ever is drawn, just have  
mouseDown: set the values of that single rect and still call  
setNeedsDisplay:


___
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/archive%40mail-archive.com

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


Re: controlTextDidChange for UITextField?

2008-12-15 Thread Ricky Sharp


On Dec 14, 2008, at 5:15 PM, Debajit Adhikary wrote:


Is there any way to call a method each time the text of a UITextField
changes?
controlTextDidChange does not seem to exist for UITextField's


You'd be better served by using the appropriate forums for UIKit- 
related questions.


But for this specific case, please search the docs for UITextField.   
Hint: Look at the corresponding UITextFieldDelegate protocol reference.


___
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/archive%40mail-archive.com

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


Re: How Can I Notify DrawRect Method?

2008-12-09 Thread Ricky Sharp


On Dec 9, 2008, at 5:31 PM, I. Savant wrote:




Even if it were slower, contorting the code like this without
having profiled the code and demonstrated that this is in fact a
significant slowdown is bad practice.


 I disagree. Certainly it's profile first, but to have a view that  
reads a simple property from user defaults every time it draws  
requires more overhead than using an instance variable. Especially  
when you're using an NSColor object which must be properly archived  
and unarchived.


 Imagine adding complexity to this view and using multiple values  
like this per draw cycle, and having to draw a whole bunch of stuff.  
Directly reading colors from user defaults is suddenly a whole lot  
more expensive.


 It doesn't matter much for the simple case the OP presented, but it  
certainly does for a custom view that does heavy drawing, especially  
if it's involved in an animation.



Completely agree.  For all my custom views, I always create and cache  
various drawing objects.  These are often build-once objects.  I  
usually build them lazily as well.


e.g. I have an attribute named 'needsCreateColors'.  When drawRect is  
called, it checks that flag and calls 'createColors' if needed.


In some cases, other attributes, when set, will 'dirty' that flag  
followed by a setNeedsDisplay.  Colors will then be re-fetched/created  
and then reused until the next change comes along.


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How Can I Notify DrawRect Method?

2008-12-09 Thread Ricky Sharp


On Dec 9, 2008, at 7:25 PM, I. Savant wrote:


On Dec 9, 2008, at 8:09 PM, Ricky Sharp wrote:

In some cases, other attributes, when set, will 'dirty' that flag  
followed by a setNeedsDisplay.  Colors will then be re-fetched/ 
created and then reused until the next change comes along.


 Perfectly good example of timely optimization.

 The main reason (which I may not have communicated clearly) is  
because any unnecessary work at all is wasteful. Especially for  
mobile platforms (laptop and iPhone users will thank you for sparing  
their battery life ... or curse you for not caring).


 Asking for the shared user defaults instance, then asking it for a  
value, then unarchiving a more useful object from it, *then* using  
it to draw is certainly more work than caching the value only when  
it changes. It's not like it's performance tuning - it's *basic  
design*.



I suppose I'm from the camp of developers that started in the days of  
8-bit CPUs with limited memory.  My coding style tends to be very  
conscious of resources.  I also have quite a bit of embedded  
experience, so that further reinforces that style.


I've never seen situations where one wastes resources and doesn't at  
some point later have to refactor lots of code.  This typically comes  
into play not only when going embedded, but when massively scaling  
your app upwards.


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: iPhone Orientation

2008-12-08 Thread Ricky Sharp


On Dec 8, 2008, at 9:58 AM, I. Savant wrote:


On Sat, Dec 6, 2008 at 12:19 PM, Bruce Martin [EMAIL PROTECTED] wrote:
I'm not sure this is the right list but a search in the Archives  
returned no
results for this question so that makes this question a simple one,  
or maybe

no one else has had an issue with it.


 The best place for detailed discussion (officially, anyway) is the
iPhone Developer Center:

http://developer.apple.com/iphone/

 Registration, a US$100 fee, and a signed NDA are required. Apple's
way of limiting public release of information which they feel works.
:-)  There's also all the documentation that you should probably read
(since this is a pretty basic function that should be easily found
with a search of the documentation) ...


Not to mention the existing sample code from Apple.

Anyhow, there's other reasons for Apple moving towards an on-line  
discussion forum format.  E-mail lists did not address many of the  
developer's needs.



 Unofficially, most iPhone-related discussions seem to be allowed on
this list but the official rules of this aren't yet entirely clear.


The boundaries sometimes do blur.  For example, the recent thread  
about responding to low-memory situations.  While clearly only an  
iPhone OS issue, it did raise many best practices that would work in  
general.


My personal take... Any FoundationKit or fundamental types of  
questions should be OK on this list.  However, specific UIKit-related  
stuff should go elsewhere.  This is nothing new.  For example,  
developers often need to step down to direct quartz APIs and often the  
best forum for help is the dedicated quartz-dev list.  I thus view  
UIKit as being a very specialized area and thus deserves a more  
dedicated forum.


For my personal iPhone OS needs, I've gotten all answers by (a)  
reading docs, (b) working through Apple's sample code, (c) attending  
the iPhone tech talk and (d) contacting DTS** when all else failed.


** You'll get two DTS incidents in the iPhone standard account (i.e.  
you don't have to use up the ones in your Select/Premier account  
should you have those as well).


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Reading in XML with iso-8859-1 encoding?

2008-12-06 Thread Ricky Sharp


On Dec 6, 2008, at 4:35 AM, Amy Gibbs wrote:

I've got a web based xml file in iso-8859-1 encoding that I'm trying  
to read into an NSXMLDocument.


I've got the following code, but I can't seem to make it work? (I've  
tried all manner of combinations)



//create the url
NSString *urlString = [NSString stringWithFormat:
			  @http://www.willowtreecrafts.co.uk/ag/ 
sesbuddyimport.php];

NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url

cachePolicy:NSURLRequestReloadIgnoringCacheData

timeoutInterval:30];
//fetch the xml response
NSData *urlData;
NSURLResponse *response;
NSError *error;
urlData = [NSURLConnection sendSynchronousRequest:urlRequest

returningResponse:response

error:error];


if (!urlData){
NSAlert *alert=[NSAlert alertWithError:error];
[alert runModal];
return;

}
//parse the xml response
[doc release];
[doc setCharacterEncoding:@iso-8859-1];



I'm guessing that doc is initially nil, so the above two lines are  
doing nothing (messages sent to nil).




	//NSString *xmlstring = [NSString stringWithContentsOfURL:url  
usedEncoding:@iso-8859-1 error:error];
	doc=[[NSXMLDocument alloc]initWithData:urlData options:0  
error:error ];


	//doc=[[NSXMLDocument alloc]initWithContentsOfURL:url options:0  
error:error];
	//doc=[[NSXMLDocument alloc]initWithXMLString:xmlstring options:0  
error:error];



I get an error telling me that the input is not in UTF-8 encoding. I  
know the input isn't UTF-8, but how can I get it to accept the  
iso-8859-1 file?




You can probably simplify this a bit by using  
stringWithContentsOfURL:encoding:error.  Note 'encoding' and not  
'usedEncoding'.  The former allows you to specify the encoding.  In  
this case, use the constant NSISOLatin1StringEncoding (which is  
ISO_8859-1).


Side note.  Some parsers are especially picky about encoding names, so  
best to always use the constants.  The official string for this  
particular encoding is ISO_8859-1.  Some parsers allow aliases or  
modifications as well (hyphens, lowercase, etc.)


Then, feed the string (which is now properly decoded) into a new XML  
doc for parsing:


NSXMLDocument* theXMLDoc = [[NSXMLDocument alloc]  
initWithXMLString:theString options:myOptions error:myError];


//do work

[theXMLDoc release];

___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Reading in XML with iso-8859-1 encoding?

2008-12-06 Thread Ricky Sharp


On Dec 6, 2008, at 7:17 AM, Amy Gibbs wrote:

Is this 10.5 only? It doesn't seem to be recognised by xcode 2.5,  
and it doesn't run on my machine at all. I should have mentioned I'm  
targeting 10.4 with this.


stringWithContentsOfURL:encoding:error is in 10.4 and later.  Do you  
have the proper SDK specified (e.g. 10.4 universal?)




On 6 Dec 2008, at 12:58, Ricky Sharp wrote:

You can probably simplify this a bit by using  
stringWithContentsOfURL:encoding:error.  Note 'encoding' and not  
'usedEncoding'. The former allows you to specify the encoding.  In  
this case, use the constant NSISOLatin1StringEncoding (which is  
ISO_8859-1).


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How To Deal With Rounding Errors

2008-12-04 Thread Ricky Sharp


On Dec 4, 2008, at 6:37 AM, Andrew Farmer wrote:


On 04 Dec 08, at 00:08, Bridger Maxwell wrote:
Short version of my question: I believe I am having rounding errors  
because
I am working with really, really small values. Would it help if I  
multiplied
these values by a scalar (say, 1,000), did math with them, and then  
divided
them by the scalar? I remember learning how IEEE floating point  
numbers are
stored, but I can't remember enough about it to know if this would  
have any
effect on precision. If not, what is a good way to get better  
precision? I

am already using doubles instead of floats.


No; if anything, multiplying by a constant will reduce your  
precision slightly.


If you're having precision issues with doubles, you are probably  
manipulating your intermediate values in such a way as to destroy  
precision (loss of significance). A common culprit is subtracting  
two values of nearly equal value. Without knowing what your math  
looks like, it's hard to guess what might be at fault, but  
rearranging your float math to avoid this sort of thing may improve  
your results.


Goldberg's What Every Computer Scientist Should Know About Floating  
Point is a worthwhile read, and covers this issue (as well as many  
other pitfalls) in great detail:


http://www.engr.pitt.edu/hunsaker/3097/floatingpoint.pdf


One common thing to do when working with very small values (i.e.  
values close to zero), is to order your operations.  For example, if  
you have a set of values that you want to compute a sum, adding them  
in smallest to largest order will often be different than largest to  
smallest.


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Button title irregularities

2008-12-03 Thread Ricky Sharp


On Dec 2, 2008, at 7:15 PM, Randall Meadows wrote:


On Dec 2, 2008, at 5:31 PM, Aki Inoue wrote:


You're using Helveitca 12.0 as your label font.


Actually, it's:

(gdb) po labelFont
ArialMT 12.00 pt. P [] (0x001c0e30) fobj=0x162670a0, spc=3.33

Use [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize: 
[yourButton controlSize]]] instead.


And I'm using that because that's what my client used on their  
iPhone app, and they want the Mac app to have the exact same look  
and feel.


Please don't do this; the iPhone and desktop experience are _way_  
different and what you're doing makes no sense.


I recently had my iPhone app reviewed by some members of Apple's UI  
team at one of the tech talk conferences.  My situation was the  
opposite; moving an app from desktop to iPhone.  In some places, I  
fell into the trap of providing a UI that contained desktop-style  
metaphors.


Also keep in mind that an iPhone OS app is much more simplified in  
terms of functions than for the desktop.


Having said all that, on the iPhone OS, use the defined system  
controls, system fonts, etc.  Then, do the same for the desktop.


However, there are definitely some things you can do to both apps to  
ensure they come from the same tree.  Color schemes are very useful  
here.  For example, for my math app, Each mathematical operation was  
given a color.  These colors are used in various parts of the app.   
Some other purely graphical elements are also shared.


Finally, make sure to read both the Macintosh and iPhone Human  
Interface Guideline documents.


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Text blurred in application

2008-11-29 Thread Ricky Sharp


On Nov 29, 2008, at 10:57 AM, Richard Somers wrote:

I just discovered part of my problem. The pdf image was being scaled  
down slightly even though there was plenty of room for it inside the  
NSButton. The default scaling is Proportionally Down. Change this  
to None and the image now is always sharp, at least for a User  
Interface Resolution of 1.0.


Change the User Interface Resolution to 1.25 or 1.5 and the pdf  
image is ok but not great. This is apparently because A shape is  
scan-converted by painting any pixel whose square region intersects  
the shape, no matter how small the intersection is. according to  
the Scan Conversion Rules in the pdf standard. I think this is why  
it looks less sharp at these resolutions. Note that fonts get  
special treatment and will render more precisely because they are  
hinted.


Anyway, perhaps this is why the final image used for many Apple  
widgets are bitmapped tiff files and not vector pdf. You can tweak  
each and every pixel in a tiff file if you want to. For me I just  
wanted to make single vector image and be done with it.



YMMV, but over 99% of my apps images are all vector-based PDF.  They  
scale beautifully at any scaling factor between 0.5 and 3.0 (to  
include the non-integral ones).


Artwork is anything from very simple to very complex (to include  
vectorized versions of original artwork from Poser).


I created a class to manage drawing of such images.  When drawing, you  
must normalize the destination rect such that it will always fall on  
integral boundaries:


+ (void)makeIntegralRectForScaling_II:(NSRect*)aRect
{
if (scalingFactor_II != 1.0)
{
aRect-origin.x *= scalingFactor_II;
aRect-origin.y *= scalingFactor_II;
aRect-size.width *= scalingFactor_II;
aRect-size.height *= scalingFactor_II;

*aRect = NSIntegralRect (*aRect);

aRect-origin.x /= scalingFactor_II;
aRect-origin.y /= scalingFactor_II;
aRect-size.width /= scalingFactor_II;
aRect-size.height /= scalingFactor_II;
}
}

___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Keystrokes for non-ascii letters

2008-11-29 Thread Ricky Sharp


On Nov 29, 2008, at 10:26 AM, Dave DeLong wrote:

I'm working on a client/server application.  The client sends tiny  
Event objects to the server that can contain an NSString of a  
letter or short sequence of letters (up to about 4).  What I'm  
trying to do is figure out how the server can perform the  
keypress(es) to get that letter (or sequence).


I know that I could use CGEventCreateKeyboardEvent, but that  
requires me to know the precise keycode for the letter.  If I were  
limited to just ASCII 0-127, that wouldn't be so bad.  But I could  
also be getting things like é or £ and so on.  I'd rather not  
hard code in every keystroke combination.  =)


Alternatively, I could try using AppleScript.  But in playing around  
with it, I found that if I do:  Tell app System Events to  
keystroke é, then all it does is type a.  Other tests have shown  
that the keystroke command only accepts basic ASCII characters.   
Of course I could use the using command down to get the non-ascii  
letters, but again, that would require me to hard code in every  
keystroke combination.


My last idea is to put it on the clipboard and paste it in by  
simulating a command-v keystroke.  The only problem with this is  
that command-v doesn't mean paste on all keyboards.


Do any of you have any ideas on how I can type arbitrary UTF8  
characters programmatically?



As part of an automated testing framework, I generate individual  
Unicode keyboard events like this:


- (void)postUnicodeKeyboardEvent_II:(unichar)aUnicodeCharacter
{
unichar theCharacters[1];

theCharacters[0] = aUnicodeCharacter;
	NSString*	theString = [[NSString alloc]  
initWithCharacters:theCharacters length:1];


	int	theWindowNumber = [[applicationController_II contentWindow_II]  
windowNumber];


NSEvent*theKeyboardEvent =
[NSEvent keyEventWithType:NSKeyDown location:NSMakePoint (0, 0)
modifierFlags:0 timestamp:0
windowNumber:theWindowNumber context:nil
characters:theString charactersIgnoringModifiers:nil
isARepeat:NO keyCode:0];

[NSApp postEvent:theKeyboardEvent atStart:NO];
}

In my case, I never needed to set the modifier flags, but you can  
easily pass in whatever you need to above.  And, depending on what  
modifiers you're working with, make sure to properly set the  
charactersIgnoringModifiers: param as well.


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: reading a PDF

2008-11-29 Thread Ricky Sharp


On Nov 29, 2008, at 3:16 PM, Torsten Curdt wrote:


I just assume that the actual content is hidden inside the page's
content stream(s).


Raw content, mostly, sometimes. But the draw commands are what put  
it all

together.

For instance, you might have a paragraph of text where there is one  
draw
command per line, or you might have a paragraph of text where is  
one draw

command per character.


Getting to the individual draw commands for the text/characters would
be a first step ...and maybe even enough for what I am after. Is this
what the CGPDFOperatorTableSetCallback() is for?


For an image that fills the page, you might have one
content stream and one draw command, or you might have multiple  
image slices

with one content stream and one draw command for each slice.


Would a PDF writer really slice the images up?


IOW, what you want is not so simple.


I see.

Well, I probably don't really need the image extraction
Just getting the text draw commands might suffice.



At my day job, we use pdfbox (see www.pdfbox.org) in automated tests.   
It basically grabs raw textual data and spits out two-dimensional  
arrays of strings.


While it's java based, it may shed a light on how text extraction can  
be done.  I do not, however, know if their licensing model will fit  
your needs (i.e. if you base your code on theirs, is that even allowed).


There's some links on their site (http://www.pdfbox.org/ 
references.html) which shows how someone wrote a Cocoa app and used  
the Java bridge to interface with pdfbox.


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: how to set up nextKeyView, full keyboard access etc, for custom subviews set up in code (rather than nib)

2008-11-27 Thread Ricky Sharp


On Nov 26, 2008, at 9:47 PM, Rua Haszard Morris wrote:

I have a dialog that has a few controls as well as a complex custom  
view that itself contains other controls as subviews. The custom  
view (for various good reasons) is instantiated and added as a  
subview in code. A template view and NSView's replaceSubview:with is  
used so the positioning etc can be set in the nib.


To fully support keyboard access, I need to somehow set things up so  
that the user can tab from the nib-instantiated controls to the  
controls within the custom view and then back out again. How can I  
achieve this?


I'll also (presumably) need to set up the nextKeyView-chain for the  
controls within the custom view (composed of a hierarchy of subviews  
with their own subcontrols...), but I think I have an idea of how to  
do this.



While I don't manually set up any UI as you're doing, I found that in  
some cases, I still needed to programatically rewire the key loop.


This was especially so for complex screens involving nested tabless  
tab views.



To manually rewire controls, look into the setNextKeyView: API.

If you then have tab views, you may need to provide an implementation  
of tabView:didSelectTabViewitem: and rewire controls based upon the  
new selected tab.


Also inside of tabView:didSelectTabViewItem:, I had to sometimes reset  
the window's firstResponder.  But, make sure to first ask the view if  
it can be the first responder using canBecomeKeyView.


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Responding to view controller memory warnings (was Re: Outlets / IBOutlet declarations)

2008-11-21 Thread Ricky Sharp


On Nov 21, 2008, at 6:53 PM, mmalcolm crawford wrote:


This leaves us for now with two solutions:
(a) Greg's (override setView:) which is more future-proof but is in  
many respects academically unsatisfying.




- (void)setView:(UIView *)aView;
{
   if (!aView) {
   // set outlets to nil, e.g.
   self.anOutlet = nil;
   }
   // Invoke super's implementation last
   [super setView:aView];
}


Unfortunately, although in principle this is correct, in practice it  
may fall foul of another issue.


Because UIViewController currently implements its dealloc method  
using the setView: accessor method (rather than simply releasing the  
variable directly...), self.anOutlet = nil will be called in dealloc  
as well as in response to a memory warning... This will lead to a  
crash in dealloc.


But, that's only if dealloc releases objects directly and doesn't use  
accessors or use the workaround shown below.


I'm now really curious as to why UIViewController uses an accessor in  
dealloc since that's supposed to be bad practice.  Has a bug been  
filed against that too?


The remedy is to ensure that outlet variables are also set to nil in  
dealloc:


- (void)dealloc {
   // release outlets and set variables to nil
   [anOutlet release], anOutlet = nil;
   [super release];
}



That is indeed a workaround, but one of the reasons I moved towards  
using accessors instead (i.e. I didn't have to think about all the  
edge cases where clearing out the ivar was absolutely necessary; the  
accessor always does the right thing).


Now then, two things...

(1) In my personal code, I'm the only developer and do not integrate  
with any third party code (I only use Apple's SDKs directly).  Having  
said that, I do have full control over my own objects and thus don't  
have any pitfalls in using accessors in inits and/or deallocs.


(2) But, I can see where in the general case, this is becoming quite  
problematic for folks.  After all, it's always dangerous to base your  
code on implementation details such as these.


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread Ricky Sharp


On Nov 19, 2008, at 10:13 AM, Brian Stern wrote:

I think that you're probably right and that it's redundant.   
Needless to say, mmalc's best practice has the outlets being  
released in dealloc.  That's why I had that code there in the first  
place.


FWIW, I don't think that UIViewController is documented as setting  
its view to nil from its dealloc method.  Frankly I don't know why  
it does it. I don't think it needs to.  It could certainly change in  
the future.  In fact another best practice (I think this is from  
mmalc) is to not set properties to nil in dealloc but to simply  
release them.  If this changed the retained outlets would leak.


But if your dealloc is like this...

- (void)dealloc
{
self.thisProp = nil;
self.thatProp = nil;
...
}

then you'll be calling the accessors and the right thing will happen  
(i.e. release if necessary).  This is what I currently do for all dev  
work (iPhone or Mac OS X).  In fact, I use accessors everywhere and  
never do direct ivar access.



I don't feel strongly about this, but not having the release code in  
my dealloc method makes me a little nervous.  I do understand that  
my releaseOutlets method gets called twice when the object is being  
dealloced.


This has been a very interesting read.  I currently do not have any  
special code in place to handle low-memory stuff.




In short, the way I think of it, -setView: _IS_ the one centralized  
place that deals with all view-related pointers, including all  
outlets. And UIViewController calls -setView: at all the necessary  
times (setup, memory warning, dealloc), so you don't have to do  
anything else.


I certainly had never thought of any reason to override this  
accessor before this issue came up.  loadView and viewDidLoad are  
the normal override points for view creation and there are others  
for view appearance and disappearance, as I'm sure you know.  It's  
just that there's no comparable override point for the view being  
unloaded, even though that's a normal part of view controller life  
on iPhone.



From Apple's template code, didReceiveMemoryWarning does have these  
code comments generated:


[super didReceiveMemoryWarning]; // Releases the view if it doesn't  
have a superview

// Release anything that's not essential, such as cached data


So, one should release all outlets that are tied to the view _iff_ it  
doesn't have a superview.  And then of course purge all support  
objects that would not be of any use.


If a view ends up not being loaded due to error warnings, it could be  
loaded at a later point in time.  Assuming there's enough memory at  
that point, your loadView will once again be called.


Personally, if any of my instances do get sent the  
didReceiveMemoryWarning message and there is no superview, I'll just  
purge everything.  I don't yet see any need to have only some objects  
live.


Having said that, I'll probably adopt the following:

- (void)dealloc
{
[self myCleanup];
[super dealloc];
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
if ([self.view superview] == nil)
{
[self myCleanup];
}
else
{
// in some cases, I lazily load objects (dictionarys, views,  
etc.)
// such objects could also be purged here.  If needed again,  
they'll be

// lazily loaded once more.
}
}

- (void)myCleanup
{
self.thisProp = nil;
...
}

___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Outlets / IBOutlet declarations (was Re: Interface Builder Wiring Objects)

2008-11-19 Thread Ricky Sharp


On Nov 19, 2008, at 4:11 PM, j o a r wrote:



On Nov 19, 2008, at 1:57 PM, Jeff Laing wrote:


My understanding (and I'm a noob in this) is that best practices
recommend that you shouldn't start sending additional messages to an
object from inside its dealloc.



That is indeed correct. The official guideline is, AFAIK, to not  
call through your properties in init / dealloc.



I guess I really missed that part of the docs.

In all my desktop code, I always call my setters (non prop based) in  
dealloc:


[self setTitle:nil];
[self setColor:nil];
etc.


Just seemed natural to do self.title = nil, etc as I viewed properties  
as just a 1 to 1 replacement of manually setting stuff up.


Now, when you say call through your properties in init/dealloc, is  
that explicitly for things set up with @property?  Or, has what I've  
been doing all these years with calls to accessors in init/dealloc  
really bad?



In my case, I do have a decent amount of code being shared between  
platforms.  And, such code doesn't yet use properties.  After reading  
this thread, it's very temping to just rid myself of the properties  
and go back to rolling my own accessors as needed (I do have  
Accessorizer, so that task is not hard at all).


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Porting from Windows to Mac

2008-10-30 Thread Ricky Sharp


On Oct 30, 2008, at 12:49 PM, Gary L. Wade wrote:


Check out this article on Apple's web site:

http://developer.apple.com/documentation/Porting/Conceptual/win32porting/win32porting.html 



Essentially, CodeWarrior, for Mac development, should not be  
considered for new development (I have to use it for a legacy  
product, and there's lots of features it lacks, and debugging is  
painful under 10.4 and later, especially for Intel-based Macs).  Use  
Xcode instead; it's free and already available to you on your system  
disks.


PowerPlant, for the most part, was very useful before CarbonEvents  
and Cocoa came to be part of the Mac operating system, but since  
these facilities and many more became available, you'll be better  
off rewriting your code into platform-specific and platform-neutral  
logic, and then move your MFC-based code into the platform-specific  
section, which is where your Mac/Cocoa code will go, and any logic  
that doesn't really care about a particular platform should go into  
the platform-neutral area.



I have to strongly second this approach.  Of the 15 frameworks I've  
authored and/or used over the years, the most successful apps written  
always contained platform-specific UI.


If you attempt to go cross-platform for everything, the app typically  
suffers (since you're now dealing with a least-common-denominator UI  
and many religious wars such a button placements).  Also have found  
that the amount of workarounds and/or bugs in such frameworks are  
often quite high.  So the benefits of the so-called write-once are  
typically lost.


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Problem with NSData to NSString to NSData

2008-10-29 Thread Ricky Sharp


On Oct 29, 2008, at 3:46 PM, Joel Norvell wrote:


Dear Cocoa-dev People,

First, I wanted to thank Aki Inoue and Rob Keniger for pointing out  
the problem with my NSData-NSString-NSData approach.


As an alternative, would it be fruitful to use a Directory Wrapper  
to represent the data as two files; one the metadata and the other  
the pdf?  Then I could work with the metadata file, but just display  
the pdf file.


In the What could go wrong here? department, would my compound  
file end up behaving like a directory (or worse)?



From your original implementation of putting the metadata directly  
into the PDF file, you'll now end up with obviously a proprietary  
file.  i.e. No application that works with PDF will be able to work  
with that file.


By having a separate file, things can become fragile.  However, the  
solution here is to use a package type for a custom document.  Just as  
TextEdit does for the rtfd type.


Your package folder would then contain the original PDF and a  
separate file (or files) for your metadata.


This document type would most likely not be openable in any app that  
opens PDF (unless their open dialogs have the 'allow navigation of  
packages' option set).  But, advanced users could your package via  
Finder and work with the PDF directly if they need to.


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Rotation in CAAnimation layers

2008-10-25 Thread Ricky Sharp


On Oct 25, 2008, at 8:31 AM, DKJ wrote:


I do this with a CAAnimation layer myLayer:

myLayer.shadowOffset = CGSizeMake( 5.0, 5.0 );

and get a shadow on the upper and right edges. But when I rotate the  
layer 180 degrees, the shadow then appears on the lower and left  
edges. Real shadows don't do that.


If the object were circular, I'd just put another stationary layer  
underneath and attach the shadow to it. But with other shapes this  
won't work.


So finally, my question: Is there an easy way of calculating the  
position and appearance of the shadow for non-circular shapes? (By  
easy I mean one that I can just copy from somewhere.) If not I'll  
try to figure it out myself; but I don't want to re-invent the wheel.



It sounds like you want a fixed shadow position regardless of  
rotation.  Note that whenever you apply a rotation (or transformation  
for that matter), shadow offsets are also adjusted accordingly.


Whenever you rotate your layers, you'll need to re-calculate your  
shadow offsets accordingly.


Also, there may exist an API to allow for shadows to be fixed? Not  
sure about that.  Wouldn't be a bad enhancement to file though.


___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Custom button cells for NSMatrix

2008-10-20 Thread Ricky Sharp
This is actually quite difficult. I can send you details later today.  
In my case, I needed accessibility and mimic the Aqua radio buttons in  
terms of all their behaviors.


I ended up subclassing NSMatrix and NSActionCell. I could not get a  
subclass of NSButtonCell in an NSMatrix to work completely.


Sent from my iPhone

On Oct 20, 2008, at 6:19 AM, norio [EMAIL PROTECTED] wrote:


Hi,

I'm trying to make a custom cell object for NSMatrix which behaves  
like radio button, this is, when you press the second cell, the  
second cell is highlighting still.


Would you tell me which method I need to override?

Thank you.

Norio

___

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 [EMAIL PROTECTED]

___

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 [EMAIL PROTECTED]


Re: Custom button cells for NSMatrix

2008-10-20 Thread Ricky Sharp


On Oct 20, 2008, at 6:23 AM, Ricky Sharp wrote:

This is actually quite difficult. I can send you details later  
today. In my case, I needed accessibility and mimic the Aqua radio  
buttons in terms of all their behaviors.


I ended up subclassing NSMatrix and NSActionCell. I could not get a  
subclass of NSButtonCell in an NSMatrix to work completely.



I originally attempted to create a custom radio button control around  
Nov 2004.  You can search the archives for a thread back then titled  
Tracking behavior of cells in NSMatrix.


There seemed to be some special code going on between NSMatrix and  
NSButtonCell that I could not duplicate.  There are probably many  
private methods at work.


Anyhow, my final solution was to do this:

subclass NSMatrix (this will be your radio button group)

In that subclass, I implemented mouseDown: to do the following:

- call convertPoint:fromView: to get the view's point that was clicked
- call getRow:column:forPoint: to see if point clicked any cells
- if it did, call cellAtRow:column: to get the cell instance.

Then it got tricky...

if the matrix didn't yet have a keyCell, I set the key cell to the one  
just clicked


I then fell into a local tracking loop by sending  
trackMouse:inRect:ofView:untilMouseUp: to the cell.


If the mouse was released inside the bounds of the cell being tracked...
- set the state of the original cell to NSOffsate and set the state of  
the tracked cell to NSOnState.


else...
- set the key cell to the original key cell before tracking was started.


Then, in a subclass of NSActionCell, I implemented:

trackMouse:inRect:ofView:untilMouseUp:

I maintained a flag in that class so I could query if the mouse was  
released in its bounds or not (used by the matrix's mouseDown: code  
above).


The subclass of NSActionCell of course handled all custom drawing too  
depending on state.



This implementation (plus more code not shown) gave me:

- custom drawing
- exact Aqua behaviors when dealing with mouse or full keyboard access
- bindings integration (e.g. selectedRadioTag)
- accessibility hooks

___
Ricky A. Sharp mailto:[EMAIL PROTECTED]
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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


  1   2   >