Re: Auto layout in XCode 6.4

2015-08-25 Thread Conrad Shultz

> On Aug 25, 2015, at 4:23 AM, Dave  wrote:
> 
> Hi All,
> 
> I’m trying to get my head around Auto Layout in XXCode, but can’t seem to 
> figure out some basic things.
> 
> I have a sample project with a View made up of two Controls, a Text Field and 
> a Button, like so:
> 
> | [TextView]   [Button] |
> 
> Where | = edge of the View.
> 
> It has the following constraints at the moment:
> 
> 1.Leading Alignment   First Item: Button.Leading
> Relation: Equal   Second Item: TextView.Leading   Constant: 8   Priority: 
> 1000   Multiplier: 1

Is this correct? It seems unusual for the button and text view's leading to be 
related if, as drawn, the button is to the right of the text view. Did you mean 
that the button's leading to be related to the text view's trailing?

> 2.Vertical Space  First Item: Superview.Bottom   
> Relation: Equal   Second Item: Button.BottomConstant: 5   Priority: 
> 1000   Multiplier: 1
> 3.Vertical Space First Item: Button.Top   
> Relation: Equal   Second Item: Superview.Top   Constant: 5   Priority: 
> 1000   Multiplier: 1
> 4.Baseline Alignment First Item: Button.Baseline   Relation: 
> Equal   Second Item: TextView.Baseline  Constant: 0   Priority: 1000   
> Multiplier: 1
> 5.Horizontal SpaceFirst Item: Superview.Trailing   
> Relation: Equal   Second Item: Button.Trailing   Constant: 5   Priority: 
> 1000   Multiplier: 1
> 
> I now, want to move the button so it’s before the text field, like so:
> 
> | [Button]   [TextView] |
> 
> If I just move the button to the left, it doesn’t work, so I’m guessing I 
> need to change the constraints or somehow get XCode to do it for me?

I assume you mean move in Interface Builder. Once you adopt Auto Layout to 
position a view it is invalid to try to set its frame in code.

> 
> When I click on the Button in XCode, I see that it is hooked to the top, 
> bottom and right edge of the superview and the left edge of the TextView.
> 
> How do I change this so that it’s hooked to the top, bottom, and left edge of 
> the superview and the left edge of the TextView?
> 
> Is there a good doc that explains how to use XCode to do this? 

I'm not sure if you are asking about the mechanics of editing constraints in 
Interface Builder or what you specifically need to edit.

Assuming you are talking about the latter, conceptually, think about what 
constraints might conflict with what you are trying to do. Since you are only 
rearranging horizontally, the vertical constraints won't be an issue, which 
leaves you with constraints 1 and 5. Looking at these, you probably will need 
to remove both and create appropriate new constraints after moving the views 
around.

You may want something like a superview-leading-to-button-leading, a 
button-trailing-to-text view-leading, and a text 
view-trailing-to-superview-trailing constraint, but it's hard to be sure 
without a picture.

-Conrad
___

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

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

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

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

Re: removeItemAtPath in 10.7

2015-08-26 Thread Conrad Shultz

> On Aug 26, 2015, at 8:11 AM, sqwarqDev  wrote:
> 
> I built my app in Xcode 6.4 on 10.10.5.
> 
> Runs without issue on Yosemite and Mavericks. However, when I boot into Lion 
> 10.7, I get an “unrecognized selector” error on the “removeItemAtPath” line. 
> Here’s the snippet"
> 
> NSError *err;
>int i;
>for (i=0; i < offendersList.count; i++)
>{
> 
>NSString *thisPath = offendersList[i];
> 
>[[NSFileManager defaultManager] removeItemAtPath:thisPath error:&err];
> 
>if (!err)
>   {
>   //blah blah
> 
> Anybody got any idea why this is objectionable in Lion but not in Mavericks 
> +? The headers indicate removeItemAtPath is good to go from 10.5 onwards.

It’s not immediately obvious to me why you’d get such an error. Could you post 
the actual error and backtrace?

Note, though, that it is incorrect to check for errors in this manner. In 
Cocoa, the value of the error out parameter is not guaranteed in the success 
case. You should test the return value of -removeItemAtPath:error: (or, better 
yet, -removeItemAtURL:error:) and, only if the value is NO, then inspect the 
error.

-Conrad
___

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

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

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

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

Re: Auto Layout and XCode/IB Warnings

2015-08-26 Thread Conrad Shultz

> On Aug 26, 2015, at 10:10 AM, Dave  wrote:
> 
> Hi All,
> 
> I’m getting these warning in a xib file:
> 
> Draw Frame View
> Expected: Height=436
> Actual: Height=48
> 
> Image View
> Expected: y=464
> Actual: y=76
> 
> 
> And a few others of the same nature and I’m at a loss to know what to do in 
> XCode/IB to fix it?
> 
> Any help greatly appreciated.

What this usually means is that the views as displayed do not match what the 
constraints indicate (and which will thus be used at run-time). You can 
frequently resolve these by clicking the yellow arrow on the misplaced view in 
the xib's inspector, then clicking the yellow triangle on the warning, and 
"Update Frame."

-Conrad
___

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

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

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

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

Re: Auto-Layout Again

2015-08-27 Thread Conrad Shultz

> On Aug 27, 2015, at 8:07 AM, Jerry Krinock  wrote:
> 
> In a hurry here, but, I know Auto Layout does not always play well with 
> scroll views.

If you encounter a situation where Auto Layout is not playing well with 
NSScrollView (or, really, any view), please file a bug report at 
https://bugreport.apple.com/ .

Thanks,
Conrad

___

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

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

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

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

Re: NSStackView - Gravity Question

2015-08-28 Thread Conrad Shultz

> On Aug 28, 2015, at 6:18 AM, Dave  wrote:
> 
> I’m looking at:
> 
> https://developer.apple.com/library/mac/documentation/AppKit/Reference/NSStackView_Class/#//apple_ref/occ/clm/NSStackView/stackViewWithViews:
>  
> 
> 
> and wondering if there is any better documentation available for NSStackView? 

NSStackView is also discussed in WWDC videos, such as the 2013 "What's New in 
Cocoa" and "Best Practices for Cocoa Animation" sessions. I encourage you to 
check them out at https://developer.apple.com/videos/ 


Please consider sending feedback about the documentation to Apple using the 
"Feedback" link at the bottom of the page mentioned above.

Thanks,
Conrad
___

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

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

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

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

Re: Subclassing a Subclass of SBApplication

2015-09-03 Thread Conrad Shultz
Note that this is a category, not a class extension.

-Conrad


> On Jun 30, 2015, at 6:19 AM, Jean-Daniel Dupas  wrote:
> 
> Using class extension is probably a safe way to extends such classes.
> 
> @interface SXPhotoshopApplication (MyExtension)
> 
> - (void)myWrapper;
> 
> @end
> 
> 
>> Le 29 juin 2015 à 13:54, Dave > > a écrit :
>> 
>> Hi,
>> 
>> I’m using the Scripting Bridge, and I was wondering if it ok to subclass 
>> SBXXX classes. Basically, I have a header file generated by the “sdp” tool 
>> with definitions as below:
>> 
>> And I’d like to subclass this to add some extra wrapping to hide some of the 
>> nastiness from the rest of the app and provide a tighter integration with 
>> the current app handling. I remember reading somewhere that these classes 
>> shouldn’t be subclassed, but I can’t seem to find it again now.
>> 
>> Thanks a lot
>> Dave
>> 
>> -
>> 
>> @interface SXPhotoshopApplication : SBApplication
>> 
>> - (SBElementArray *) documents;
>> - (SBElementArray *) fonts;
>> - (SBElementArray *) notifiers;
>> 
>> @property (copy, readonly) NSNumber *bestType;  // the best type for the 
>> object's value
>> @property (copy, readonly) NSNumber *defaultType;  // the default type for 
>> the object's value
>> @property (copy) NSDictionary *properties;  // all of this object's 
>> properties returned in a single record
>> @property (copy) SXPhotoshopColorValue *backgroundColor;
>> @property (copy, readonly) NSString *build;  // the build number of Adobe 
>> Photoshop application
>> @property (copy) id colorSettings;  // name of selected color settings' set
>> @property (copy) SXPhotoshopDocument *currentDocument;  // the frontmost 
>> document
>> @property SXPhotoshopE050 displayDialogs;  // controls whether or not 
>> Photoshop displays dialogs
>> @property (copy) SXPhotoshopColorValue *foregroundColor;
>> @property (readonly) double freeMemory;  // the amount of unused memory 
>> available to Adobe Photoshop
>> @property (readonly) BOOL frontmost;  // is Photoshop the frontmost 
>> application?
>> @property (copy, readonly) NSString *locale;  // language locale of 
>> application
>> @property (copy, readonly) NSArray *macintoshFileTypes;  // list of file 
>> image types Photoshop can open
>> @property (copy, readonly) NSString *name;  // the application's name
>> @property BOOL notifiersEnabled;  // enable or disable all notifiers
>> @property (copy, readonly) id preferencesFolder;  // full path to the 
>> preferences folder
>> @property (copy, readonly) NSArray *recentFiles;  // files in the recent 
>> file list
>> @property (copy, readonly) NSString *scriptingBuildDate;  // the build date 
>> of the scripting interface
>> @property (copy, readonly) NSString *scriptingVersion;  // the version of 
>> the Scripting interface
>> @property (copy, readonly) SXPhotoshopSettingsObject *settings;  // 
>> preference settings
>> @property (copy, readonly) NSString *systemInformation;  // system 
>> information of the host application and machine
>> @property (copy, readonly) NSString *version;  // the version of Adobe 
>> Photoshop application
>> @property (copy, readonly) NSArray *windowsFileTypes;  // list of file image 
>> extensions Photoshop can open
>> 
>> - (void) AETEScriptsScriptsJavaScriptNameName:(NSString *)JavaScriptNameName 
>> JavaScriptFileFile:(NSString *)JavaScriptFileFile 
>> JavaScriptTextText:(NSString *)JavaScriptTextText 
>> JavaScriptDebuggingDebugging:(BOOL)JavaScriptDebuggingDebugging 
>> JavaScriptMessageMessage:(NSString *)JavaScriptMessageMessage;  // Photoshop 
>> scripting support plug-in
>> - (void) open:(id)x as:(SXPhotoshopOpAs)as 
>> withOptions:(SXPhotoshopOpenOptions *)withOptions 
>> showingDialogs:(SXPhotoshopE050)showingDialogs 
>> smartObject:(BOOL)smartObject;  // open the specified document file(s)
>> - (void) print:(id)x sourceSpace:(SXPhotoshopE945)sourceSpace 
>> printSpace:(NSString *)printSpace intent:(SXPhotoshopE130)intent 
>> blackpointCompensation:(BOOL)blackpointCompensation;  // print the specified 
>> object(s)
>> - (void) quit;  // quit the application
>> - (NSArray *) PhotoshopOpenDialog;  // use the Photoshop open dialog to 
>> select files
>> - (NSString *) batch:(NSString *)x fromFiles:(NSArray *)fromFiles 
>> from:(NSString *)from withOptions:(SXPhotoshopBatchOptions *)withOptions;  
>> // run the batch automation routine
>> - (NSString *) createPDFPresentationFromFiles:(NSArray *)fromFiles 
>> toFile:(id)toFile withOptions:(SXPhotoshopPresentationOptions *)withOptions; 
>>  // create a PDF presentation file
>> - (NSString *) createContactSheetFromFiles:(NSArray *)fromFiles 
>> withOptions:(SXPhotoshopContactSheetOptions *)withOptions;  // create a 
>> contact sheet from multiple files
>> - (NSString *) createPhotoGalleryFromFolder:(id)fromFolder 
>> toFolder:(id)toFolder withOptions:(SXPhotoshopGalleryOptions *)withOptions;  
>> // Creates a web photo gallery
>> - (NSString *) cre

Re: NSView's in Separate NIB

2015-09-04 Thread Conrad Shultz

> On Sep 4, 2015, at 9:23 AM, Dave  wrote:
> 
> Hi,
> 
> Is it still allowable (taking into consideration Auto Layout) to have a 
> separate NSView subclass with a NIB?
> 

Yes.

Auto Layout should be unrelated to this, though if you are composing your 
separate views together in code then you will likely need to add constraints in 
code (just as you might have to manually set frames in code under manual 
layout).

-Conrad
___

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

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

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

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

Re: NSView's in Separate NIB

2015-09-04 Thread Conrad Shultz

> On Sep 4, 2015, at 10:30 AM, Dave  wrote:
> 
> The reason I ask is that for a while now when you create an NSView subclass 
> it no longer offers you the option to create a separate NIB file. I remember 
> a while back reading something saying that it was frowned upon.
> 

You should be able to create a xib for an empty view, create an class file, and 
set the view's custom class in the xib.

I'm not sure about being frowned upon, but I would consider also creating an 
NSViewController subclass that is responsible for loading your view's nib, 
performing associated logic, and connecting it to the rest of your code.

-Conrad
___

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

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

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

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

Re: iOS 9 or Watch App

2015-09-21 Thread Conrad Shultz

> On Sep 21, 2015, at 6:20 AM, Michael David Crawford  
> wrote:
> 
> however you may only have one version of the command line tools
> installed in /usr/bin and the like.

You might take a look at 
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcode-select.1.html
 


-Conrad
___

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

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

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

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

Re: questions on WebView for Mac apps

2015-09-30 Thread Conrad Shultz
WKWebVew is the preferred API.

If WKWebView is missing API that prevents you from adopting it (on either iOS 
or OS X) please file a bug at https://bugreport.apple.com 
.

-Conrad
___

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

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

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

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

Re: NSView - trouble setting next responder on 10.10 - works okay on 10.9

2015-10-02 Thread Conrad Shultz

> On Sep 30, 2015, at 9:15 AM, Jonathan Mitchell  
> wrote:
> 
> In my app i manage the responder chain on 10.8 and 10.9 to insert the 
> NSViewController into the responder chain.
> The view controllers are inserted just below the NSWindowController so that 
> designated view controllers can respond to actions coming up the chain from 
> any source.
> ie: the NSViewController for any view will NOT be the view’s next responder - 
> it will be higher up in the chain.
> 
> On 10.10 the view controller is automatically assigned to be the view’s next 
> responder.
> I want to override this behaviour to not assign the controller as the view’s 
> next responder. 
> I thought this would be trivial but once the NSView nextResponder has been 
> set to the controller the view seems reluctant to have its next responder 
> changed.
> The next responder remains set to the view controller;

Starting with 10.10, -[NSView setNextResponder:] forwards to the view 
controller, which is what you are seeing.

From the AppKit Release Notes 
:

NSViewController automatically adds itself into the responder chain... When the 
view has a call to setNextResponder: made, the method will be forwarded to the 
view’s view controller. If you currently are already doing your own responder 
chain management, take particular care as the view.nextResponder may already be 
the NSViewController. This can cause an issue for apps that manually set the 
viewController.nextResponder = view.nextResponder, without checking to see if 
the view.nextResponder != viewController...

It sounds like in your case you may want to implement responder methods higher 
up in the chain that, when appropriate, dispatch messages to the view 
controller(s), but this of course will depend on your architecture and what 
exactly you are trying to do.

-Conrad
___

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

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

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

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

Re: questions on WebView for Mac apps

2015-10-02 Thread Conrad Shultz

> On Sep 30, 2015, at 11:59 AM, Jens Alfke  wrote:
> 
> 
>> On Sep 30, 2015, at 10:43 AM, Conrad Shultz > <mailto:conrad_shu...@apple.com>> wrote:
>> 
>> WKWebVew is the preferred API.
>> 
>> If WKWebView is missing API that prevents you from adopting it (on either 
>> iOS or OS X) please file a bug at https://bugreport.apple.com 
>> <https://bugreport.apple.com/>.
> 
> Really? WKWebView has like ¼ the API surface area of WebView. It’s abundantly 
> obvious that it provides significantly less functionality — surely Apple 
> doesn’t need developers to tell it that. I realize that WKWebView is more 
> secure, and it's a step up from UIWebView, but it is in no way a replacement 
> for WebView.

I can’t speak to specific functionality, but I will reiterate that filing bug 
reports explaining your needs is the best way to help us understand them. We 
read your reports and consider them when designing API.

Thanks,
Conrad
___

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

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

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

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

Re: Handling http:// URLs

2015-10-13 Thread Conrad Shultz

> On Oct 13, 2015, at 5:34 PM, Rick Mann  wrote:
> 
>> On Oct 13, 2015, at 17:29 , Stephen J. Butler > > wrote:
>> 
>> I think you're talking about Seamless Linking/Universal Links. Introduced in 
>> iOS 9
>> 
>> https://developer.apple.com/videos/play/wwdc2015-509/ 
>> 
>> 
>> https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html
>>  
>> 
> 
> Yes, that's it, thank you. Sadly, it's not as cool as I had hoped (I really 
> want, as a user, to be able to have multiple choices when tapping certain 
> kinds of URL, but that's for another day). This will address our current 
> needs.

As always, if there are enhancements you’d like to see, please file a bug at 
https://bugreport.apple.com .

That said, could you elaborate on what you mean by "multiple choices when 
tapping certain kinds of URL”? Universal links are based on mutual trust: an 
app and website mutually agree to let one another handle links. You can have 
different apps handle different parts of your website (e.g. a video player to 
handle videos you host and a social app to handle messaging through your site).

-Conrad
___

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

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

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

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

Re: CGContextShowTextAtPoint

2015-10-14 Thread Conrad Shultz

> On Oct 14, 2015, at 11:41 AM, Raglan T. Tiger  wrote:
> 
> 
> 
>> On Oct 14, 2015, at 10:02 AM, Jens Alfke  wrote:
>> 
>> The view is probably using flipped coordinates. Look up flipped coordinates 
>> in the Cocoa view documentation to understand what they are and how to work 
>> around the problem.
>> 
>> As for the size, have you set the size of the NSFont in ‘sysFont’?
>> 
> 
> I am using -graphicsContextWithBitmapImageRep and then adding text 
> annotations.  The reason for using CGContextShowTextAtPoint in the first 
> place was to solve this problem when drawing NSStrings.
> 
> I guess the real question is "How to you draw NSStrings as flipped == YES 
> when the current NSGraphicsContext is graphicsContextWithBitmapImageRep which 
> is flipped = NO.

If I understand your question, I’d expect you could set the graphics context’s 
transform (see the CGContextFooCTM() family of functions), draw your text, then 
reset the transform.

-Conrad
___

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

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

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

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

Re: debugging AutoLayout exception with no build errors

2015-11-05 Thread Conrad Shultz

> On Nov 5, 2015, at 6:50 AM, 2551 <2551p...@gmail.com> wrote:
> 
>> or set a breakpoint on -[NSView(NSConstraintBasedLayout) 
>> engine:willBreakConstraint:dueToMutuallyExclusiveConstraints:].  
> 
> Not sure I’m still following along. Are we talking symbolic breakpoint here? 
> I tried that, but the app just builds and runs fine on 10.11.
> 
> 
>> Either way, select that frame of the stack.  Then, try to examine the third 
>> parameter, which seems like it would be the array of constraints.  
> 
> 
> Ken, this is beyond my ken. Sure, I know what frames and stacks are, but I 
> don’t understand where/how/when I’m supposed to be selecting these frames and 
> stacks in the debugger when no debug session appears in Xcode. Or are you 
> suggesting I export the project to my 10.9 install and run it from Xcode 
> there? In theory I could do that (I think there’s an old Xcode install on 
> that machine), but I’m not sure if the project will build if it was made in 
> 10.11, will it?

You can attach LLDB to a running application (or set it to attach-on-launch) 
and set breakpoints therein without needing to actually build.

-Conrad
___

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

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

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

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

Re: Trigger "Back to..." from code?

2015-11-17 Thread Conrad Shultz
As always, if helpful API is missing, please file a bug at 
https://bugreport.apple.com and explain your use case.

Thanks,
Conrad

> On Nov 16, 2015, at 6:41 PM, Eric Shepherd  wrote:
> 
> Bummer. I was writing a Workflow script to do stuff and just wanted it
> to be able to return me back to where I started when it's done, instead
> of having to do it by hand. I didn't figure there was a way, but it
> would have been helpful.
> 
> Daniel Phillips wrote:
>> No this is all out of your control. 
>> 
>> You'll only see that when landing in an app from another app. 
> 
> -- 
> 
> Eric "Sheppy" Shepherd
> http://www.sheppyware.net/
> http://www.bitstampede.org/
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/conrad_shultz%40apple.com
> 
> This email sent to conrad_shu...@apple.com


___

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

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

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

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

Re: Voiceover support

2015-11-17 Thread Conrad Shultz
One other thing you may find helpful is to test your app using Screen Curtain 
(https://developer.apple.com/library/ios/technotes/TestingAccessibilityOfiOSApps/TestAccessibilityonYourDevicewithVoiceOver/TestAccessibilityonYourDevicewithVoiceOver.html
 
),
 which, with VoiceOver on, you can toggle by triple tapping with three fingers.

Screen Curtain turns off the display. Knowing that your app is fully usable 
with Screen Curtain on can go some way toward knowing it’s accessible.

-Conrad

> On Nov 16, 2015, at 5:46 AM, Daniel Phillips  wrote:
> 
> Hi Alex,
> 
> Thank you very much for your advice and feedback. I've subscribed to the 
> accessibility mailing list now, I didn't even think about that before 
> emailing my original message on here. Sorry for that!
> 
> Andrew, thank you for pointing me to RNIB, I think I may indeed be emailing 
> them for some discussions.

___

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

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

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

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

Re: How to

2015-12-09 Thread Conrad Shultz

> On Dec 6, 2015, at 2:56 PM, Graham Cox  wrote:
> 
> 
>> On 7 Dec 2015, at 2:45 AM, Dave  wrote:
>> 
>> On the Mac what is the best control to use to do this?
> 
> 
> Just override -mouseDown: in the view and call [NSApp 
> sendAction:toTarget:from:]
> 

I’d recommend looking at NSClickGestureRecognizer. You can set its 
target/action directly just like a button and it should be significantly easier 
than working out click timings, etc.

-Conrad
___

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

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

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

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

Re: Any way to intercept the URL-opening mechanism on OS X?

2016-01-02 Thread Conrad Shultz

> On Dec 22, 2015, at 3:51 PM, Rick Mann  wrote:
> 
> You know how you can click links in email, and heck, to open them in Safari 
> (or whatever browser)? Is there any way to write an extension of some sort 
> that can intercept this and re-write the URL? I tried to write a filter in 
> Safari proper for the URL that the user pastes into the address bar, but 
> Safari plug-ins don't have access to that.
> 
> I want to write a thing to strip all the utm_* parameters off the URLs.

Rather than a plug-in, would a Safari extension do what you need? You might 
take look at 
https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html

-Conrad
___

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

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

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

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

Re: Any way to intercept the URL-opening mechanism on OS X?

2016-01-02 Thread Conrad Shultz
You should be able to listen, at the application level, for a beforeNavigate 
event and then effectively modify the URL by canceling the navigation with 
preventDefault() and triggering a new load using your rewritten URL.

See also 
https://developer.apple.com/library/safari/documentation/Extensions/Reference/SafariBeforeNavigateEventClassRef/#//apple_ref/javascript/instp/SafariBeforeNavigateEvent/url

-Conrad


> On Jan 2, 2016, at 3:07 PM, Rick Mann  wrote:
> 
> That was my first attempt, and it provides no way to modify the main url. 
> 
> Sent from my iPhone
> 
> On Jan 2, 2016, at 15:04, Conrad Shultz  <mailto:conrad_shu...@apple.com>> wrote:
> 
>> 
>>> On Dec 22, 2015, at 3:51 PM, Rick Mann >> <mailto:rm...@latencyzero.com>> wrote:
>>> 
>>> You know how you can click links in email, and heck, to open them in Safari 
>>> (or whatever browser)? Is there any way to write an extension of some sort 
>>> that can intercept this and re-write the URL? I tried to write a filter in 
>>> Safari proper for the URL that the user pastes into the address bar, but 
>>> Safari plug-ins don't have access to that.
>>> 
>>> I want to write a thing to strip all the utm_* parameters off the URLs.
>> 
>> Rather than a plug-in, would a Safari extension do what you need? You might 
>> take look at 
>> https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html
>>  
>> <https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html>
>> 
>> -Conrad

___

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

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

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

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

Re: NIB for Cocoa Standard Alert Sheet

2015-04-20 Thread Conrad Shultz

> On Apr 20, 2015, at 11:12 AM, Dave  wrote:
> 
> Hi All,
> 
> Is the Cocoa Standard Alert Sheet available anywhere in a NIB or failing that 
> is there a list of the fields and their Frame Rectangles anywhere?
> 
> I’m sure it’s there somewhere, I’ve been doing google searches but I can’t 
> think of the right thing to search for!

Obligatory question: what are you trying to do?
___

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

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

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

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

Re: EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x00000000bbadbeef crash on UIWebview

2015-06-22 Thread Conrad Shultz
From this backtrace it looks like you might be trying to perform UI operations 
someplace other than on the main queue, which would cause problems. I'd start 
by checking whether you have:

-Any dispatches to a background queue that might need a dispatch_async to the 
main queue.
-Any observer callbacks/notification handlers that might be called on a 
background queue, and which thus might need a dispatch_async to the main queue.

-Conrad


> On Jun 22, 2015, at 1:21 AM, Devarshi Kulshreshtha 
>  wrote:
> 
> For some reasons it is  at this line as reported by crashlytics:
> 
> _webView = [[UIWebView alloc] initWithFrame:CGRectZero];
> 
> Here is the stack-tace of crashed thread:
> 
> Thread : Crashed: com.apple.root.utility-qos
> 
> 0  JavaScriptCore 0x00018413c9e4 WTFCrash + 72
> 
> 1  JavaScriptCore 0x00018413c9dc WTFCrash + 64
> 
> 2  WebCore0x000190992504
> WebRunLoopUnlock(__CFRunLoopObserver*, unsigned long, void*)
> 
> 3  WebCore0x000190992dac WebThreadLock + 104
> 
> 4  UIKit  0x000187449b2c -[UIWebView
> _webViewCommonInitWithWebView:scalesPageToFit:] + 140
> 
> 5  UIKit  0x00018729dc38 -[UIWebView
> initWithFrame:] + 88
> 
> 6  XYZ   0x0001002e0b60
> -[XYContentViewController viewDidLoad] (XYContentViewController.m:43)
> 
> 7  UIKit  0x000187074958 -[UIViewController
> loadViewIfRequired] + 692
> 
> 8  UIKit  0x000187074668 -[UIViewController
> view] + 32
> 
> 9  XYZ   0x000100032620 -[XYModalViewController
> setViewController:] (XYModalViewController.m:252)
> 
> 10 XYZ   0x00010003279c -[XYModalViewController
> pushModalController:] (XYModalViewController.m:260)
> 
> 11 XYZ   0x000100038b14 -[XYViewController
> presentModalController:] (XYViewController.m:426)
> 
> 12 XYZ   0x0001002fc3d4 __57-[AppDelegate
> application:didFinishLaunchingWithOptions:]_block_invoke451
> (AppDelegate.m:590)
> 
> 13 XYZ   0x0001002fc6c0 __57-[AppDelegate
> application:didFinishLaunchingWithOptions:]_block_invoke499
> (AppDelegate.m:619)
> 
> 14 Foundation 0x000183672574 -[__NSObserver _doit:]
> + 320
> 
> 15 CoreFoundation 0x00018280cddc
> __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
> 
> 16 CoreFoundation 0x00018274b370 _CFXNotificationPost +
> 2060
> 
> 17 Foundation 0x00018366f520 -[NSNotificationCenter
> postNotificationName:object:userInfo:] + 72
> 
> 18 XYZ   0x000100312a50
> __44-[XYListingPriceHistoryCell getPriceAlerts:]_block_invoke_2
> (XYListingPriceHistoryCell.m:77)
> 
> 19 libdispatch.dylib  0x000193e75994
> _dispatch_call_block_and_release + 24
> 
> 20 libdispatch.dylib  0x000193e75954
> _dispatch_client_callout + 16
> 
> 21 libdispatch.dylib  0x000193e82780
> _dispatch_root_queue_drain + 1848
> 
> 22 libdispatch.dylib  0x000193e83c4c
> _dispatch_worker_thread3 + 108
> 
> 23 libsystem_pthread.dylib0x00019405522c _pthread_wqthread + 816


___

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

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

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

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

Re: How to enable local storage in WebView using Swift

2015-06-27 Thread Conrad Shultz

> On Jun 3, 2015, at 7:23 AM, Juanjo Conti  wrote:
> 
> Hi, I'm using WebView and I'd like to enable HTML5 local storage.
> 
> I've read some questions on Stack Overflow where the suggestion is to do:
> 
>WebPreferences *prefs = [webView preferences];
>[prefs _setLocalStorageDatabasePath:@"~/Library/Application
> Support/MyApp"];
>[prefs setLocalStorageEnabled:YES];
> 
> but if I try something similar in Swift:
> 
>webView.preferences._setLocalStorageDatabasePath(LocalStoragePath)
>webView.preferences.localStorage = true
> I get a "WebPreferences does not have a member named ..." error.
> 
> How can I do it?
> 
> Thanks in advance,

If you can target Yosemite and newer, you can use WKWebView (instead of 
WebView), and HTML 5 local storage should just work. If it doesn't, or if this 
is insufficient for your needs, please file a bug report!

-Conrad
___

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

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

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

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

Re: Safe time to add accessory view to NSSavePanel in sandboxed app?

2015-07-15 Thread Conrad Shultz

> On Jul 15, 2015, at 3:53 PM, Graham Cox  wrote:
> 
> This works 99% of the time, but sometimes it just crashes. This seems to 
> occur when the app has just been activated after using a different app, and 
> this save panel is requested within a few seconds of the activation, though 
> that’s a bit of a woolly description because the circumstances make it 
> difficult to reproduce reliably.

Do you have a crash log?

-Conrad
___

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

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

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

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

Re: Auto Layout and Resizable NSViews

2015-07-20 Thread Conrad Shultz
Or NSSplitViewController, if you can target 10.10+.

> On Jul 20, 2015, at 1:50 PM, Gary L. Wade  
> wrote:
> 
> Depending on your design, why not just use an NSSplitView to do all that for 
> you?
> --
> Gary L. Wade (Sent from my iPhone)
> http://www.garywade.com/
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/conrad_shultz%40apple.com
> 
> This email sent to conrad_shu...@apple.com


___

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

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

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

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

Re: Tech update avoiding legacy code

2015-08-14 Thread Conrad Shultz
This thread appears to be about OS X, not iOS.

In any event, a great reference that covers many of the technologies under 
discussion is the Objective-C Feature Availability Index, available at 
https://developer.apple.com/library/mac//releasenotes/ObjectiveC/ObjCAvailabilityIndex/index.html
 


-Conrad

> On Aug 14, 2015, at 1:00 PM, Rick Aurbach  wrote:
> 
> I may be missing something here, but I have to disagree with some of the 
> version numbers that are being quoted in this thread.
> 
> I have an app that supports iOS 5.1.x, which was a requirement since that is 
> that last iOS version supported on the original iPad. It was developed using 
> whatever the current SDK was, but with a deployment target of 5.1. And it 
> uses ARC, GCD, and blocks. Not auto-layout.
> 
> My memory isn’t that good about the differences between 5.0 and 5.1, but it 
> is definitely true that 5.1 has a lot more capability in it than has been 
> claimed in this thread.
> 
> Cheers,
> 
> Rick Aurbach
> Aurbach & Associates, Inc.
> 
>> On Aug 14, 2015, at 2:00 PM, cocoa-dev-requ...@lists.apple.com wrote:
>> 
>> Message: 2
>> Date: Fri, 14 Aug 2015 09:42:13 -0700
>> From: Jens Alfke 
>> To: Appa Rao Mulpuri 
>> Cc: "Cocoa-dev@lists.apple.com" 
>> Subject: Re: Tech update avoiding legacy code
>> Message-ID: <6981443e-3e53-4c2c-b264-dfe20c73d...@mooseyard.com>
>> Content-Type: text/plain;charset=windows-1252
>> 
>> 
>>> On Aug 13, 2015, at 11:27 PM, Appa Rao Mulpuri  
>>> wrote:
>>> 
>>> Thanks for the priority order. In GDC Vs ARC, GCD is the first one to opt
>>> unless if you are app has more memory leaks. Correct me If I am wrong.
>> 
>> ARC will simplify your source code, make new code easier to write, and make 
>> memory issues (leaks, crashes due to messaging dealloced objects) less 
>> likely. Once I switched I couldn’t imagine how I worked without it.
>> 
>> GCD is useful if you make heavy use of concurrency in your app and need all 
>> the performance you can get. Not all apps will need it. If you’re using 
>> NSOperationQueue, you’re already taking advantage of GCD on OS’s that 
>> support it.
>> 
>> One thing we both forgot to mention is blocks — I can’t remember, can you 
>> even use blocks in an app targeting 10.5? If not, those would be a huge, 
>> huge reason to drop support. Possibly bigger than ARC. Blocks make the 
>> language so much more flexible, even without GCD.
>> 
>> —Jens

___

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

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

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

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

Re: [Solved] Section header artifacts in popover

2011-08-02 Thread Conrad Shultz
After much exploration I found that the problem was resolved by setting the 
autoresizing mask of the parent tableView to flexible height/width. 

This did not occur to me earlier because, as I mentioned, visually everything 
resized properly. I'm unclear whether this is a framework bug or confusion on 
my part, but I'm happy it's working and just wanted to share the solution. 

(As an aside, another oddity is that I found the problem only presented when 
the _index_ was visible. If I suppressed index display, the _header_ bug 
resolved itself. Strange.)

(Sent from my iPhone.)

--
Conrad Shultz
www.synthetiqsolutions.com

On Jul 30, 2011, at 1:12, Conrad Shultz  wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> Hi all,
> 
> I have been attempting to debug a strange quirk I am getting when I use
> a UISearchDisplayController in conjunction with a UIPopoverController.
> 
> Consider the perfectly normal looking filtered table view seen in a
> popover at http://dl.dropbox.com/u/5847625/popover-with-kb.png
> 
> (Note that, to aid debugging and visualization, I set a red border on
> the searchResultsTableView's CALayer.  This has no effect on the
> behavior I am about to discuss.)
> 
> Now consider the appearance when I hide the keyboard:
> http://dl.dropbox.com/u/5847625/popover-without-kb.png
> 
> As I expected, the searchResultsTableView cleanly animates to fill the
> new popover content size, but somehow a stray section header (clearly
> deriving from the searchContentsController, not shown but which has the
> header present in about the right location) becomes visible
> 
> Since the errant section header overlays the red layer border, remains
> fixed if I scroll the searchResultsTableView, and does not seem to
> respond to touch events itself, it appears it actually sits on TOP of
> the searchResultsTableView (which would appear inconsistent with the
> 
> While most users probably won't hide the keyboard manually, they will
> rotate the device, which is also sufficient to trigger the quirk:
> http://dl.dropbox.com/u/5847625/popover-landscape.png
> 
> I haven't had any luck Googling this, and trying to call
> setNeedsDisplay/setNeedsLayout on either the searchResultsTableView or
> the searchContentsController's table view has no effect.
> 
> Has anyone seen this issue and/or might have an idea of how to prevent it?
> 
> Thanks.
> 
> - -- 
> Conrad Shultz
> 
> Synthetiq Solutions
> www.synthetiqsolutions.com
> -BEGIN PGP SIGNATURE-
> Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAk4zvOsACgkQaOlrz5+0JdUfxwCghjlxU4/boPJekribDWXSGRc6
> 5ckAn34GCUSSGb8bM1P/RhTmoEVQ1uUz
> =o30v
> -END PGP SIGNATURE-
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/conrad%40synthetiqsolutions.com
> 
> This email sent to con...@synthetiqsolutions.com
___

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

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

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

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


Re: Unnecessary Boolean Warning

2011-08-02 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 8/2/11 5:57 PM, Dale Miller wrote:
> Greg Parker wrote: "A warning on '==' inside of 'if' is ridiculous.
> '==' is comparison for equality. "=' is assignment. Anyone who can't
> at least keep these two straight shouldn't be doing programming."
...
> I think Mr Parker was guilty of hubris in his statement, and was
> totally out of line. Pride in being facile with a crummy language
> does not justify denigrating people who have finger-checks or memory
> lapses in dealing with some of C's dumber constructs.

I fear that you misinterpreted his words: he was being facetious,
somewhat satirizing a previous comment along those lines that (as far as
I can tell) was not facetious.

Please take note of the next sentence in Greg's email from which you quoted:

"One programmer's appreciated warning is another programmer's annoying
noise. If you think some warning is noise, turn it off. Please don't
belittle those of us who are not perfect."

Greg, a valuable list contributor from whom I think we all learn a great
deal, is on your side.

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOOJ8waOlrz5+0JdURAmQFAJ9xMAHCPskIIiiO2K2fe7uyneNI+QCgiilr
y+I71h9mZdrneuWxOjZMK4s=
=TR/A
-END PGP SIGNATURE-
___

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

Please do not post 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 Identify if the device is used in iAD supported Regions

2011-08-04 Thread Conrad Shultz
Full disclosure: I don't use iAd, so this is based on WWDC recollection and doc 
lookup. 

The "Test Advertisement" I believe only displays when you are testing during 
development. Users will never see it.

Keep the banner view hidden until you receive a bannerViewDidLoadAd: message in 
the ad delegate. Presumably this just won't get called in regions that don't 
support iAd.

You could setup a timer to load from other ad networks if you don't receive an 
iAd within some predetermined period. 

(Sent from my iPad.)

--
Conrad Shultz
www.synthetiqsolutions.com

On Aug 3, 2011, at 20:46, Sasikumar JP  wrote:

> I am planning to use iAD for my iOS application. As the iAD available
> only in USA,UK,France,Italia,Deutschland,España AppStores.
> 
> I want to display iAD only for supported regions. This will avoid
> displaying "Test Advertisement" from iAD.I can use AdMob for all other
> regions.
> 
> I am not sure, how to identify the iOS Device is used in supported region?
> 
> Any help is highly appreciated.
> 
> Thanks
> 
> Sasikumar JP
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/conrad%40synthetiqsolutions.com
> 
> This email sent to con...@synthetiqsolutions.com
___

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

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

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

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


Re: How to Identify if the device is used in iAD supported Regions

2011-08-04 Thread Conrad Shultz
Wow, if that's really the behavior then I'd say you should definitely file a 
bug.

Not only should users never see debug/test junk, but it would be ridiculous for 
you to have to hard code region support... without an API how would you handle 
addition or removal of a region? You shouldn't have to push out a new app. 

FWIW, given the absence of mention of iAd at WWDC this year and the publicized 
lack of enthusiasm among advertisers (at least in the US), I would not be 
surprised to see iAd revamped or even dropped. But this is purely speculative. 

(Sent from my iPhone.)

--
Conrad Shultz
www.synthetiqsolutions.com

On Aug 4, 2011, at 1:28, Sasikumar JP  wrote:

> Cornad,
>I guess, "Test Advertisement" displays even your region App store
> does not support iAD. I have seen many application in my device
> displays "Test Advertisement", as iAD not supported in my region.
> 
>  I agree with your approach,only if the delegate
> method(bannerViewDidLoadAd:) is not getting invoked for iAD not
> supported regions. But thats not the case, if Appstore supports iAD,
> it Displays real ad. otherwise it will display "Test Ad". Either case
> your delegate method would be invoked.
> 
> Any one can confirm the behaviour of iAD in the not supported region.
> 
> Thanks
> Sasikumar JP
> 
> On Thu, Aug 4, 2011 at 1:33 PM, Conrad Shultz
>  wrote:
>> Full disclosure: I don't use iAd, so this is based on WWDC recollection and 
>> doc lookup.
>> 
>> The "Test Advertisement" I believe only displays when you are testing during 
>> development. Users will never see it.
>> 
>> Keep the banner view hidden until you receive a bannerViewDidLoadAd: message 
>> in the ad delegate. Presumably this just won't get called in regions that 
>> don't support iAd.
>> 
>> You could setup a timer to load from other ad networks if you don't receive 
>> an iAd within some predetermined period.
>> 
>> (Sent from my iPad.)
>> 
>> --
>> Conrad Shultz
>> www.synthetiqsolutions.com
>> 
>> On Aug 3, 2011, at 20:46, Sasikumar JP  wrote:
>> 
>>> I am planning to use iAD for my iOS application. As the iAD available
>>> only in USA,UK,France,Italia,Deutschland,España AppStores.
>>> 
>>> I want to display iAD only for supported regions. This will avoid
>>> displaying "Test Advertisement" from iAD.I can use AdMob for all other
>>> regions.
>>> 
>>> I am not sure, how to identify the iOS Device is used in supported region?
>>> 
>>> Any help is highly appreciated.
>>> 
>>> Thanks
>>> 
>>> Sasikumar JP
>>> ___
>>> 
>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>> 
>>> Please do not post 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/conrad%40synthetiqsolutions.com
>>> 
>>> This email sent to con...@synthetiqsolutions.com
>> 
___

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

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

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

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


Re: Zinnia on iPad

2011-08-07 Thread Conrad Shultz
I believe you posted this to xcode-users yesterday and got several useful 
responses. Can you elaborate on your specific challenges?

(Sent from my iPhone.)

--
Conrad Shultz
www.synthetiqsolutions.com

On Aug 6, 2011, at 13:00, Claudio Ceballos Paz  wrote:

> Hello, friends.
> I'm trying to integrate Zinnia [1]  on my iPad proyect. But I don't know how
> to integrate a C++ library to my Objective-C proyect.
> I've seen some tutorials on genereic integration of C++ and Objective-C++.
> Can anyone help me? I'm quite lost.
> Thanks.
> 
> [1] http://zinnia.sourceforge.net/
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/conrad%40synthetiqsolutions.com
> 
> This email sent to con...@synthetiqsolutions.com
___

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

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

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

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


Re: Decimation - NSBezierPath or something else?

2011-08-08 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 8/8/11 5:16 PM, N!K wrote:
> Does NSBezierPath do decimation as well as interpolation? I didn't 
> find it in the Class Reference. Or is there another class that does 
> it? Or must I do the decimation before plotting the data with 
> NSBezierPath?
> 
> Decimation reduces the original sampling rate for a sequence to a 
> lower rate, the opposite of interpolation. The decimation process 
> filters the input data with a lowpass filter and then resamples the 
> resulting smoothed signal at a lower rate.
> 
> 
> In my application, the math generates  hundreds of points for 
> accuracy, for every one that needs to be plotted to make a decent 
> looking plot. Signal processing theory says that you can't just
> throw away points, or you can generate errors.

Not ringing a bell, but this sounds more along the lines of signal
processing than pure drawing.  (NSBezierPath is for arbitrary drawing,
not plotting per se.)

You might find some useful goodies in the Accelerate framework
(http://developer.apple.com/library/mac/#documentation/Accelerate/Reference/AccelerateFWRef/_index.html),
but I've only just barely started learning about it myself.

> For example, I might generate 25,000 points and be happy to look at
> a 200 point plot. Throwing 25,000 points at NSBezierPath might swamp 
> it, or at least run very slowly.

The obligatory question: is this conjecture or have you found this to be
the case?

I have some code that plots about 7500 points in a scalable, scrollable
NSView using NSBezierPath (without attempting any fancy optimization)
and I see absolutely no delay at all during either the initial render or
subsequent transformations.

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOQIAoaOlrz5+0JdURArwDAJ4vmVoJWVJFDANlgMG1XTwA0uvcjQCfWS/l
lbWVdwHp2SPVO/N+pTvPL6s=
=w8Ez
-END PGP SIGNATURE-
___

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

Please do not post 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: Frameworks (ConnectionKit)

2011-08-09 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 8/9/11 6:15 AM, Amy Gibbs wrote:
> It seemed the easiest way of uploading  a file to the server?

In addition to what others have mentioned, it is worth pointing out that
FTP is a notoriously insecure protocol (or at least lends itself to
security vulnerabilities).

It doesn't support encryption out of the box, so you would have to deal
with the added headache (larger or smaller, depending on implementation)
of tunneling through an encrypted pipe or using a later variant of FTP
that supports encryption but then requires support by both client and
server.

Like most vendors I've seen, Apple implicitly discourages the use of
FTP.  Quoting page 201 of the Snow Leopard Security Configuration guide:

"Avoid using this protocol to share sensitive data. If you must use this
protocol, encrypt your data using a secure encrypted image."

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOQWbHaOlrz5+0JdURAn4RAJ9oHZVCLmqwcv7nNShZggzNGtVDFQCfVF/e
Rny+npzOo8j55OPj6Ql1Q3E=
=UbbC
-END PGP SIGNATURE-
___

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

Please do not post 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: Decimation - NSBezierPath or something else?

2011-08-09 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 8/8/11 5:49 PM, Graham Cox wrote:
> I can tell you that 25,000 points in a bezier path will make for
> slow drawing, though it also depends on your hardware of course.
> 

Lo and behold, when I went from 7500 points (which rendered instantly)
to 25000 the main thread blocked.

I did not expect the drawing would slow so dramatically with a mere 3.3
fold increase in plotted points, so I stand corrected.

I appreciate your drawing my attention to this matter as it is something
I will certainly keep in mind as I work on my application; I will have
to spend some more time benchmarking this and optimizing later on.

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOQWpJaOlrz5+0JdURAv/5AJwIYHgyXJcvHAcA1d7Y+9ZCBJGvmQCgh1OP
WkCsY92OHvgD4y4fNb9lwQs=
=XIor
-END PGP SIGNATURE-
___

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

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


Flipped horizontal NSRulerView?

2011-08-10 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

I have a scroll view containing a view with plotted data (previously
mentioned in my emails regarding plotting with NSBezierPath).

I am considering using NSRulerViews as axis scales.  I was able to
configure the rulers to have the appropriate point-to-unit conversion
factors, etc., but the one obstacle I have encountered is that the
desired scales increment in opposite directions from usual (i.e.
increasing from right to left and top to bottom).

By overriding -isFlipped in an NSRulerView subclass and then calling
- -setOriginOffset: appropriately I was able to get the desired behavior
in the vertical ruler (though it feels like a kludge).

However, this does not seem to have any effect in the horizontal
dimension (which would be consistent with the documentation, which
rather cryptically notes that horizontal rulers always assume a flipped
coordinate system).

Is there a way to achieve a right-to-left horizontal ruler?  Or is this
a sign that I am abusing NSRulerView beyond its intended use and I
should consequently draw my own axis scales?

Googling for terms like "flipped nsrulerview" and "mirrored nsrulerview"
simply led me back to the NSRulerView documentation, for which I think I
have read all the pertinent portions.

Thanks.

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOQ1uuaOlrz5+0JdURAh1fAJ9N69KgF0JxRTpYaPSa6sxjbtum3QCcD/Dh
+FYDd+Enz0KOX6fCbvt6nU0=
=ECfh
-END PGP SIGNATURE-
___

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

Please do not post 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: Flipped horizontal NSRulerView?

2011-08-10 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 8/10/11 9:54 PM, Quincey Morris wrote:
> Did you try using negative scale factors in the custom ruler scale 
> definition? If the rulers accept that, then you might also have to 
> change the sign on your data values too, for drawing purposes.

Yeah, that was actually the first thing I tried, but it unfortunately
triggers an "invalid parameter" (don't recall exact wording) error.

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOQ2V1aOlrz5+0JdURAmjIAJ4rQ+JFCjm1HUomB0kKzF+x2Ve8uACfXON+
aeC9GxxXcfjX3qI6+wbQMtE=
=FWyc
-END PGP SIGNATURE-
___

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

Please do not post 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: Flipped horizontal NSRulerView?

2011-08-11 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 8/10/11 9:47 PM, Graham Cox wrote:
> Yes, I think so - subclass & override -drawHashMarksAndLabelsInRect.
> I think the comment that the horizontal ruler already assumes a
> flipped coordinate system refers to the fact that it draws text,
> which likes flipped coordinates, and also maybe makes it easier to
> lay out.

Thanks for the response.

Unless I'm missing something big, overriding this method is rather
non-trivial.  There doesn't seem to be any way to get at the positions
that NSRulerView internally calculates normally, so I will have to do
all my own math, including sorting out the stepUp/stepDown stuff that
you usually get for free.

This is fine (even if it's not how I would prefer to be spending time),
but it makes me wonder what benefit I will really get then from using
NSRulerView.  Since I don't anticipate using markers or event handling
on the axis scales, I wonder whether it might make more sense to scrap
NSRulerView entirely and just do the axis drawing in the scroll view's
documentView's drawRect: (which is already being used to plot the actual
data).

Thoughts?  This is the first time I've dealt with NSRulerView so I don't
know if there are other hidden benefits that I would forgo.


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk5DklwACgkQaOlrz5+0JdWUIACfdVFTNflb6goKIxS7YBe0Fpsb
FnkAniJXwbEyFPD+kF8H6JTH1hb79FNr
=xVTb
-END PGP SIGNATURE-
___

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

Please do not post 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 prevent drag-and-drop initiation in an NSTextField

2011-08-16 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 8/16/11 11:26 AM, Michael Crawford wrote:
> Thanks for responding, Kyle.
> 
> I assume you meant NSTextField not NSTextView? I'm working on touch 
> based museum exhibits, which run on Mac mini's.  Suffice it to say I 
> don't want to allow the movement of text.

If that's your goal, why don't you just setEditable:NO ?


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOSrrmaOlrz5+0JdURArfFAJwN6E4pVMGdSe3OUO7xyXMzPfkqNACdHXTU
WnjZeuVCuOLHcRI41A4ocCY=
=o/yn
-END PGP SIGNATURE-
___

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

Please do not post 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 prevent drag-and-drop initiation in an NSTextField

2011-08-16 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 8/16/11 12:15 PM, Michael Crawford wrote:
> If that's your goal, why don't you just setEditable:NO ?
> 
> I tried that.  The only problem is that then I cannot display the 
> keys the user taps as they happen.  I'm injecting keyboard events
> and the textfield is the responder.  I could bypass the keyboard
> input altogether and just have the keyboard buttons add the
> appropriate character to a string which is then written to the
> textfield but we have other reasons for wanting this to response as
> if a real keyboard was plugged in.
> 
> Please don't focus on the constraints I just described.

OK, I will refrain from further comment on this constraint.

> Does anyone know of a way to prevent drag and drop from an 
> NSTextField?  This is all I'm trying to accomplish.

Since blocking drag and drop likely will require a subclass along the
lines you described, it is probably still worth some effort to determine
whether your goal can be differently accomplished.

If I understand correctly, you need the field to be editable because it
is the first responder and you need it to handle key input, whether from
a physical keyboard or from events injected into the event stream.  Is
that a correct interpretation?

If so, I would ask why you don't simply handle these events higher up -
say, in a container view or the corresponding NSWindow or
NSWindowController?  These objects could (maybe even already do) have
references to the text field (which could just be treated as a label
now) and could implement -keyDown: and the like, dispatching updates to
the text field when required.

The upshot is that by handling the events higher in the responder chain:

1) You still get to handle keyboard input just as you desire.

2) Since you are likely already implementing a subclass for one of these
responder objects you can avoid unnecessary further subclassing.

3) You will have a much less fragile architecture when the you or the
designers inevitably decide that the string needs to also be displayed
elsewhere on the screen, etc.

Would this work?  Please correct me if I do not understand your
objectives properly.


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD4DBQFOSsowaOlrz5+0JdURAgy6AJY3t+ObRV8Xx6k0KYKapUUPW6MaAJ0cCCfF
Lhpv/odeJKLKxTYVILa2WQ==
=fMCI
-END PGP SIGNATURE-
___

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

Please do not post 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: Options to defaults or commandline

2011-08-16 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 8/16/11 12:46 PM, Abdul Sowayan wrote:
> My question is regarding options such as ApplePersistenceIgnoreState.
> Where did this come from? Is there some documentation that lists
> similar options I can use?
> 
> The above was helpful for me to disable Lion¹s Resume feature. I
> would also like to disable Lion¹s resize the Window from all edges. I
> couldn¹t find any documentation that list such options.

I do not know of any unified list of these, but this option is
documented in the most recent AppKit release notes
(http://developer.apple.com/library/mac/#releasenotes/Cocoa/AppKit)
along with a bunch of others.

It should be noted that, as Lion-optimized apps become more widely
available and the user base upgrades to Lion (*), features like
restoration will likely become expected to the point where people will
see non-implementing applications as "broken."

Apple seems to have anticipated this with the following release note
regarding the option in question:

"This user default is intended for automated tests that want to start
with a clean environment, and for debugging."

So tread carefully...


*: I'm not one to talk here - I haven't yet done so.


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOSs4UaOlrz5+0JdURAvjWAJ9/jPj8cujUANIg6KFYGZLSEj59/QCfeOxm
h6HIV4qv1712rnIIC+yRYqM=
=EOUy
-END PGP SIGNATURE-
___

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

Please do not post 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: Problems with UIAlertView

2011-08-16 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 8/16/11 4:09 PM, Laurent Daudelin wrote:
> I'm looking at popovers. I'm wondering if there is any way that I'm 
> overlooking to make popovers modal. So far, in all the samples I 
> looked at, if you just tap outside the popover, it will dismiss. I 
> read about the passthroughViews property. If I set that property to 
> nil, will this prevent the popover from being dismissed?

Returning NO from the -popoverControllerShouldDismissPopover: delegate
method should do the trick.

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOSvpOaOlrz5+0JdURAhX9AJ4qRCGKxzconNDXDNZwfCYHlegKygCfUt7N
3m8UcyVr32valMkQYta0EsY=
=/JWR
-END PGP SIGNATURE-
___

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

Please do not post 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 prevent drag-and-drop initiation in an NSTextField

2011-08-17 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 8/17/11 3:11 PM, Michael Crawford wrote:
> For those who are interested, here is a simple answer to my
> original question.
> 
> @implementation NSTextView (csstest)
> 
> -
> (NSDraggingSession*)beginDraggingSessionWithItems:(NSArray*)items 
> event:(NSEvent*)event source:(id)source { return
> nil; }
> 
> That's it.

Please don't do that.

It is usually bad practice to override(*) a method in a category.  It
is highly fragile, particularly because you don't know (and shouldn't
care) how the frameworks are implemented internally.

Furthermore, wherever the category gets picked up, you are overriding
that method.  So when you have some other NSTextView (or subclass
thereof) that you DO want to support dragging, it will (inexplicably)
not work.

Finally, I will note that the particular method you chose is 10.7+
only, so this presumably won't work at all on Snow Leopard and
earlier.  I recall that you said this is for an internal project, so
maybe that's OK, but personally I wouldn't jump on a Lion-only
approach this early on for something which has very good and more
broadly compatible alternate solutions.

I would STRONGLY encourage you to reconsider your approach and perhaps
try what I previously suggested vis-a-vis the responder chain.  Though
I obviously can't see what you are doing in its entirety, I get the
impression that you are painting yourself into an uncomfortably small
corner by - wait for it - "fighting the framework."

*: To be very clear here, I am talking about OVERRIDING a method, not
the intended use of categories which is to ADD a method.


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOTED0aOlrz5+0JdURAo0TAJsE3geERkN0qttbpy5gEai/Q+xgMgCdEEv3
Zss2o6N/tquQp9jNJmVhpsg=
=cteS
-END PGP SIGNATURE-
___

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

Please do not post 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 prevent drag-and-drop initiation in an NSTextField

2011-08-17 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 8/17/11 6:04 PM, Michael Crawford wrote:
> Conrad, thank you for your concern.  I know you want me and others 
> reading this thread to follow practices that are safe and lead to 
> robust resilient software.
> 
> I only wanted to post for completeness.  What I was looking for was
> a specific answer to a technical question.   Since no-one had the 
> answer, I posted it.  The answer was the API call not the category 
> override, in which it was implemented, FOR TESTING.

Fair enough; it wasn't obvious to me that the category was purely for
testing purposes and I wanted to make sure that others understood when
and when not to use a category to solve a problem.

I'm glad you found a solution that fits your needs and that will keep
the clients happy.

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOTGlPaOlrz5+0JdURAqtCAJ9Via+kfWLp/5s5hHPLPUyV1906SACeKm4O
z4JaIcNT5wWVZIvEtqh7KFM=
=mAWT
-END PGP SIGNATURE-
___

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

Please do not post 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: Large over 100K pixel high ruler scroll view

2011-08-23 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 8/23/11 4:19 PM, Julie Porter wrote:
> This is what I am having issue with.How and where to put the 
> delegates?  Specifically what file would I place them into?  Or do
> I create a new file for the delegate that does this?

Sorry to jump in a little late into this conversation, but have you
read the Scroll View Programming Guide
(http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/NSScrollViewGuide/Articles/Introduction.html),
in particular the section titled "Creating and Configuring a Scroll View?"

I ask because it seems like you have some basic misunderstandings
about how NSScrollView works.  (This is not surprising - it's a very
complex piece of machinery that I spent several evenings agonizing
over before coming to something of truce with the framework.)

For example, you don't use a delegate to set the content size or
document size (which are two distinct and very confusingly named
attributes).  You typically set them by setting the associated views
themselves.

> I am not familiar with what a scrubbing interface would be.  Can
> you suggest some examples.

See any non-linear video or audio editor.  If you don't want to deal
with setting up an import into iMovie, take a look at about a minute
in or so of http://www.youtube.com/watch?v=Z9Jt9d5ZFZY (I just found
this via Google, so I can't vouch for purported instruction itself).

> My understanding once I get the view set up drawRect will give me
> a rectangle, where the bottom of the rectangle would be the line to
> start drawing.  The top of the rectangle would be the limit to stop
> drawing at.   The rectangle would be in my coordinate space and
> scaled appropriately.

You are right about the coordinate space, but remember that
NSScrollView does not handle zooming (scaling?) - that is up to you.
(Note that UIScrollView, the analogous iOS class, DOES have some
facilities to assist with zooming.  It is very important therefore
that you keep clear which one you mean when you say "scroll view" -
there IS a UIScrollViewDelegate protocol, for example, but no
NSScrollViewDelegate.)

The way you probably want to think about drawRect: is that the rect
passed in is the dirty rect, that is, it is the region you MUST draw
because it is coming on screen or getting updated.  You CAN draw
outside, but this is a waste of processor cycles.  If you are doing
small amounts of simple drawing it is often easier to just redraw
everything (ignoring the passed in rect), but in your case, with a
huge document view, you will definitely want to only draw in the
requested rect.

In practice, what will happen (as I understand it) is that when the
scroll view first draws you will get a drawRect: call for the
- -documentVisibleRect.  If you scroll, you will then only get a
drawRect: requesting the narrow strip that scrolled onto screen;
NSScrollView (or, rather, the NSClipView therein) will copy and
translate as much of the drawn content as possible and then ask for
only the remainder.

> Simply that there are too many choices to choose from.  Ironic in
> that I am a postscript programmer, a language that is the
> definition of obfuscation.   Perhaps I am thinking backwards here?
> 
> Do I use delegates or bindings?  There are some setup wizards, but
> when one runs them,  there are no code parameters to change.  It is
> like I have to read the mind of the application engineer that
> defined the class. But I digress ..

I don't see how bindings come into this.  I'm also unclear by what you
mean by "setup wizards" - are you referring to Xcode templates, or...?

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOVD4YaOlrz5+0JdURAnxqAJ9QTv5083D/m7zXGg5d/6HDq8e/xQCfYaeI
1ODVesMeKRLOewalBMsiZZE=
=2n8Z
-END PGP SIGNATURE-
___

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

Please do not post 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: Confused with block completionHandler

2011-08-24 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 8/24/11 5:46 PM, Brad Stone wrote:
> This is the method definition - (void)saveToURL:(NSURL *)url 
> ofType:(NSString *)typeName 
> forSaveOperation:(NSSaveOperationType)saveOperation 
> completionHandler:(void (^)(NSError *errorOrNil))completionHandler

This indicates it is expecting a block with no return value and
accepting one argument, a pointer to an NSError.

So you would pass in something like:

^(NSError *error) { // Do something with error if present }

as the completionHandler.

> I've used blocks before like below but I don't understand the
> syntax above and I couldn't find an example on the internet or the
> documentation.  Any help would be appreciated. [openPanel
> beginSheetModalForWindow:[NSApp keyWindow]
> completionHandler:^(NSInteger theResult) { if (theResult) { // some
> code here }

This is very similar to the above.

I recommend
http://developer.apple.com/library/ios/#featuredarticles/Short_Practical_Guide_Blocks/_index.html.

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOVZ43aOlrz5+0JdURAl7eAJ4t2zkF12CQxjgTLiYPmMyDesJGEgCfT7zS
0uiVWwR5cNFVYwNvjyLVlAg=
=Kj0v
-END PGP SIGNATURE-
___

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

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


NSTabView Sizing Question

2011-08-26 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi all,

I'm attempting a seemingly trivial task that is proving sufficiently
cumbersome that I wonder whether I am missing some shortcut.  ("Easy
things should be easy, hard things should be possible," right?)  Given
that I am a relative newcomer to AppKit this is not at all improbable.

I have an NSTabView in a window and want to size it (and,
subsequently, the window) to fully display the current tab view item's
content view (i.e. [tabViewItem view]).

What I am currently doing, more or less, is:

1) Calculate the proper enclosing rect for the content view's
subviews.  Easy enough, but have to do manually since -sizeToFit is
declared on NSControl, not NSView.

2) Set the content view's frame appropriately.

3) Resize the NSTabView to match.  Here is where it gets tricky: as
far as I can tell there is no method along the lines of
"setFrameForContentRect" for NSTabView.  So I end up getting the old
frame and old contentRect, storing the origin, calculating the offsets
and insets for the contentRect vis-a-vis the frame, calculating a new
frame using the old origin, the derived offsets and insets, and the
previously calculated content view frame, and finally setting the new
frame.

4) Resize the NSWindow, here taking advantage of
- -frameRectForContentRect to simplify calculations.

This sequence, particularly step #3, seems rather more complicated
than I would have expected for something that I've got to believe is a
fairly common problem.  (What I want in the end is a tab view whose
sizing behavior acts like the System Preferences application.)

Am I missing something?  Google only turns up a recent Stack Overflow
question along related lines but with no suggested solution, as well
as a rather vague sentence on cocoadev.com: "Of course, resizing the
window would be helpful and if you really want to, make the tabview
switch to a blank tab as the window is resizing to get the Sys Prefs
effect."  A search for NSTabView on the devforums reveals only six
(unrelated) threads.

Thanks!


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOV9smaOlrz5+0JdURAreKAJ9wLm053xnx/S5+Kkw7Y9OrS7ESEQCeKiD5
MKCKaoZmuT9xSDsQAs/n07k=
=1K15
-END PGP SIGNATURE-
___

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

Please do not post 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: NSTabView Sizing Question

2011-08-26 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 8/26/11 11:08 AM, Jens Alfke wrote:
> What I would do is, once you know the content view size you want, 
> compute the difference between that size and the content’s current
> size, then grow the window by that amount.
> 
> The assumption is that that every pixel you grow the window also
> grows the content view by a pixel; this is usually true in the kind
> of window you’re describing, but if it isn’t, you might have to
> temporarily change some of the view autoresize masks while you do
> this.

That makes so much more sense than what I had been doing... I even had
the autoresizing masks set properly, but couldn't see the forest for
the trees.

Thanks for the helpful suggestion.  I'll give it a shot, seems like it
should work.


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOV+IAaOlrz5+0JdURAiW4AJ9roj4dxLUgVCug515Za8gQIXPqrgCfYtdh
gM+mlkeXL0cT5RDIbj+u2aU=
=Dmn2
-END PGP SIGNATURE-
___

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

Please do not post 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: UIBarButtonItem exclusive touch

2011-08-29 Thread Conrad Shultz
Sorry, I don't have time right now to fully respond, but first thing's first: 
UIKit is generally not thread-safe, so you should not invoke user interface 
actions (like popping a nav controller) on a secondary thread. 

This is a situation where GCD can make your life a lot simpler (with nested 
dispatch_async() calls)...

(Sent from my iPhone.)

--
Conrad Shultz
www.synthetiqsolutions.com

On Aug 29, 2011, at 19:34, Leon Qiao  wrote:

> Dear all,
> 
> The UI I made is like the system app "Contact", there's an "add" bar button
> on the navigation bar. And a table view where you can tap and enter the
> detail view. The problem is when the user tap the bar button item and the
> table view cell at the same time, it doesn't work well.
> 
> The code here:
> 
> Action for right bar button item:
> - (IBAction)saveAction: (id)sender;
> {
> ...
> ...
>  [NSThread detachNewThreadSelector:@selector(saveTheData) toTarget:self
> withObject:nil];
> }
> 
> - (void)saveTheData
> {
> //some save action...
> [self.navigationController popToRootViewControllerAnimated: YES];
> //when complete, pop to the root
> }
> 
> Action for table view's delegate method
> 
> - (void)tableView:(UITableView *)tableView
> didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
> DetailViewController *controller = [[DetailViewController alloc]init];
> [self.navigationController pushViewController: controller animated:
> YES];
> [controller release];
> }
> 
> When using UIButton, we can set the exclusive touch property to avoid
> tapping the two buttons at the same time. But what should I do for the table
> view and the bar button item.
> 
> Thanks a lot!
> 
> Best regards
> Leon
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/conrad%40synthetiqsolutions.com
> 
> This email sent to con...@synthetiqsolutions.com
___

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

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

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

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


Re: UIBarButtonItem exclusive touch

2011-08-30 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 8/29/11 11:51 PM, Leon Qiao wrote:
> Hi,
> 
> Thanks for your response ! I missed something.In the thread method
> "saveTheData", I do call the popToRootViewController on the main
> thread by using "performSelectorOnMainThread:".

OK; that's an important detail to note.

While this is then technically acceptable, it still seems like a
strange design.  What it sounds like it will do is perform a save in
the background then, when finished, pop the nav controller.  Is this
what you really want?  Presumably you are multithreading the save
operation since it could potentially take a while and you don't want
to block user interaction (*good*).  But then you are going to
abruptly pop the nav controller, potentially in the middle of whatever
else the user might have been doing (*bad*).

(I'm also a little unclear as to why an "add" button has a "save"
action; I'm assuming you meant "add" as an analogy to the contacts app
as stated, with your actual button being a "save" button in the same
location.)

So here's my question: do you actually want the save action to prevent
the user from continuing display/edit?  If so, throw up some sort of
modal view with, say, a UIProgressView, so the user knows a save is
happening but keep the save on a background thread (if for no other
reason than to prevent the watchdog from killing your app).  If not,
keep the save on the background thread but lose the navigation
controller action, letting it quietly complete (but display a message
if the save fails).

> It seems that both of the two functions(saveAction: and
> tableView's delegate method) are invoked. And the navigation
> controller first pop all view controllers to the root. And then
> push the detail view controller, and sometimes it push to the
> detail view and then pop to the root. So is there any tips about
> the synchronization?

And now to your original question, which probably still applies
regardless of how you handle the above issue... please see my comments
below.

> On Aug 29, 2011, at 19:34, Leon Qiao  <mailto:leon.qiao@gmail.com>> wrote:
> 
>> When using UIButton, we can set the exclusive touch property to
>> avoid tapping the two buttons at the same time. But what should I
>> do for
> the table
>> view and the bar button item.

Well, the exclusiveTouch property is defined for UIView, so
UITableView (and its components) can be set to have exclusive touches.

I had forgotten that UIBarButtonItem does not inherit from UIView, so
that is an interesting little puzzle.  I notice that in the contacts
app the behavior seems deterministic, so there is something going on
to handle synchronization.

My first wild guess as to how you might do this without exclusive
touches is to have the "lower priority" action (i.e. whichever you
would not want performed if there were a conflict) use a delayed
perform (you probably only need delay 0 to kick it into the next run
loop iteration) and have the "higher priority" action start by
canceling any previous delayed performs.  There may be a more elegant
solution, but this is the usual approach for situations such as
distinguishing between single- and double-taps (at least in the days
before gesture recognizers, which presumably are using this mechanism
under the hood).

Since you are familiar with performSelectorOnMainThread: I'm going to
guess you have also encountered delayed performs before, but if not
you will want to take a look at NSObject's

– performSelector:withObject:afterDelay:

and

+ cancelPreviousPerformRequestsWithTarget:selector:object:


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOXT4naOlrz5+0JdURAqOnAJ9pzz/Pce9C3yGIKoMHVh8bHbmibACcCYeD
wpNq+ubIp7Xcct0eUZyYeu0=
=cjgQ
-END PGP SIGNATURE-
___

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

Please do not post 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: Size of a file on disk

2011-08-31 Thread Conrad Shultz
NSFileManager's attributesOfItemAtPath:error:

(Sent from my iPhone.)

--
Conrad Shultz
www.synthetiqsolutions.com

On Aug 31, 2011, at 12:51, Jon Sigman  wrote:

> How does one determine the size of a file on disk using Cocoa? 
> I've looked at NSFileManager but it doesn't seem to offer any 
> methods for finding file attributes. 
> OSX 10.6.8
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/conrad%40synthetiqsolutions.com
> 
> This email sent to con...@synthetiqsolutions.com
___

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

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

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

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


Re: Linking an NSWindow in IB

2011-08-31 Thread Conrad Shultz
Sorry I'm on my phone so I can't write a detailed response, but you're just 
structuring your app kind of backwards. 

In IB you would want to have a connection between your custom window and an 
outlet in your app delegate in this case. You would then send the window an 
"order front" message from the app delegate. 

Putting an outlet to your window _inside the window_ is counterproductive. (I 
assume also that you meant for MyWindow to be a subclass of NSWindow, not 
NSObject.)

(Sent from my iPhone.)

--
Conrad Shultz

On Aug 31, 2011, at 19:54, Guy Halford-Thompson  wrote:

> Hi,
> 
> Thanks for the help, I really appreciate it.
> 
> I still appear to be having some trouble tho.
> 
> Here is my code:
> 
> MyWindow.h
> 
> #import 
> 
> @interface MyWindow : NSObject  {
> 
>   IBOutlet NSWindow *window;
> }
> 
> -(void)showWindow:(id)sender;
> 
> @property (assign) IBOutlet NSWindow *window;
> 
> @end
> 
> MyWindow.m
> ---
> 
> #import "MyWindow.h"
> 
> @implementation MyWindow
> 
> @synthesize window;
> 
> -(void)showWindow:(id)sender {
>   NSLog(@"**Window %@",window);
>   [window makeKeyAndOrderFront:nil];
> }
> 
> @end
> 
> 
> Then... in my main app delegate
> 
> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
> 
> if {...condition is met} {
>MyWindow *uni = [[MyWindow alloc] init];
>[uni showWindow:nil];
>  }
> }
> 
> But its still not working...
> 
> Sorry if this is pretty basic, but getting my head round objective C
> is proving to be difficult.
> 
> Thanks
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/conrad%40synthetiqsolutions.com
> 
> This email sent to con...@synthetiqsolutions.com
___

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

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

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

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


Re: test on device using company registration

2011-09-07 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/7/11 2:37 PM, Wilker wrote:
> Hi guys,
> 
> Today my company create a company account for iOS in order to test
> our product on device. They add me as an company developer using
> iTunes Connect.
> 
> But I can't find how I create an certificate to me in order so I
> can test the product on device.
> 
> I searched on internet but found nothing about it...
> 
> How can I make this to test on device?

This is not a Cocoa question.

That said, login to the Provisioning Portal
(http://developer.apple.com/ios/manage/overview/index.action) and
follow the instructions in the How-Tos.

If you cannot access the Provisioning Portal then your company has not
setup your account with the proper credentials.

Portions of the iOS Development Guide (e.g.
http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/iphone_development/128-Managing_Devices_and_Digital_Identities/devices_and_identities.html)
may be helpful as well.

You should be able to get more information from the dev forums or,
maybe, the Xcode-users mailing list (though this is pretty far afield
there as well).


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOZ+ZjaOlrz5+0JdURAip0AJ9KKxO9mQUOZID//Ivkzk1kwWd/EwCggkCl
RX5YOOEqNV8xt0jpP9oOm8Q=
=rKmq
-END PGP SIGNATURE-
___

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

Please do not post 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: NSScanner to find multiple occurrences of a prefix?

2011-09-12 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/12/11 7:01 AM, Devraj Mukherjee wrote:
> Hi all,
> 
> I am trying to use NSScanner to change camel cased strings into 
> underscore delimited strings, e.g featuredListingId to 
> featured_listing_id

In addition to the responses you have already received, if you are
using a sufficiently new SDK you can use regexes to accomplish your goal:



NSString *input = @"featuredListingId";

NSError *error = nil;

NSRegularExpression *regex = [NSRegularExpression
regularExpressionWithPattern:@"([a-z])([A-Z])" options:0 error:&error];

NSString *result = [[regex stringByReplacingMatchesInString:input
options:0 range:NSMakeRange(0, [input length]) withTemplate:@"$1_$2"]
lowercaseString];



(Clearly you would need to handle errors, etc., as appropriate for
your situation.)

Regular expressions typically run slowly in relative terms, so if you
are doing a lot of these conversions you would probably want to
profile performance too.


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFObpg5aOlrz5+0JdURAnrBAJ9kH0BeBVAbp9xKLVQE1RAgR1xMkwCeOwSC
SRZfXZa4Hp28J71FtdcK7TU=
=qLaC
-END PGP SIGNATURE-
___

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

Please do not post 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: Responder-Chain question.

2011-09-13 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/13/11 5:01 AM, Motti Shneor wrote:
> Hello everyone.
> 
> I need to insert some controllers I have into the responder chain,
> in such a place that their functionality (IBActions and menu
> validation) will be available regardless of specific view focus,
> etc.
> 
> Event Programming guide says:
> 
> "You should never send setNextResponder: to an NSView object. You
> can safely add responders to the top end of a window’s responder 
> chain—the NSWindow object itself if it has no delegate or, if it
> has a delegate, after the delegate.

I remember reading this and being somewhat confused by it.  For my
purposes I have chosen to set this guidance aside as needed.

In particular, I opted to insert NSViewController into the responder
chain in a manner akin to how UIViewController behaves on iOS,
allowing me to implement the "C" part of MVC much more cleanly.

Matt Gallagher has a nice blog post on the topic, the best solution
(unfortunately) being to create a custom NSView subclass and override
the responder chain methods:
http://cocoawithlove.com/2008/07/better-integration-for-nsviewcontroller.html

> However --- the window delegate isn't an NSResponder to start
> with, and is only being delegated responder methods from the window
> --- it is never in the responder chain per se. (same goes for the
> App delegate).
> 
> I have two questions: 1. Is it a typo, and the doc really means 
> "windowController" instead of "delegate" ?? this makes much more 
> sense.

No.  Presumably to minimize such a potential source of confusion,
Apple explicitly puts "(which need not inherit from NSResponder)"
after references to delegates.

I haven't messed with the responder chain surrounding the delegates,
but the impression I get (and perhaps what might be the only option
from an implementation perspective) is that the delegates are not part
of the responder chain in the sense that you can't call
- -setNextResponder: on them, but that their delegating objects
internally attempt to send them messages before calling [[self
nextResponder] ...].  If this is the case, then you can't inject a
responder between the object and its delegate without overriding
methods in the delegating object.

> 2. If I have two windows, and each of them has such a custom 
> controller inserted into its responder chain after the 
> windowController (or delegate?). What happens when I bring them to 
> front in turn (user clicks on each). Somewhere Appkit re-wires the 
> responder chain, and connects the window to the application ---
> won't my controller be dropped out of the responder chain then?

I'm actually not sure, though this would be easy enough to test.  It's
possible that AppKit traverses the responder chain, breaks the
connection at the highest level possible, and reestablishes the links
at that level, but I don't know.

The reason I'm unsure is that I haven't had cause to do so - if you
want a custom controller for each window, what's wrong with using
their NSWindowControllers, which certainly are handled properly by
AppKit and which are designed for this purpose?

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk5ve0YACgkQaOlrz5+0JdVZYgCdFsfZ9AexbTQNJfghrBze8HG5
GQwAnRmzVSACRnSae19899N42qU5qt5e
=OzKV
-END PGP SIGNATURE-
___

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

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

2011-09-13 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/13/11 10:30 AM, Scott Ribe wrote:
> - A couple of minutes still seems like a long time to load it. 
> Perhaps there is a more efficient way to store & load it?

Perhaps there are also matrix operations that occur as part of the
load process?

Regardless, if you are working with matrices of this size, you (the
OP, that is) should definitely scrutinize the Accelerate framework to
determine if there are hardware-optimized functions that would improve
performance (and maybe simplify your code).

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOb6FbaOlrz5+0JdURApy7AJ9X50xrKZViQoZjmR82ppBtbzFD2QCeP2kv
l/Woi8kONx51dpYKJbVz7ds=
=QfND
-END PGP SIGNATURE-
___

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

Please do not post 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: SDK 10.5 on XCode 4.1

2011-09-15 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/15/11 10:57 AM, Richard Somers wrote:
> On Sep 15, 2011, at 10:40 AM, Scott Ribe wrote:
> 
>> Minor nit, that's a symlink, not a hard link. One important 
>> difference is that a symlink can cross volume boundaries...
> 
> Correct. Second important difference is symbolic links may refer
> to directories which this is.

Not quite true.  User-land "ln" cannot (to my knowledge) create hard
links to directories in OS X.  But the file system does support such
hard links.  The remote backup program that I use (rsnapshot) definitely
does it, and I suspect that is what Time Machine does under the hood as
well.

There's a lengthy discussion of this matter on Stack Overflow for anyone
interested:
http://stackoverflow.com/questions/80875/what-is-the-bash-command-to-create-a-hardlink-to-a-directory-in-os-x

But yes, for your purposes you want a symlink.

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOckB9aOlrz5+0JdURAsYTAJ0R487HqyHVt7kuIl/SlLVGWxa4GwCePBXa
88rzdDSINaszPVwEB+9Oosg=
=6Str
-END PGP SIGNATURE-
___

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

Please do not post 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: Timeout back to login screen

2011-09-15 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/15/11 12:40 PM, Shawn Bakhtiar wrote:
> 
> Hi All,
> 
> I have multiple users using the same iTouch device during our 
> inventory, shipping and receiving process. They log in, take 
> inventory, ship stuff, receive stuff, than leave it on the
> counter. They have requested that the unit time out after 5 min
> back to the log in screen. I have done some research on line, and
> have come across a few awkward suggestions on how to do it.
> 
> I am looking for someway of detecting when the device goes back to 
> the lock screen, and using that as a signal to take my app to the 
> login window and clear out the password field.

Take a look at the UIApplicationDelegate protocol.

I haven't played with it, but:

- - applicationProtectedDataWillBecomeUnavailable:

looks like a promising direct notification that the phone is going to
be locked (provided the device is using content protection and a
passcode).

It's a bit of a misappropriation of the notification, but other
options (such as -applicationWillResignActive:) are going to have side
effects because they can be triggered by other events.


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk5yWHwACgkQaOlrz5+0JdVXiwCfXCh1RiGWkbz6pOJBVAkqgM/n
UfgAn1Enl23LuGAI8a2XgaI3s1zitF6W
=X2vs
-END PGP SIGNATURE-
___

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

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

2011-09-21 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/21/11 12:26 PM, koko wrote:
> Is Gestalt(gestaltSystemVersion, &MacVersion) the wat toget OSX 
> versions today and moving forward?

Can you elaborate on what you are trying to do?  There are relatively
few scenarios, I would think, where getting the version number is what
you really want.


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOejulaOlrz5+0JdURAqAmAJ0RnF2N807+5zD12GADG1WNzNP5xwCfc8JV
tktMlEBDDKouOQviWoF9Fzs=
=72hm
-END PGP SIGNATURE-
___

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

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

2011-09-21 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/21/11 1:59 PM, koko wrote:
> FRSystemProfile is very nice ... I am unfamiliar, is it free?
> 

It's under the Apache license... in general, start at the top of a
file's comments when looking for license info.

And regarding my earlier query: I agree, this sounds like a reasonable
place to use version numbers.  I just wanted to make sure you weren't
trying to do something like determine whether a certain framework is
available by looking at the OS version. :-)

(For anyone reading this in the list archives: please don't use OS
version numbers for such tasks.)

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOelKHaOlrz5+0JdURArG5AJ9KBV8wHEIPFic0gREZrVbrHxv4cwCeJ+pv
KSgqiLgwqLS0z6UmTpRFgaM=
=DsoY
-END PGP SIGNATURE-
___

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

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

2011-09-21 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/21/11 2:22 PM, Charles Srstka wrote:
> Why not? I find it to be safer than checking for the existence of
> a method, because you never know if that method might have actually
> have existed before it went public, but in a less stable form or
> with different behavior. If this is the case, then just checking
> whether the method exists and calling it could produce who knows
> what behavior on older systems.

I have always been under the impression that Apple recommends weak
linking and run-time checks.  It's what's covered in the (aging) Tech
Note 2064 for OS X and, IIRC, is what is discussed in, for example,
the original iPad/iOS 3.2 release notes.

What are some examples of breakage happening under this scenario?  I'd
like to be on the lookout myself if I indeed did put too much faith in
the documentation.

> There’s also the case where an API exists, but is buggy on older 
> versions, causing you to want to avoid that API unless you’re
> running at least a certain version of OS X (for example, -[NSURL 
> URLByDeletingLastPathComponent] before Lion).

That is an interesting case that I hadn't really considered, and I
concede that it is a situation where checking the OS version (or, at
least, NSAppKitVersionNumber) may be the best solution.

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOemCDaOlrz5+0JdURAk7bAJwII/9jEyqonDSS5lncZTMp/WBQEQCfUnCo
bUmH61OQ2zdcVXxENd1DKXA=
=r7I6
-END PGP SIGNATURE-
___

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

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

2011-09-22 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/22/11 7:37 AM, AM wrote:
>> What are some examples of breakage happening under this
>> scenario? I'd like to be on the lookout myself if I indeed did
>> put too much faith in the documentation.
> 
> One relevant case I encountered was a leak in CFFileDescriptor
> which occurred on 10.5 but was fixed in 10.6. Under 10.5 (when
> detected), I had to manually close a leaked file descriptor.

Yes (but this falls into the second category of tasks in the message
to which I was replying, and clearly weak linking isn't going to get
around this sort of issue).

Good to know about QLPreviewPanel, though.  An app I'm casually
working on will probably eventually make use of QuickLook, so Kyle's
response may well save me some headaches.

Thanks to everyone who replied for the enlightenment.


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOe3shaOlrz5+0JdURAi1kAJ9eA1WQhvUwq1IxzbSjEQwOxTzkUgCgh7Ys
auhCVgmjItphmLofALraLAg=
=lMXt
-END PGP SIGNATURE-
___

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

Please do not post 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: Telling apart different save panels

2011-09-22 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/22/11 3:34 PM, Graham Cox wrote:
> 
> On 23/09/2011, at 5:20 AM, Seth Willits wrote:
> 
>> On Sep 20, 2011, at 6:00 PM, douglas welton wrote:
>> 
>>> I'm not sure that my solution is any "less messy" than what
>>> you have suggested, but... when faced with this same situation,
>>> I gave the save panel a different title each time it was
>>> invoked. When the panel object was passed to my delegate, I
>>> could tell where the panel was being used by the title of the
>>> inbound object.  No need for subclasses or additional retains.
>> 
>> 
>> 
>> You could use Obj-C associated objects for the same effect with 
>> your own property instead of reusing title.
> 
> Can you elaborate? I'm not sure what you mean by this.

Associated objects are a runtime feature that allow you to, well,
attach one or more objects to another one using a key-value mechanism.
 They are often used to add pseudo-ivars in category methods.

See the documentation for objc_setAssociatedObject() and related
functions.

So instead of co-opting the title, one option is to store a panel
identifier as an associated object on the panel then look it up in
your delegate with objc_getAssociatedObject().


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOe7wZaOlrz5+0JdURAiwHAJ4uR5GZwLQLArB49bZbZXnOo7jN8ACeO/H5
Ylzo50e0qUdZlEYuXH0QObI=
=9P1f
-END PGP SIGNATURE-
___

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

Please do not post 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: searching for strings containing "

2011-09-26 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/26/11 5:26 PM, Koen van der Drift wrote:
> How do I use isEqualToString with strings that contain a " ?
> 
> The string I try to find is for instance:  name= "foo" Type="bar"
> 
> So:
> 
> if ([myString isEqualToString: @"name= "foo" Type="bar"")
> 
> Gives an error because there are too many " symbols.  I looked
> into replacing the " with ' by using 
> stringByReplacingOccurrencesOfString:withString:  , but that gives 
> the same problem.

Did you try escaping the inner quotes with backslashes?

@"name= \"foo\" Type=\"bar\""

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOgRpLaOlrz5+0JdURAjE5AJ9Vbp1uINz+jQt6zFtYIqPkXVmSVACfUGoF
6U7QqtEotoTJ9RMTviBXK2s=
=RGTT
-END PGP SIGNATURE-
___

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

Please do not post 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: creating multiple NSTimers

2011-09-29 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/29/11 3:06 PM, Tom Hohensee wrote:
> Yes.  What I have worked on is using an array of timers fired 
> sequentially.  Each firing of the timer sets up the next one in the
> array.  Each new addition to the array requires invalidating of the
> active timer and reordering of the array according to times. But i
> have run into problems when two or more timers are set to fire at
> the same time.

I don't really follow what you are doing here, but given the original
description of your problem, wouldn't an NSMutableDictionary keyed by
IP be a good choice?  Then you can just add/remove timers as needed
and not have to worry about shifting an array.

If you are trying to get the timers ordered by when they will fire, do
not overlook, e.g., NSDictionary's –keysSortedByValueUsingComparator:.

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOhO6raOlrz5+0JdURAoLMAJ4qJwuj5/6riE4jhtc3n6mafOYxdACbBOJP
yUKa53Va5NYPgITcnpJJyPU=
=xa6z
-END PGP SIGNATURE-
___

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

Please do not post 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: creating multiple NSTimers

2011-09-29 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/29/11 4:48 PM, Tom Hohensee wrote:
> Sorry, I started this out wrong.   I am probably over thinking
> this to the point of confusion.  Here is where I am. I have an
> application for a facility that uses a number of ip enabled set top
> boxes to drive TV's  throughout the place.  Each box is to be
> shutdown at certain times of the day depending on what part of the
> facility is closed for the day.  In my app the user sets up a
> configuration in an NSTable whereby each device is set to shut down
> at a certain time each day.  From this configuration, I setup
> timers to correspond to the shutdown time and have them repeat each
> 24 hours.  I originally thought I would simply load each into the
> runloop using NSTimers class method 
> +scheduledTimerWithTimeInterval:target:selector:userinfo:repeats. 
> without retaining a reference to it.  But I ran into the problem
> of the user changing a device's shutdown time while the app is
> running. I needed to retain a reference to the timer to invalidate
> it .  In other words, if the user comes along and wants to change
> the configuration (a shut down time) of one device while the app
> is running I need to be able to stop the timer that is currently in
> the run loop and use the new configuration.  Without invalidating
> that timer would I not have an active timer in the run loop on top
> of what is created by new configuration?  I then moved on the
> creating timers and instead of loading them into the run loop I
> would load them into an array and and sort them according to time.
> I then loop through the array loading only the first timer of the
> array into the run loop and retain a reference to it. Each firing
> of the timer loads the next timer into the run loop and retains a
> reference to it. But this has other issues particularly when firing
> times are real close together.
> 
> At this point I need a fresh prospective on this.  Any thoughts
> would be greatly appreciated.

OK, from the description I still don't see why you couldn't schedule
the timers on the run loop and keep references to them in an
appropriately keyed dictionary.  When someone needs to edit the
shutdown time you simply fetch the timer from the dictionary and
- -setFireDate:.  You would also have the ability to invalidate timers
and remove them from the dictionary.

Just make sure you remove the timers from the dictionary once
fired/invalidated.  (You could probably avoid this step by using
zeroing weak references if you really wanted.)

The polling approach described by John and Jamie would presumably also
work, but I would consider the dictionary approach more straightforward.

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOhQ1saOlrz5+0JdURAvEhAKCK7mCy5d/Y2Byx3CrKGPtyJ2PgowCffXNt
oCPRXWNVcHVyCLeRIuGQSyI=
=dH8W
-END PGP SIGNATURE-
___

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

Please do not post 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: delegate of an NWindowController's window

2011-09-29 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/29/11 5:38 PM, Koen van der Drift wrote:
> This all goes fine, the sheet opens and I get generate the data, 
> stored in an NSDictionary in MyDataWindowController. Now I  want 
> somehow to get the data back to MyAppDelegate. So I am trying this
> in MyDataWindowController:
...
> id  del = [self delegate];  // 
> <---
> 
> if ([del respondsToSelector:@selector(insertData:)]) { [del 
> insertData: data]; } }
> 
> [NSApp endSheet: [self window] returnCode: 1]; [[self window] 
> orderOut: self];
> 
> Which now gives the warning:
> 
> Semantic Issue: Instance method '-delegate' not found (return type 
> defaults to 'id') on the line with the arrow.

As Graham mentioned, NSWindowController does not have a -delegate
method.  The compiler seems to be telling you that you didn't
implement one yourself either.

If I had to hazard a guess, I would surmise that you are getting
tripped up by the fact that NSWindow DOES respond to -delegate and, in
practice, one often sets an NSWindow's delegate to be an
NSWindowController instance.

So, you could declare a delegate property on MyDataWindowController
and handle it that way.

An alternate approach, depending on the details of your
implementation, might be to make use of some of the other parameters
in that lengthy -beginSheet... method; setting appropriate values for
didEndSelector (and, potentially, contextInfo if your design requires
it) can probably get you what you need.

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOhRViaOlrz5+0JdURAroXAJ4tO2WAshz1c/UpyoLnq6Q7s+VvkwCeLHiC
jPPm4IuWqlE5rnxhxmBZ7W0=
=6cVo
-END PGP SIGNATURE-
___

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

Please do not post 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: creating multiple NSTimers

2011-09-30 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/29/11 10:50 PM, Greg Guerin wrote:
> Gordon Apple wrote:
> 
>> There must already be an array for the table, so just iterate
>> the
> array every
>> minute or whatever (single repeating timer), compare the times to
>> [NSDate date} and start or shut down whatever has not been
>> started or shut
> down.  Much
>> easier than trying to manage timers.
> 
> You don't have to iterate the whole array, either.  Sort it by
> ascending order of turn-off time.  Keep a current position (index).
> If the time of day is less than the turn-off time of the device at
> the current position, do nothing.  If time of day >= turn-off time
> of current position, then turn it off and advance position until
> time of day is again less than the turn-off time of device at the
> current position. Only needs one timer, and scales to as large an
> array as you want to keep.

I don't really see how this is superior to keeping the one timer per
remote box.

When the user updates a timer, one is forced to re-sort the array and
reposition the index (under the above implementation).

One would also have to implement the scheme carefully, particularly if
the shut-off code is offloaded onto separate threads, to avoid
potential race conditions arising from a user changing a fire date in
the middle of a shut-off sequence.

And as Graham mentioned, polling is probably less CPU and power
efficient than using timers anyway.

Am I missing something conceptually here?  Why are people pushing for
the single timer model?  Is there some hidden complexity in a
multi-timer approach that I'm not seeing?


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6FbZoACgkQaOlrz5+0JdUAuQCcC3cpCXFJSa7/AMJcrca7l749
1zcAn1tM1yHYuZkoZhvCMPVdAA1UBX4u
=tv8r
-END PGP SIGNATURE-
___

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

Please do not post 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: creating multiple NSTimers

2011-09-30 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/30/11 12:29 AM, Thomas Davie wrote:

>> When the user updates a timer, one is forced to re-sort the
>> array and reposition the index (under the above implementation).
> 
> Why would you need to resort?  Just remove, and reinsert.

OK, I'll grant you it's a fast re-sort, but you still have to find the
new insertion point and move the index (if needed).

>> One would also have to implement the scheme carefully,
>> particularly if the shut-off code is offloaded onto separate
>> threads, to avoid potential race conditions arising from a user
>> changing a fire date in the middle of a shut-off sequence.
> 
> Careful locking required in multithreaded environment – 
> unsurprising.

Of course, though my gut feeling (admittedly happening at a time of
day where I'm fast fading and likely to put my foot in my mouth...) is
that the locking would be simpler if one had discrete timers that can
be scattered across threads (or run their invocations on separate
threads - though that might be unsuitable for the task at hand).  I
haven't sat down and implemented this (as you evidently have), so I
must confess I don't have much to stand on here.

>> And as Graham mentioned, polling is probably less CPU and power 
>> efficient than using timers anyway.
> 
> Who's suggesting polling - you simply have one timer set for the
> time at which the first of your actual timers goes off.  When it
> goes off, you fire the first of your actual timers, and reschedule
> your "when do other timers go off" timer.

OK, my apologies, I got turned around and had the earlier suggestion
about a high-resolution poll still stuck in my head.  You're
absolutely right - no one is suggesting polling in the above.

>> Am I missing something conceptually here?  Why are people
>> pushing for the single timer model?  Is there some hidden
>> complexity in a multi-timer approach that I'm not seeing?
> 
> I implemented the single timer model yesterday, but I have to
> admit, the reason was because I'm targeting GNUstep, and when I
> stared at their source I discovered that they simply itterate
> through *all* timers every run loop iteration checking if they've
> gone off, their code also starts NSLogging warnings if you have
> more than 1000 timers.  I have no idea if apple's solution is
> better than GNUstep's, but if it isn't, the single timer approach
> would be vastly beneficial.

Wow, I have to imagine there are a fair number of timers getting fired
off throughout the system all the time for various tasks and that
Apple would have optimized it more thoroughly.

But a cursory inspection of the most recent open source CFRunLoop.c
suggests that indeed is what is happening inside __CFRunLoopDoTimers.
 It's possible that I'm missing something in my tired state, but it
sure does look like a simple loop.  (There's a lot of magic happening
in __CFRunLoopDoTimer, but it still gets called during each loop
iteration.)

Huh... color me surprised.

Thanks for the response (and putting up with me).

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6Ff6wACgkQaOlrz5+0JdXnYwCeL8dCMMzWdLxigqgak56ADr9U
jQUAnjltbDhavl2/PiwUiD7O+HofAU/Q
=Yo8x
-END PGP SIGNATURE-
___

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

Please do not post 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 to run a ln command for every boot

2011-10-05 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 10/5/11 12:16 AM, kiran kumar wrote:
> Hi All,
> 
> I need to run this  ln -s /Applications/test.app ~/Desktop/  command for 
> every boot on Mac OS 10.6.
> Please can any one suggest me how to do this  .

1) This has nothing to do with Cocoa.

2) Symlinking at every boot between two fixed paths seems really unusual
(unless ~/Desktop is getting wiped every time for some reason).  It
should also be noted that ~ doesn't mean a whole lot at boot time since
it is determined by the logged-in user.  My first guess is that you are
using autologin to a guest account of some sort that does not persist
files, in which case there are likely better ways to accomplish whatever
result is intended from your question.

3) If you are interested in the general topic of automated execution,
Google "login items" (for an easy user-configurable method) or "launchd"
(OS X's full-featured Swiss army knife of automated execution, roughly a
replacement for the System V init/cron scripts and more).

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.8 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6MEeYACgkQaOlrz5+0JdWRkgCdFYLARGwbGAHkf3hWhWLcpxAg
1igAn1ULFrirdhH8lfb8hpnwo2bKTvlQ
=bfv3
-END PGP SIGNATURE-
___

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

Please do not post 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: UIWebView not updating picker when picking dynamically populated select items

2011-10-05 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 10/5/11 12:04 PM, Ron Wagner wrote:
> I have an app with a UIWebView. The contents of the UIWebView 
> contains two html  items. When the first select item is 
> changed, javascript on that   item populates the second 
>   time according to the selection of the first  
> item.
> 
> The problem I am experiencing is that when tapping on the first 
>   item, Safari brings up a Picker for the   item, 
> along with a view above the Picker containing Previous and Next 
> buttons. When clicking on the Next button, the Picker stays in
> place and the second   item is focused, but the Picker
> doesn't update to display the newly updated contents of the second
>  item, which was populated by the first  item's
> onChange javascript.
> 
> I am about to file a bug report against WebKit for this, but am 
> looking for a workaround. I realize that this might be more of a 
> Safari list question, but since it is in an app using a UIWebView
> I'm willing to attack it from either side if anyone has any ideas.

There are undoubtedly people on the list (and elsewhere) far more
skilled than I in these sorts of issues, but I'll throw out a couple
naive ideas.

I presume that you have otherwise tested this behavior and that the
problem only manifests when "Next" is used (instead of tapping on the
page body, thus resigning first responder)?  If so, that does rather
sound like a WebKit bug.  (I'm also assuming that you meant
"UIWebView" instead of "Safari" in your message.)

As a workaround, maybe try using a different event.  Instead of
"onchange" (note: event names are technically supposed to be
non-camel-cased: http://www.w3.org/TR/html4/interact/scripts.html),
what happens if you use "onblur" on the first  or "onfocus" on
the second ?

It might also help (for your bug report if no other reason) to
determine whether the issue is WebKit failing to trigger the
"onchange" event or the second  failing to honor the change.
If you through in an alert() or equivalent into your "onchange" code
it should be pretty easy to distinguish.  If the problem is 
failing to honor the change, you might be SOL (or at least would have
to find some more convoluted approach that does trigger an update).


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOjK/GaOlrz5+0JdURAtHpAJ9sqeto7O3ElcE9KnbXa7vy2E6EmwCdGFnj
2gcRn68bVR0CCyC2lwcLypg=
=izgR
-END PGP SIGNATURE-
___

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

Please do not post 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: Writing a simple vector graphics editor - how to implement?

2011-10-05 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 10/5/11 12:39 PM, Nick wrote:
> I am a beginner in this kind of programs (usually I ended up with
> placing few buttons/standard Cocoa controls and implemented rather
> low level logic of the application). I need an advice how would
> experienced developers implement this basic functionality.

Good for you!  UI can be frustrating at times, but it can also be a
lot of fun.

> Is it correct to implement all the objects as views, that are the
> subviews of the "sheet view"? But since this sheet can be bigger
> than the window, I will need some kind of scrolling support.. And I
> need to have the objects to be editable by their edges.. Not sure
> how to do it.

You might start by taking a look at NSScrollView, which will enclose
your canvas.

> Could you please give me a basic idea of how such kind of editors
> are usually implemented? If there are some simple opensource
> programs, I'd be thankful for their names.

Graham Cox will probably respond to your message as well, and I
recommend you take a look at his DrawKit framework
(http://apptree.net/drawkit.htm), which includes a nice sample program
putting the pieces together.

Apple's Sketch is probably useful too.

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOjLnZaOlrz5+0JdURAmUdAJ4/nN/byNUBz6gvWQlbiMG4kMLSsQCeLIM7
SsTuZNVqfiIvKCEF8vggA/I=
=Jobs
-END PGP SIGNATURE-
___

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

Please do not post 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: UIWebView not updating picker when picking dynamically populated select items

2011-10-05 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 10/5/11 1:01 PM, Ron Wagner wrote:
> I can see the actual select item on the web page changing when it 
> should. The problem is that the Picker items aren't changing along 
> with the select item. I've tried a hack to un-focus the second
> select and then re-focus it, but when I re-focus it I can see the
> select item focused, but the Picker doesn't come back up. When
> hitting the next button or directly clicking on the second select,
> the Picker stays up but doesn't update it's items.

OK, sorry, I misunderstood your problem.  Are you then saying that the
options in the picker do not match the underlying options in the
 element?  Or that the options match but the selected item
does not match?

It also seems really strange to me that the picker doesn't come up
when you give the  focus.  Are you doing this by just calling
focus() on the element?

Anyhow, this is pretty clearly a WebKit or JavaScript glitch, so this
list is not well suited to the problem.  I'd be happy to continue a
conversation off-list if you want to bounce ideas back and forth.



- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOjMq/aOlrz5+0JdURAt13AJ9MSNlXG09hbVgM3KUCQSLszg5WBQCeIpWV
d6TI7/bz4Xe+iFXKXzS2F4U=
=2JFU
-END PGP SIGNATURE-
___

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

Please do not post 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: NSTableView - Drag/Drop not working

2011-10-09 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 10/7/11 10:25 PM, GW Rodriguez wrote:
> I have gone through many different threads on this, read the docs
> and went over a few example projects.  For some reason I cannot
> get reordering via drag and drop to work.  I have even created a
> new project with only a NSTableView with one column and pasted code
> from a working example and it still wont work.
> 
> My guess is my error is somewhere around the
> registerForDraggedTypes method because I cannot even start the
> drag.  It only start to highlight multiple selections.  I dont
> fully understand that method and I should also note that all the
> example projects are document based projects and mine is not.

Code would really help here.

To get to the point where dragging *begins* you need to minimally do
the following:

1) Have a data source (an object that, in 10.6 and newer, conforms to
NSTableViewDataSource) properly set for your table.  I repeat: make
sure your data source is assigned to the object in which you are
implementing your dragging methods.

2) In your data source, return YES from
–tableView:writeRowsWithIndexes:toPasteboard:.

If you do this, you will be able to start a drag (but won't be able to
drop it anywhere yet).

Note what I did not mention:

* Whether the app is document based is irrelevant.

* You DON'T need to call -registerForDraggedTypes:.  This method is
used to set which pasteboard types the view potentially _accepts_ from
a drag.  If you don't register one or more types, the table view won't
let you drop a row that you are dragging, but it will let you begin a
dragging session.

* You DON'T need to implement anything other than a return in
–tableView:writeRowsWithIndexes:toPasteboard:.  Of course, if you
don't you won't actually be storing any pasteboard data, so the drag
will be useless - but the drag will still visually begin.

So, check on your implementation of the two steps listed earlier.  You
might consider breaking on
–tableView:writeRowsWithIndexes:toPasteboard: to make sure it's
getting called.

After you have nailed that down and can see a drag begin, you will
need to flesh out the full dragging procedure.  In particular:

1) DO call -registerForDraggedTypes: and give it an array of UTIs; for
a table view, this may be a single custom UTI you define for internal
use and which you will use in the dragging methods where required.

2) DO fully implement –tableView:writeRowsWithIndexes:toPasteboard:.
For row reordering purposes, it may be as simple as:

- - (BOOL)tableView:(NSTableView *)tableView
writeRowsWithIndexes:(NSIndexSet *)rowIndexes
toPasteboard:(NSPasteboard *)pboard
{
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
[pboard declareTypes:[NSArray
arrayWithObject:MyAwesomeCustomUTIStringThatIDeclaredSomewhere]
owner:self];
[pboard setData:data
forType:MyAwesomeCustomUTIStringThatIDeclaredSomewhere];
return YES;
}

3) DO implement
- -tableView:validateDrop:proposedRow:proposedDropOperation:, most
likely returning NSDragOperationMove for a row reordering operation.

4) DO implement -tableView:acceptDrop:row:dropOperation: to reorder
the rows and/or update the model (if appropriate), typically returning
YES if it's a simple row reordering.

Good luck - feel free to post a link to your sample project if you
can't get it to work.

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6RZ9sACgkQaOlrz5+0JdVHhgCfcYVJb9z4LPGSYse8lqlL1j9Z
Y84AnjBIrGlea59mWTKqLnnVejOBxXUg
=YAKg
-END PGP SIGNATURE-
___

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

Please do not post 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 get info about an iOS device (UDID, etc)?

2011-10-10 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 10/10/11 5:44 PM, Jens Alfke wrote:
> I’m writing an internal app our QA engineers going to use to
> capture performance metrics on various iOS devices. After running
> tests, the app will upload the results to a server. In those
> results I need to include enough info to identify the device, so I
> want to get things like the UDID, the model ID (e.g. “iPhone 4” or
> a codename that can be mapped to it), and maybe lower-level stuff
> like the clock speed and RAM and whether it’s on battery power or
> charging.
> 
> I can’t find the APIs to get this sort of stuff. I was thinking
> the SystemConfiguration framework, but I didn’t see anything
> relevant in SCSchemaDefinitions.h. Searching the Xcode doc browser
> didn’t help. Any clues?
> 
> —Jens
> 
> PS: I realize these may not be Cocoa APIs, but I’m not sure what 
> other list would be more relevant.

Check out the UIDevice class.

(You probably want to use the MAC address instead of the UDID...)


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOk5WZaOlrz5+0JdURAr8MAJ4kqfFnOCwCC+iepHClb4vknZ9hjQCfVUfo
fZO2wPPnpKYBojTzmQRwfSk=
=N0Iv
-END PGP SIGNATURE-
___

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

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

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

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


Re: Get my NSDocument-based application out from "Open With" menu?

2011-10-20 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 10/20/11 12:25 PM, Lee Ann Rucker wrote:
> 
> On Oct 20, 2011, at 4:51 AM, Nick wrote:
> 
>> Hello I have an application that is able to process .txt files, 
>> which can be opened using File->Open and saved with File->Save, 
>> File->Save As. The problem is that Finder thinks that my 
>> application is an app that the user may want to open by double 
>> clicking a text file. How does it do it? And how could I prevent
>> OS X from adding my application to the list "Open With" of the
>> context menu of txt files? Thank you
> 
> Take .txt out of your plist, subclass [NSDocumentController 
> runModalOpenPanel:forTypes:] to add "txt" to the types it can
> open, and (I think; I haven't done this) [NSDocument 
> fileNameExtensionForType:saveOperation:] for save - if not, that's
> a starting point.___

May I also ask why you would want to do this?  I would generally expect
that if an application lets me open and save a format via the menus that
I would also be able to open it through Finder.


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6geIoACgkQaOlrz5+0JdV2/QCfXV2WNQenIKih3GVsnrOW+QO1
ObQAn2ZlJ3xcrc3dVgLFKjyYvUGjohK+
=GGSw
-END PGP SIGNATURE-
___

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

Please do not post 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: Draw a non-antialiased image (NSImage)

2011-10-28 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 10/26/11 1:17 AM, Nick wrote:
> hi I have a 2x2 px png image which represents a line element. I am
>  drawing this "line" by drawing vertically repeatedly these line 
> elements. The problem is, when I resize the window, I get this 
> line's width "doubled" (probably, because of antialiasing) and the
>  line appears blurred. Is there a way I could disable this 
> "antialiasing" (or whatever it is?). Thank you
> 
> int borderSize = 2;
> 
> [line drawAtPoint:NSMakePoint([self bounds].size.width-borderSize, 
> totalHeight-(borderSize/2 + borderSize+i*borderSize)) 
> fromRect:NSMakeRect(0, 0, borderSize, borderSize) 
> operation:NSCompositeSourceAtop fraction:1.0];

You're iterating over the length of the line?

If so, I think you are overengineering this.  Have you investigated
whether CGPattern will accomplish what you want?  (There is a thorough
section in the Quartz 2D Programming Guide that you will probably find
more useful than the somewhat sparse class documentation.)

My guess is that using an API designed for tiling will not only
alleviate various artifacts that may be introduced in other methods
but will probably give superior performance (and make for more
readable code).

- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOq1hEaOlrz5+0JdURAoWaAJsGEvouo0WvP0hKoF3ThQMdq4/3UgCfUF2e
PEZBFja6yE645be+FxjQ2FM=
=VCS/
-END PGP SIGNATURE-
___

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

Please do not post 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: Draw a non-antialiased image (NSImage)

2011-10-28 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 10/26/11 1:17 AM, Nick wrote:
> hi I have a 2x2 px png image which represents a line element. I am
> drawing this

Btw, using an image for a 2x2 element seems like overkill.  Even if
you drew every pixel with Quartz drawing code you would have four
lines of code.

Unless you are working with an artist or designer who is not in a
position to edit code, you can probably get better results (as well as
resolution independence) by drawing such an element in code.


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOq1kjaOlrz5+0JdURAgf5AJ9AuQDO/CQfF+wWCJaorQGRk5fb/ACdHLsl
/O9rLjCikWJ1wCqJ8YlaaIk=
=yG+Z
-END PGP SIGNATURE-
___

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

Please do not post 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: Problems with runModalForWindow, looking for alternatives

2011-11-01 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 11/1/11 11:41 AM, Vojtěch Meluzín wrote:
> But the retainCount is needed for successful release of the window,
> right? I allocate the window and then deallocate it when I'm
> finished with it. But runModalForWindow increases retainCount to 2,
> so when I release it, it's actually not destroyed and causes a
> crash afterward, because for some crazy reason the OS tries to
> repaint the view in it, despite the window is already closed...


Quoting from the NSObject protocol reference:



- - (NSUInteger)retainCount
...
Important: This method is typically of no value in debugging memory
management issues. Because any number of framework objects may have
retained an object in order to hold references to it, while at the
same time autorelease pools may be holding any number of deferred
releases on an object, it is very unlikely that you can get useful
information from this method.

To understand the fundamental rules of memory management that you must
abide by, read “Memory Management Rules”...



You may have a problem leading to a crash, but examining retainCount
will only confuse matters.

> I'm using my own styles. It may be no according to HI guidelines,
> but to be honest, I don't care. The app/plugin should look the same
> on all platforms.


I disagree vehemently (as I suspect do others on the list), but I
won't dwell on this.

> Yaj, ok, can you explain a little more? I don't know much about
> Objective C, how should the MStringToNSString be implemented to
> create the autoreleased NSString? (sorry for lack of knowledge, but
> I just don't plan any further development in objc, just want the
> small layer...)


I don't really know C++, so there is some generalization here.  Since
you are returning a retained NSString, presumably inside your function
are you are doing something like:

return [[NSString alloc] initWithCString:stringFromCPlusPlusMethod
encoding:someEncoding];

To return an autoreleased string, instead use:

return [NSString stringWithCString:stringFromCPlusPlusMethod
encoding:someEncoding];


- -- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFOsEmlaOlrz5+0JdURAvPIAJ0T9zfk1j0pkPAppTeXRTQ6Fo9HWgCfYb9W
AWSjxZKNtvONuqN6vS5YvCQ=
=ILa7
-END PGP SIGNATURE-
___

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

Please do not post 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 detect clicks outside of modal window?

2011-11-02 Thread Conrad Shultz
On 11/2/11 5:46 PM, Vojtěch Meluzín wrote:
> Ok, folks please forget about the intentions, if they are bad, they will be
> badly rewarded :).
> Anyway I need it from Leopard. Is that really so hard to do such a trivial
> thing in Cocoa???

NSWindow's delegate protocol declares a -windowDidResignKey: method that
you may also find useful.  But I suspect you are going to have trouble
because the window is modal; as a result I don't think that will be
called when you would like.

What you are describing is highly non-standard, and Cocoa behaves in a
manner to discourage behaviors that users may find confusing or
unexpected.  A phrase commonly seen on this list is "don't fight the
framework."

Take note of the HIG's section titled "Embrace Modelessness" - you are
feeling the nudge of the framework.  I also see that the HIG recommends
using a panel if possible, just as Scott recommended.

-- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

___

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

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

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

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


Re: How to detect clicks outside of modal window?

2011-11-03 Thread Conrad Shultz
Close the window in its delegate's -windowDidResignKey:. 

You will need to architect your app differently, though. Blocking the main 
thread waiting for the window to close will not work. You instead need to have 
the appropriate delegate method (e.g. -windowWillClose:) call back into your 
code (or put whatever you need to do, such as finalizing an update to your 
model, directly in the delegate method implementation).

(Sent from my iPhone.)

--
Conrad Shultz

On Nov 3, 2011, at 8:58, Vojtěch Meluzín  wrote:

> Thanks. Ok, let's say I'm ok with "not making it modal". All I need is that 
> when I show the window, the "method" that does that must return after the 
> window has closed. So basically it's still the same thing, I just can live 
> with the fact that the window may not be modal and rather closed when gets 
> deactivated. How to do that? Do I need to write my own event loops?
> 
> Vojtech
> 
> 
> Dne 3. listopadu 2011 2:03 Conrad Shultz  
> napsal(a):
> On 11/2/11 5:46 PM, Vojtěch Meluzín wrote:
> > Ok, folks please forget about the intentions, if they are bad, they will be
> > badly rewarded :).
> > Anyway I need it from Leopard. Is that really so hard to do such a trivial
> > thing in Cocoa???
> 
> NSWindow's delegate protocol declares a -windowDidResignKey: method that
> you may also find useful.  But I suspect you are going to have trouble
> because the window is modal; as a result I don't think that will be
> called when you would like.
> 
> What you are describing is highly non-standard, and Cocoa behaves in a
> manner to discourage behaviors that users may find confusing or
> unexpected.  A phrase commonly seen on this list is "don't fight the
> framework."
> 
> Take note of the HIG's section titled "Embrace Modelessness" - you are
> feeling the nudge of the framework.  I also see that the HIG recommends
> using a panel if possible, just as Scott recommended.
> 
> --
> Conrad Shultz
> 
> Synthetiq Solutions
> www.synthetiqsolutions.com
> 
> 
> 
> 
> 
> 

___

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

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

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

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


Re: Read Keyboard

2011-11-03 Thread Conrad Shultz
I assume you mean that keyDown: is not called if _only_ a modifier key is 
pressed. If it's not called for any key press then you have bigger problems. 

To answer your question, the method you are looking for is NSResponder's 
-flagsChanged:.

(Sent from my iPad.)

--
Conrad Shultz

On Nov 3, 2011, at 10:25, koko  wrote:

> Within a method I want to read the keyboard to look for ctrl or shift being 
> down.  Is this possible?
> 
> I ask because I first thought to implement keyDown and set a flag for the the 
> key BUT for whatever crazy reason the keyDown for the view is not being 
> called ... the view has been made first responder.
> 
> Any comments or suggestions would be appreciated.
> 
> -koko
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/conrad%40synthetiqsolutions.com
> 
> This email sent to con...@synthetiqsolutions.com
___

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

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

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

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


Re: Storyboard scene and UIViewController

2011-11-03 Thread Conrad Shultz
On 11/3/11 12:05 PM, Eric E. Dolecki wrote:
> I init a UIViewController class...
> 
> FooViewController *fvc = [[FooViewController alloc] init];
> 
> This is great, but I have to generate all the UI for the view controller in
> code in the class. Is it possible to layout a scene in a Storyboard and
> associate it with the view controller so that the UI in the scene will be
> used instead of me doing it all in code?

I haven't explored storyboarding yet, but it's definitely not the case
that you in general need to construct UI in code.

Make sure you are aware of UIViewController's -initWithNibName:bundle:
method!


-- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com

___

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

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

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

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


Re: UISplitViewController some of the time

2011-11-03 Thread Conrad Shultz
On 11/3/11 10:28 AM, Eric E. Dolecki wrote:
> Sorry - but I am not following you. What I just tried that almost work is:
> 
> In my detail view controller for the split view controller, I added in it's
> viewDidLoad:
> 
> HomeUIViewController *tmp = [[HomeUIViewController alloc] init];
> [self presentModalViewController:tmp animated:NO];
> [[NSNotificationCenter defaultCenter] addObserver:self
> selector:@selector(removeMainView:)
> name:@"removeMainView" object:nil];
> 
> And added this method to the same detail view controller:
> 
> - (void)removeMainView:(NSNotification *)notification {
> [self dismissModalViewControllerAnimated:YES];
> }
> In my HomeUIViewController I have a button that broadcasts that
> "removeMainView" - which causes the viewcontroller to be removed.

Sorry, didn't you want the home view to be the initial view?  If so,
this seems backwards.

I'm pretty sure Matt was recommending you do something more like the
following.

In your main view controller (that is, the one initially visible), being
the HomeUIViewController, have an action that responds to your button
(typed in email, be warned):

MySplitViewController *svc = [[MySplitViewController alloc]
initWithNibName:@"MySplitViewController" bundle:nil];

[self presentModalViewController:svc animated:YES];

[svc release];

Then in MySplitViewController, have some UI that allows you to return to
the home screen, and simply call:

[self dismissModalViewControllerAnimated:YES];

No notifications needed.

As an aside, notifications are used primarily for decoupling objects and
for communicating with an indeterminate number of objects.  These
conditions don't really apply here.  If you need a modally presented
view controller to communicate with its presenter, it should probably
use delegation or a similar form of direct messaging.


-- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
___

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

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

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

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


Re: UISplitViewController some of the time

2011-11-03 Thread Conrad Shultz
On 11/3/11 1:04 PM, Eric E. Dolecki wrote:
> I am not using nibs. Per Apple's guidelines, a splitviewcontroller must
> be the root. My "home" view controller needs to fill the whole screen,
> over top of the splitviewcontroller, which I've done. 

As I said, I have _never_ used storyboards, so this could probably
benefit from someone who actually knows about this.

That said, I glanced over what I could find about UIStoryboard and the
like.  I couldn't find anything about UISplitViewController needing to
be at storyboard root.

Now, I know that the HIG tell you (and, I believe, the framework
expects) that UISplitViewController's view should not be a subview -
that is, it expects to take over the screen.  Fine.  Is that what you
were referring to?  If so, that's not an issue here - presenting a
UISplitViewController modally, either in code or by setting the seque
transition style (reminder: I've never done this!) to modal should work.

> Right now I am trying to get the storyboard scene for my
> HomeUIViewController to be used instead of just calling up my class and
> having to do all the UI with code. I'd like to use the scene instead.
> This is happening in the app delegate FYI.

To be clear: storyboard or no, you can ALWAYS use a nib to encapsulate
UI that you hook up in code, getting the best of both worlds (potentially).

UINib is just another class.  If you want to get access to pre-built UI
for use in code, try something like (typed in email):

UINib *nib = [UINib nibWithNibName:@"MyNib" bundle:nil];
NSArray *topLevelObjects = [nib instantiateWithOwner:foo options:nil];

Then pull out whatever objects you please from topLevelObjects and
manipulate them.  If you have IBOutlets in the file where you are doing
this, and set owner to self, you might even be done.

As I indicated above, though, I seriously doubt this is necessary for
what you are trying to accomplish.  If you could clarify where you are
getting this information about UISplitViewController needing to be root,
and if I could maybe spend some time writing a test app to familiarize
myself with storyboarding, we could get to the bottom of this.

But I can't believe there is no one on the list who has experience with
this new technology - please chime in!

-- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
___

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

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

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

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


Re: UITapGestureRecognizer and state/action w/rt numberOfTapsRequired

2011-11-08 Thread Conrad Shultz
On 11/8/11 1:14 PM, Jeffrey Oleander wrote:
>> In order to respond to both a single and double tap, do I
>> thus need to attach two gesture recognizers?
> 
> Go another layer more primitive:

Please don't drop down to UITouch unless you have to (which mainly means
if you are supporting pre-UIGestureRecognizer devices).

As for your issue of single vs. double taps, from the class reference:

"For the gesture to be recognized, the specified number of fingers must
tap the view a specified number of times."

I'm not sure why you aren't receiving intermediate messages, but trying
to key off intermediates is not a great pattern anyway.  Just attach two
gesture recognizers, then you have the benefit of separating your action
methods (which will be nice if you decide to change gestures later on).

If you want to suppress the single tap action in the event of a double
tap, employ the –requireGestureRecognizerToFail: method when setting up
the recognizers, paying special attention to the notes ("Requiring a
Gesture Recognizer to Fail") on this matter in the Event Handling Guide
(http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/GestureRecognizers/GestureRecognizers.html).

-- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
___

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

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

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

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


Re: UIGestureRecognizer

2011-11-08 Thread Conrad Shultz
On 11/8/11 10:23 AM, Eric E. Dolecki wrote:
> Hi all,
> 
> I'd like to be able to drag my finger around on a UIImageView, and without
> lifting the finger have a long press trigger a method of mine. I'd prefer
> to use UIGestureRecognizer if possible.
> 
> 
> Right now the longPress triggers only on a distinct press, not a drag
> around and then hold.

As far as I know this behavior cannot be accomplished using only the
built-in recognizers.  It's easy to require a recognizer to fail before
another succeeds, but the inverse is not true.

Unless someone has a better suggestion, you will need to create a custom
UIGestureRecognizer subclass.  By careful design, you can probably use
UIPanGestureRecognizer and UILongPressGestureRecognizer internally to
minimize the amount of touch-handling code you need to write.

-- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
___

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

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

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

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


Re: Allocating too much memory kills my App rather than returning NULL

2011-11-08 Thread Conrad Shultz
On 11/8/11 9:43 PM, Don Quixote de la Mancha wrote:
> It would be enough if there were some way I could check ahead of time
> how much I can safely allocate, without actually trying to allocate
> it.  Is there an API for that?

I don't see how there COULD be an API for that for the simple reason
that the phone is not a static device, and your app does not run in a
vacuum.  Phone calls can come in, alerts can fire, background processes
can run.  At best you have a race condition.

This seems very much like the "how do I check for server availability?"
question that comes up on the list every couple months, with the
inevitable response of "try it."

> A bad workaround would be to just empirically determine how much
> memory is safe to allocate by trying various grid sizes.  A binary
> search would determine that pretty quickly for each of my devices.
> But that is not the desired solution, because future hardware models
> will likely have more physical RAM.  Also the amount that can be
> safely allocated would depend on how much is left over from other
> processes, and so could not be counted upon to be any particular fixed
> amount.

And there's a bigger problem.  That memory warning notification that you
referenced in your first message is there to tell you that you need to
free up resources ASAP at run-time.  Quoting from the iOS App
Programming Guide:

"Using large amounts of memory can seriously degrade system performance
and potentially cause the system to terminate your app."

You don't just get to hold onto whatever memory the OS can allocate at
some arbitrary point in your app's life cycle.  iOS will keep system
services (from telephony on down) running at all costs, and (AFAICT)
will keep Apple-supplied background tasks running as well (e.g.
iPod/music app).  Under low memory conditions, it will terminate
suspended apps first but will eventually kill your app too, even if it's
running in the foreground.

You are expected to allocate as LITTLE memory as possible, make caches
discardable, and play nicely with memory warnings.

-- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
___

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

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

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

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


Re: How to switch GDB disassembly from Thumb to ARM?

2011-11-09 Thread Conrad Shultz
This doesn't have anything to do with Cocoa. You might have better luck taking 
it up on the Xcode-users list. 

(Sent from my iPad.)

--
Conrad Shultz

On Nov 9, 2011, at 9:39, Don Quixote de la Mancha  
wrote:

> My iOS App is build with the Apple LLVM 3.0 compiler in Thumb mode.
> For armv7, I'm pretty sure that's actually Thumb-2.
> 
> I'm reimplementing my two most time-consuming functions in ARM
> assembly code.  The callers of these functions are Thumb, so I use
> Thumb to ARM interworking instructions to switch to ARM in the
> prologue of my functions so I have acesss to ARM's richer instruction
> set and greater number of registers.  At function exit I use ARM to
> Thumb interworking to return to ARM mode.
> 
> GDB's disassembly is correct for the Thumb code, but when I am in ARM
> mode, it disassembles the ARM instructions as if each one were a pair
> of completely nonsensical Thumb instructions.  Is there some way I can
> tell GDB to switch to ARM disassembly, then upon returning to Thumb
> code, use the Thumb disassembler?
> 
> Google is no help.  There are apparently other forks of GDB that can
> do that, but I haven't figured out a way to do it with GDB.
> 
> LLDB apparently supports ARM debugging, but it does not yet work on
> iOS devices in Xcode 4.2.  When I choose the LLDB debugger in Product
> -> Edit Scheme, then set a breakpoint in my code, my App hangs before
> hitting the breakpoint.
> 
> It's been a long time since I've done any assembly of any sort, so I
> am brushing up on the ARM calling conventions by implementing
> functions that take various parameters and return various types of
> results in both C and ARM assembly.  The lower_case functions are C
> and the CamelCase functions are assembly.  I call abiTest the very
> first thing from main(), and use assert() to ensure that it returns
> YES
> 
> BOOL abiTest( void )
> {
>void_no_args();
>VoidNoArgs();
> 
>if ( 42 != int_no_args() )
>return NO;
> 
>if ( 42 != IntNoArgs() )
>return NO;
> 
>return YES;
> }
> 
> Here is the source for IntNoArgs.  .thumb_func is a directive for the
> linker.  My research seems to indicate that you want it even for ARM
> functions, if one mixes the two types of code
> 
> .globl _IntNoArgs
> .align 2
> .code 16
> .thumb_func _IntNoArgs
> 
> _IntNoArgs:
>@ int IntNoArgs( void );
>.loc 1 __LINE__ 0
> 
>adr r0, Larm1 @ Larm1 is a PC-relative address.  r0's low bit
> will be cleared
>bx r0   @ Switch to ARM mode then branch to Larm1.
> That's the next instruction
> 
> .align 4
> .code 32
> Larm1:
>stmfd sp!, { r7, lr }
> 
>mov r0, #42
> 
>ldmfd sp!, { r7, lr }
>bx lr
> 
> Here is how GDB disassembles the _IntNoArgs.  The first two lines are
> correct, the remainder are completely wrong
> 
> 0x000172c8  <+>  addr0, pc, #0(adr r0, 0x172cc )
> 0x000172ca  <+0002>  bxr0
> 0x000172cc  <+0004>  lslsr0, r0
> 0x000172ce  <+0006>  stmdbsp!, {r1, r3, r5}
> 0x000172d2  <+0010>  b.n0x17a16
> 0x000172d4  <+0012>  lslsr0, r0
> 0x000172d6  <+0014>  ldmia.wsp!, {r1, r2, r3, r4, r8, r9, r10, r11,
> r12, sp, lr, pc}
> 
> The disassembly stops here because the ldmia.w instruction appears to
> be putting a new value into the program counter after taking it from
> the stack, thereby returning from the subroutine.  After I step over
> this instruction with "si" the disassembly pane show:
> 
> 0x000172d8  <+0016>  vrhadd.u16d14, d14, d31
> 
> The si instruction always does the right thing, by advancing just one
> instruction whether we are in Thumb or ARM mode.  So GDB _must_ know
> the current instruction set architecture, it's just that the
> disassembler is not getting that information.
> 
> There is a bit in one of the ARM's register that indicates the current
> mode.  Some forks of GDB have the ability to use the value of that bit
> when determining which ISA to disassemble as, but this is apparently
> not the case with Xcode 4.2's GDB.
> 
> Xcode's GDB has a command "set arm disassembler" and its corresponding
> "show arm disassembler" that looks like it would help, but it doesn't.
> That apparently is meant to support other kinds of ARM variants than
> what the iOS devices use.
> 
> "set fallback-mode" can be set to arm, thumb or auto in other forks of
> GDB, but not Xcodes.  Ditto for "set disassembler-flavor".
> 
> What I would REALLY REALLY REALLY like is a machine debugger th

Re: 2 itunesconnect questions

2011-11-11 Thread Conrad Shultz
Quick note: the 3GS and onward use ARMv7. You would not be limited to the 4S. 

(Sent from my iPhone.)

--
Conrad Shultz

On Nov 11, 2011, at 12:42, Development  wrote:

> I attempted to submit an app last night and it failed validation because it's 
> universal but did not include armv6 arch. I'm using xcode 4.2 and assumed the 
> universal (and only) selectable setting was fine. It was not.
> 
> Easy correction of the issue, manually set the archs. 
> 
> Problem. an upcoming game i'm working on requires a certain library I 
> purchased and of course do not have code level access too. It was not 
> compiled correctly for me to use the universal setting in xcode. it's armv7 
> only. Hence I cannot submit it to the app store in a few weeks...
> 
> I've contacted the developer but do not expect a response or fix at this 
> point. Basically... am I too understand that if I don't nix plans to use this 
> library and find another solution I can only build my app for iPad and 
> 4s?___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/conrad%40synthetiqsolutions.com
> 
> This email sent to con...@synthetiqsolutions.com
___

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

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

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

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


Re: 2 itunesconnect questions

2011-11-11 Thread Conrad Shultz
On 11/11/11 1:11 PM, Development wrote:
> Well like I said in my previous email. I need to know how to build my
> app to run as an iPhone app on iPhone and a iPad app on iPad. Since I
> always use device specifics in the interface.
> 
> In the setting in the Build Summary I've set it to Universal. in the
> Build Settings the arch is set to the only selectable option of armv7
> 32 bit. Am I missing another setting? Or am I going to have to build
> every app specifically as an iPad app and a separate iPhone app which
> I don't see any one else doing.

Sorry, we had a bit of a race condition there.  :-)  I sent out my
previous email before I received your subsequent one.

Truth be told I haven't built any universal apps myself, but obviously
it can be done.

Did you setup your project as a universal app from the beginning, use
the "convert to universal" option, or configure the project settings
manually?

Did you add "armv7" to the UIRequiredDeviceCapabilities in Info.plist?
(Cf.
http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html)

-- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
___

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

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

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

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


Re: 2 itunesconnect questions

2011-11-11 Thread Conrad Shultz
On 11/11/11 1:21 PM, Glenn L. Austin wrote:
> Set your iOS Deployment Target to iOS 4.3 and build ARMv7.

I don't think the OP said that the app should be version restricted.
Why target 4.3?



-- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
___

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

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

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

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


Re: 2 itunesconnect questions

2011-11-11 Thread Conrad Shultz
See comments below. 

(Sent from my iPhone.)

--
Conrad Shultz

On Nov 11, 2011, at 13:39, Development  wrote:

> That's the problem I ran in to. I wanted to maintain some degree of backward 
> compatibility 4.2 

OK. But architecture and target SDK can be throttled independently. So set your 
target to 4.2, base to latest version. 

> However... honestly... I dont have anything pre ipod 3 iphone 3gs to even 
> test on so I can't say with any accuracy the software will work anyway. 

Craigslist is useful for acquiring old equipment on the cheap (assuming you are 
in the U.S.). I always kept an old iPod touch with the last 3.x on it until 
very recently when we decided to finally require 4.0 or higher.

> I guess switching to 4.3 minimum is fine. I mean are there still a lot of 
> people still using iphone 2? or ipod 2? It's just that I didn't even stop 
> building mac apps as ppc/intel until there was no choice.

Again, no reason you should need to set 4.3 minimum. 



___

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

Please do not post 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: 2 itunesconnect questions

2011-11-11 Thread Conrad Shultz
On 11/11/11 2:02 PM, Development wrote:
> Well your average dolt that jailbreaks and knows absolutely nothing
> about it would be blockaded. It's the folks that have hex editors and
> the time to figure it out that will find it easy. Which is still a
> little too much for many JB'ers. Besides, I want to see it broken so
> I can figure out how to stop it from happening in the next point
> release. That said... On my mac software I have a library I've
> written that makes cracking more difficult than using a hex editor
> and changing some bools. Specifically it uses a non MD5 hash to
> detect the slightest change in the binary, libraries or data files.
> Thus far, recompiling alone with absolutely no changes to the code
> will fail the hash check. Its been fairly successful. But I don't
> really understand code signing that well. so I am curious if such a
> hash would be possible on an iOS app. My understanding tells me that
> it would not work. The problem being of course that the hash is done
> after the app is built, archive builds preclude the inclusion of an
> after the fact data file.

(Insert obligatory statement about cryptography being hard here.)

Setting aside all the technical issues, do you have evidence that
jailbreak piracy is a large enough problem to justify you doing all this?

For one, while I don't have a percentage I'm quite certain that it is a
minority of phones that are jailbroken.  I run with a pretty tech savvy
crowd and I know only _one_ person who has jailbroken their phone, and I
am fairly confident that techies are more likely to go through the
trouble.  (How many average users have the faintest idea of what it
means to "jailbreak" a device?)

Jailbreaking is probably more prevalent in countries and cultures with
less of a tradition of paying for software.  But this leads to the
second point...

>From your standpoint you (presumably) really care about converting
would-be software pirates into _paying customers_.  If they can't use
your app on a jailbroken device yet don't buy it legitimately, you
haven't accomplished anything economically worthwhile.  In fact, you may
be worse off because you lose the (admittedly small) possibility that
the would-be pirate will show off your app to others who might in turn
become paying customers.

So, your calculus ought to be something like:

(# users with compatible devices) * (% with jailbroken devices) * (%
interested in your app) * (% unable or unwilling to circumvent your
protection) * (% who will purchase your app when confronted with copy
protection) * ($ price per sale)  >  (increase in legitimate sales that
could be obtained by devoting development resources to product
enhancement, marketing, support, etc.)

Let's suppose that 250M compatible devices have been sold, with 150M
distinct users (assuming that there are many people who have replaced
devices or own iPad with an iPhone, etc.)  Suppose 10% are jailbroken,
which is what some cursory Googling turns up.  That gives us 15M
candidate users.

Now, unless you are writing Angry Birds, it seems unlikely that you will
appeal to any more than 1% of the user base.  That leaves 150K users.
Maybe 80% are unwilling to circumvent your copy protection, leaving 120K
users.  Now the kicker: how many are then going to want to actually buy
the app?  Maybe 5%?  That puts you at 6000 users.

So with these admittedly crude guesstimates, if you could gain even 6000
users (out of the 135M non-jailbroken user base postulated above) by
devoting your time and energy to anything else, you'd come out ahead.

Do you think that is not possible?  Do you disagree with the analysis?
(I'm not asking rhetorically; I have based my own decisions on such an
analysis and would welcome criticism or clarification.)


-- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
___

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

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

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

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


Re: 2 itunesconnect questions

2011-11-11 Thread Conrad Shultz
On 11/11/11 4:59 PM, April wrote:
> Years ago I used my real name.  I was very new to cocoa (this is like
> 2002) and asked some dumb questions. I got flamed to death.

Greetings, April.  I regret that you were mistreated in the past; I am
confident that will not occur now.

Anyhow, did you get a chance to try the couple suggestions I tossed out
in previous messages?

I remain a little hazy on how your project got into this state.  I
understand that you manually set build architectures, but vis-a-vis
creating a universal app, did you:

a) Start a new Xcode project, configured to be universal; or
b) Convert an existing project using the universal conversion feature; or
c) Convert an existing project by hand?

I ask because I remember something in the docs about how the
migration/conversion feature does more than just change the target
platform and add a couple nibs, and that we shouldn't try to convert
projects manually.  If this is what you attempted then it seems possible
that there are other magic flags that need configuration.

Also, since this topic now seems to be well within the tools domain, you
might get good feedback on the xcode-users list as well.

-- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
___

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

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

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

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


Re: How to determine if there is an internet connection available?

2011-11-11 Thread Conrad Shultz
On 11/11/11 6:39 PM, Vojtěch Meluzín wrote:
> Hi,
> 
> I'm using BSD sockets for some internet access, it works fine. But if there
> is no connection available, it waits for say 30 seconds completely stopping
> the application. Is there a way to determine if there is actually an
> internet connection, so that I can check before using sockets?

(This has been extensively discussed in the past in the context of iOS
network availability.  Search the archives for more info.)

The only reliable way to verify connectivity is to attempt a connection.
 Checking for physical connectivity might speed up failure detection
(assuming you don't care about connections on the loopback interface),
but there are a host (no pun intended) of reasons that you still might
not be able to connect.

However, there are other options.

For one, since you are using BSD sockets (and I have to ask: are you
sure that a higher level API wouldn't accomplish what you need?), you
can use setsockopt() to control various timeouts.  One of the Darwin or
networking lists might be of more assistance at this level of the
application.

More worrying is your statement that the wait "completely [stops] the
application."  Are you saying that you are blocking the main thread
while waiting on I/O?  This is almost always a bad idea in a
user-interactive application.  The BSD sockets API is thread-safe (when
accessed from a single thread), so you could spawn a separate network
thread.  I believe there is also a non-blocking mode within the sockets
system, but people on the Darwin list would be more helpful here.

If you are able to use higher level APIs, life becomes somewhat easier.
 One level up, using CFNetwork, Apple has detailed documentation about
how to handle this issue
(http://developer.apple.com/library/mac/#documentation/Networking/Conceptual/CFNetwork/CFStreamTasks/CFStreamTasks.html#//apple_ref/doc/uid/TP30001132-CH6-SW19).


-- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
___

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

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

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

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


Re: Cannot D&D from an NSTableView

2011-11-14 Thread Conrad Shultz
On 11/14/11 3:45 PM, Koen van der Drift wrote:
> You were right. Implementing the custom cell, even though I only was
> calling drawFrameRect caused the D&D not to work.

Are you subclassing NSCell directly or using one of its subclasses?

Out of the box, NSTableView (or, rather, NSTableColumn) uses an
NSTextFieldCell, which importantly inherits from NSActionCell, which
itself adds lots of core functionality that we are used to (for example,
the target-action pattern).

It's possible that it also does some things behind the scenes to make
drag and drop work better.  So: what happens if you inherit from
NSActionCell?

-- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
___

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

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

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

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


Re: 2 itunesconnect questions

2011-11-14 Thread Conrad Shultz
On 11/11/11 9:37 PM, Glenn L. Austin wrote:
> On Nov 11, 2011, at 1:26 PM, Conrad Shultz wrote:
> 
>> On 11/11/11 1:21 PM, Glenn L. Austin wrote:
>>> Set your iOS Deployment Target to iOS 4.3 and build ARMv7.
>> 
>> I don't think the OP said that the app should be version
>> restricted. Why target 4.3?
> 
> 4.3 only runs on ARMv7, so it's one way to limit to customers who
> have "modern" devices.

So am I misunderstanding the UIRequiredDeviceCapabilities option?  I
thought that was the granular way to control architecture
requirements... setting to 4.3 when your app (theoretically) might still
run on 3.2 seems unduly harsh.

But I have not had to restrict to an architecture, so I was hoping you
might have some insight here.


-- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
___

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

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

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

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


Re: 2 itunesconnect questions

2011-11-14 Thread Conrad Shultz
er ran the app when I asked them to, and I am going to
> have to fix a crash that never happened in all that time. After all,
> those apple people could find a bug in 'hello world.'

Between ARC and the static analyzer, a great many crashers can nowadays
be eliminated.

As for the task of finding good, reliable beta testers... if you figure
out a secret, please don't keep it to yourself!

-- 
Conrad Shultz

Synthetiq Solutions
www.synthetiqsolutions.com
___

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

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

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

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


Re: Cannot D&D from an NSTableView

2011-11-14 Thread Conrad Shultz
Ah...

Have you read the documentation for NSCell's -hitTestForEvent:inRect:ofView: ?

In particular the note:

If the cell not disabled, and it would track, return NSCellHitContentArea 
|NSCellHitTrackableArea.

I believe that for dragging to work you do NOT want to return 
NSCellHitTrackableArea. What happens in your custom cell class if you  return 
just NSCellHitContentArea?

(I'm assuming from your original message that you had been using the default 
hit test implementation.)

(Sent from my iPhone.)

--
Conrad Shultz

On Nov 14, 2011, at 17:05, Koen van der Drift  wrote:

> 
> On Nov 14, 2011, at 7:15 PM, Conrad Shultz wrote:
> 
>> Are you subclassing NSCell directly or using one of its subclasses?
>> 
>> Out of the box, NSTableView (or, rather, NSTableColumn) uses an
>> NSTextFieldCell, which importantly inherits from NSActionCell, which
>> itself adds lots of core functionality that we are used to (for example,
>> the target-action pattern).
>> 
>> It's possible that it also does some things behind the scenes to make
>> drag and drop work better.  So: what happens if you inherit from
>> NSActionCell?
> 
> I'm indeed subclassing NSCell. Using NSActionCell doesn't make a difference. 
> But with NSTextFieldCell it works.
> 
> Thanks for the suggestion.
> 
> - Koen.

___

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

Please do not post 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: About iVars declaration and property

2011-11-16 Thread Conrad Shultz
One other advantage to using properties over direct ivar access internally is 
KVO compliance.

Usually I prefer to declare properties backed by ivars of a different name, 
then use getters/setters everywhere except inside initializers and dealloc. 
Frees me from having to worry about willChangeValueForKey:, etc.

I do this even if I currently don't observe a property in order to foster 
forward compatibility. 

(Sent from my iPhone.)

--
Conrad Shultz

On Nov 16, 2011, at 2:19, Quincey Morris  
wrote:

> On Nov 16, 2011, at 01:00 , Don Quixote de la Mancha wrote:
> 
>> Using properties significantly increased the size of my executable
>> file.  If I had something like this:
>> 
>> float a = [self foo: self.scale];
>> float b = [self bar: self.scale];
>> 
>> I could cut down the size of my code quite a bit by caching the return
>> value of self.scale:
>> 
>> float theScale = self.scale;
>> float a = [self foo: theScale];
>> float b = [self bar: theScale];
>> 
>> Now just removing one of two getter calls by caching its result won't
>> have that much effect on binary size, but the other night I went
>> through my code to do the exhaustively.  The size decrease was quite
>> significant.
>> 
>> Using properties when a simple iVar would do is not justified.  One
>> wants to use properties only when the generated code significantly
>> reduces the amount of work one has to do as a coder, for example by
>> automagically taking care of retain counts.
> 
> Once again you're using a bogus argument. There's nothing wrong (in most 
> cases) with using stack variables to "cache" property values or return values 
> as you have demonstrated. However, these are not ivars.
> 
> Within a class implementation, there's often nothing wrong with reading ivars 
> directly. There's also nothing wrong with writing ivars directly, except that 
> there is generally memory management to consider (though, I guess, not when 
> you're using ARC).
> 
>> Calling accessors is also quite slow compared to a direct iVar access,
>> because it has to go through Objective-C's message dispatch mechanism.
> 
> If you're talking about access from outside the class (that is, from clients 
> of the class), then the overwhelming consensus of developers who've being 
> using Obj-C for a while is that properties are a huge win, because they 
> provide useful encapsulation -- class implementation details, such as the 
> backing store (aka ivar) for a public property, are hidden within the class's 
> implementation.
> 
> If you're talking about access within the class implementation, then the best 
> approach depends on the circumstances. In many cases, the self-discipline of 
> encapsulating property values yields greater robustness for subclasses, code 
> readability, etc. In many other cases, internal encapsulation is of no 
> benefit and direct ivar access is perfectly fine.
> 
> I'll tell you, though, that (at least pre-ARC) the trend over the last 
> several years has been strongly in favor of using the properties, for 
> practical rather than theoretical reasons. Whether ARC might reverse this 
> trend isn't obvious yet.
> 
>> Focussing on interface is no excuse for weighty, bloated code!
> 
> I'm not sure what exactly this has to do with "interface".
> 
> One mantra that gets repeated a lot on this list is 'No Premature 
> Optimization'. If the "weighty, bloated" accessors produce no significant 
> *measurable* effect on your app, there's no reason to avoid them. If there is 
> a measurable effect, and if the measurable benefits of optimizing your code 
> outweigh the development costs of doing so, then by all means the optimized 
> route is the way to go.
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/conrad%40synthetiqsolutions.com
> 
> This email sent to con...@synthetiqsolutions.com
___

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

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

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

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


  1   2   3   4   >