Re: File UTI on 10.6.8

2012-01-03 Thread Quincey Morris
On Jan 2, 2012, at 23:57 , Martin Hewitson wrote:

> I want to check if a file extension is registered as a text file. So I made a 
> little category method on NSString like this:
> 
> - (BOOL)isText
> {  
>  BOOL fileIsText = NO;
> 
>  CFStringRef fileExtension = (CFStringRef) self;
>  CFStringRef fileUTI = 
> UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, 
> fileExtension, NULL);
>  if (UTTypeConformsTo(fileUTI, kUTTypeText)) {
>fileIsText = YES;
>  }  
>  CFRelease(fileUTI);
> 
>  return fileIsText;  
> }
> 
> This works fine on 10.7. On 10.6.8 when 
> 
> self = @"tex"
> 
> this returns NO and fileUTI is dyn.age81k3p2.
> 
> Anybody got an idea what this dyn.* means?

Well, you don't need to ask *us* when the answer in the the documentation for 
the 'UTTypeCreatePreferredIdentifierForTag' function:

> "If no result is found, this function creates a dynamic type beginning with 
> the dyn prefix. This allows you to pass the UTI around and convert it back to 
> the original tag."

OTOH, I doubt that you really want to *create* a UTI just to test conformance, 
especially since you immediately discard the created UTI. What's wrong with 
using one of the NSWorkspace methods, such as 
'filenameExtension:isValidForType:'?


___

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

Please do not post admin requests or moderator comments to the list.
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: Setting ApplePressAndHoldEnabled key for specific application.

2012-01-03 Thread Vaibhao Mahore
Hi Jens,

I have used Boolean value while setting 
ApplePressAndHoldEnabled key using
[[NSUserDefaults standardUserDefaults] setBool:NO  
forKey:@"ApplePressAndHoldEnabled"] . Even I tried with setting it using 
defaults tool.

1. defaults  write < my application bundle-identifier > 
ApplePressAndHoldEnabled  -bool   NO

Still I am unable to see "Press and Hold  for Certain keys" feature disable for 
my application.

Regards
Vaibhao Mahore

From: Jens Alfke [mailto:j...@mooseyard.com]
Sent: Tuesday, January 03, 2012 1:11 AM
To: Vaibhao Mahore
Cc: cocoa-dev@lists.apple.com
Subject: Re: Setting ApplePressAndHoldEnabled key for specific application.


On Jan 1, 2012, at 8:44 PM, Vaibhao Mahore wrote:


2.   I have tried with setting defaults for my application with 
ApplePressAndHoldEnabled being NO. I can even read defaults for my application 
using
defaults read < my application bundle-identifier >
Still I am unable to see "Press and Hold  for Certain keys" feature disable for 
my application.


Did you try forcing a boolean value for the default? I've had problems before 
where some system code only understands a boolean false, not the string "NO".

defaults write my.bundle.id ApplePressAndHoldEnabled --bool NO

-Jens

DISCLAIMER
==
This e-mail may contain privileged and confidential information which is the 
property of Persistent Systems Ltd. It is intended only for the use of the 
individual or entity to which it is addressed. If you are not the intended 
recipient, you are not authorized to read, retain, copy, print, distribute or 
use this message. If you have received this communication in error, please 
notify the sender and delete all copies of this message. Persistent Systems 
Ltd. does not accept any liability for virus infected mails.

___

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

Please do not post admin requests or moderator comments to the list.
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: Modal Window for NSTextField

2012-01-03 Thread Dany Golubitsky
Hello again.

I am sorry, I am new to Cocoa and some things that looks completely obvious to 
you are completely unknown to me.
(controlTextDidEndEditing: notification) - What is this function, where should 
it be implemented, who should call it?
How need I start the TextField? 

For my code I need to call opening function, wait for it to open, get text from 
user and return. Meaning:

{
Block 1
}
Calling for TextField and waiting for return value.
{
Block 2
}

Getting return value in some other place is not an option.


Is there any example of this?

Thanks!



-Original Message-
From: cocoa-dev-bounces+danyg=waves@lists.apple.com 
[mailto:cocoa-dev-bounces+danyg=waves@lists.apple.com] On Behalf Of Seth 
Willits
Sent: Monday, January 02, 2012 20:28
To: cocoa-dev cocoa-dev
Subject: Re: Modal Window for NSTextField

On Jan 2, 2012, at 4:02 AM, Dany Golubitsky wrote:

> // Make the text field "in focus", and start an editing session on it 
> [textField becomeFirstResponder];

-becomeFirstResponder is a notification method for when the responder becomes 
first responder; it doesn't *make* it first responder. For that you want 
[window makeFirstResponder:].



> Now I tried 2 approaches:

Both are wacky as Michael explained.


You do not need the window to be modal at all. The solution is really simple. 
Just start editing the text field, and when the editing is done 
(controlTextDidEndEditing: notification), you just remove the text field. 


--
Seth Willits
___

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

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

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

This email sent to da...@waves.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: File UTI on 10.6.8

2012-01-03 Thread Martin Hewitson

On 3, Jan, 2012, at 09:42 AM, Quincey Morris wrote:

> On Jan 2, 2012, at 23:57 , Martin Hewitson wrote:
> 
>> I want to check if a file extension is registered as a text file. So I made 
>> a little category method on NSString like this:
>> 
>> - (BOOL)isText
>> {  
>>  BOOL fileIsText = NO;
>> 
>>  CFStringRef fileExtension = (CFStringRef) self;
>>  CFStringRef fileUTI = 
>> UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, 
>> fileExtension, NULL);
>>  if (UTTypeConformsTo(fileUTI, kUTTypeText)) {
>>fileIsText = YES;
>>  }  
>>  CFRelease(fileUTI);
>> 
>>  return fileIsText;  
>> }
>> 
>> This works fine on 10.7. On 10.6.8 when 
>> 
>> self = @"tex"
>> 
>> this returns NO and fileUTI is dyn.age81k3p2.
>> 
>> Anybody got an idea what this dyn.* means?
> 
> Well, you don't need to ask *us* when the answer in the the documentation for 
> the 'UTTypeCreatePreferredIdentifierForTag' function:
> 
>> "If no result is found, this function creates a dynamic type beginning with 
>> the dyn prefix. This allows you to pass the UTI around and convert it back 
>> to the original tag."

Oops. Completely missed that. Even after reading your post it took me a while 
to see it. Probably time for another coffee.

> 
> OTOH, I doubt that you really want to *create* a UTI just to test 
> conformance, especially since you immediately discard the created UTI. What's 
> wrong with using one of the NSWorkspace methods, such as 
> 'filenameExtension:isValidForType:'?

Thanks! I didn't know about this NSWorkspace method. I think a google search 
got me to the solution I was using. 

Anyway, thanks, I'll try the NSWorkspace method.

Cheers,

Martin


> 
> 


Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

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

Please do not post admin requests or moderator comments to the list.
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: File UTI on 10.6.8

2012-01-03 Thread Martin Hewitson
Actually, it seems that the NSWorkspace method behaves differently, (assuming 
I'm using it correctly):

[[NSWorkspace sharedWorkspace] filenameExtension:@"pdf" 
isValidForType:(NSString *)kUTTypeText]

returns YES

whereas the UTTypeConformsTo() solution returns NO.

So am I passing the wrong value for Type?

Cheers,

Martin




On 3, Jan, 2012, at 11:04 AM, Martin Hewitson wrote:

> 
> On 3, Jan, 2012, at 09:42 AM, Quincey Morris wrote:
> 
>> On Jan 2, 2012, at 23:57 , Martin Hewitson wrote:
>> 
>> 
>> Well, you don't need to ask *us* when the answer in the the documentation 
>> for the 'UTTypeCreatePreferredIdentifierForTag' function:
>> 
>>> "If no result is found, this function creates a dynamic type beginning with 
>>> the dyn prefix. This allows you to pass the UTI around and convert it back 
>>> to the original tag."
> 
> Oops. Completely missed that. Even after reading your post it took me a while 
> to see it. Probably time for another coffee.
> 
>> 
>> OTOH, I doubt that you really want to *create* a UTI just to test 
>> conformance, especially since you immediately discard the created UTI. 
>> What's wrong with using one of the NSWorkspace methods, such as 
>> 'filenameExtension:isValidForType:'?
> 
> Thanks! I didn't know about this NSWorkspace method. I think a google search 
> got me to the solution I was using. 
> 
> Anyway, thanks, I'll try the NSWorkspace method.
> 
> Cheers,
> 
> Martin
> 
> 
>> 
>> 
> 
> 
> Martin Hewitson
> Albert-Einstein-Institut
> Max-Planck-Institut fuer 
> Gravitationsphysik und Universitaet Hannover
> Callinstr. 38, 30167 Hannover, Germany
> Tel: +49-511-762-17121, Fax: +49-511-762-5861
> E-Mail: martin.hewit...@aei.mpg.de
> WWW: http://www.aei.mpg.de/~hewitson
> 
> 
> 
> 
> 
> 


Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

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

Please do not post admin requests or moderator comments to the list.
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


Strategies for dynamic modification of search results in NSTextViews

2012-01-03 Thread Martin Hewitson
Dear list,

I have an app which managed a bunch of files and presents these text files for 
viewing and editing in NSTextViews. I have implemented a project-wide search 
functionality which works fine, but with one problem. If the user changes the 
text in one file after making a search, then the search results are no longer 
valid. A typical use-case is to make a search for a word or phrase, then go 
through each result and modify it. Problem is, after the first modification by 
the user, the subsequent results are no longer accurate/valid. 

Does anyone have any good suggestions as to how to update my search results 
when the underlying source text changes? Do I have to listen for all changes 
from the underlying text objects and try to adapt, or is there a better pattern 
for doing this? Xcode does this nicely: no matter what changes you make in the 
editor, the search results are updated on the fly.

Cheers,

Martin

___

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

Please do not post admin requests or moderator comments to the list.
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: CGDisplayHideCursor and -[NSWindow toggleFullScreen] don't get along on Lion

2012-01-03 Thread Michael Crawford
I'm curious.  I swapped out my calls to CGDisplayHideCursor and 
CGDisplayShowCursor with +[NSCursor hide] and +[NSCursor unhide], respectively. 
 Same behavior.  I wanted to know if one called the other so I set a breakpoint 
on the CGDisplay methods and called the NSCursor methods.  They don't appear to 
be layered.

I'm curious to know, what if any differences there are between the two sets of 
calls?  What advantage if any does one set have over the other?

-Michael

On Jan 2, 2012, at 5:11 PM, Michael Crawford wrote:

> For the benefit of anyone else who is watching and also has limited 
> experience with some of the new Lion features, a call to [NSWindow 
> setRestorable:] or flipping a switch in the interface builder UI for the 
> NSWindow instance, handily solves the problem.
> 
> -Michael
> 
> On Jan 2, 2012, at 4:56 PM, Michael Crawford wrote:
> 
>> Seth, I appreciate your offer to help out by testing some code.  Now that 
>> Kyle has identified what is going on, I'm looking into programmatically 
>> disabling or overriding the window restoration behavior for my app.
>> 
>> -Michael
>> 
>> On Jan 2, 2012, at 4:44 PM, Michael Crawford wrote:
>> 
>>> Thank you, Kyle.  That works.
>>> 
>>> -Michael
>>> 
>>> On Jan 2, 2012, at 3:16 PM, Kyle Sluder wrote:
>>> 
 On Jan 2, 2012, at 11:27 AM, Michael Crawford  
 wrote:
 
> Seth, don't run from inside Xcode.  Start the app from the finder.  I 
> find that in that instance, it goes to full screen and then immediately 
> exits full screen.
 
 Try launching with Shift held down to clear restorable window state.
 
 --Kyle Sluder
>>> 
>>> ___
>>> 
>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>> 
>>> Please do not post admin requests or moderator comments to the list.
>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>> 
>>> Help/Unsubscribe/Update your Subscription:
>>> http://lists.apple.com/mailman/options/cocoa-dev/michaelacrawford%40me.com
>>> 
>>> This email sent to michaelacrawf...@me.com
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>> 
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/michaelacrawford%40me.com
>> 
>> This email sent to michaelacrawf...@me.com
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/michaelacrawford%40me.com
> 
> This email sent to michaelacrawf...@me.com

___

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

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

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

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


Re: Modal Window for NSTextField

2012-01-03 Thread Fritz Anderson
On 3 Jan 2012, at 3:29 AM, Dany Golubitsky wrote:

> I am sorry, I am new to Cocoa and some things that looks completely obvious 
> to you are completely unknown to me.
> (controlTextDidEndEditing: notification) - What is this function, where 
> should it be implemented, who should call it?

It is a delegate method of NSControl. (Read up on the "delegate" design pattern 
for the concept.) You must make some object a delegate of each field you want 
to respond to; the object can then respond to the current value of the field. 
Use the firstResponder method of the enclosing window to get a pointer to the 
field. Searching the documentation will tell you more. (Perhaps you've done 
that, and don't want to believe what you're seeing.)

> How need I start the TextField? 

Send it to the window as the parameter for the window's -makeFirstResponder: 
method.

> For my code I need to call opening function, wait for it to open, get text 
> from user and return. Meaning:
> 
> {
> Block 1
> }
> Calling for TextField and waiting for return value.
> {
> Block 2
> }
> 
> Getting return value in some other place is not an option.

Running a text field modally is not a favored option. Few developers do it, 
because it's easier to defer processing till their did-end-editing method is 
called. It might be possible to lash something together with a borderless 
window, but this is a framework: _It_ calls _you_. If you want to program for 
the Macintosh, you really have to be able to design for asynchrony. Fighting 
the framework is a losing proposition.

— F

___

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

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

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

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


Versions, -windowWillClose:

2012-01-03 Thread Martin Hewitson
Dear list,

I'm investigating getting the new 10.7 Versions stuff working on my 
NSPersistentDocument app. In doing that, I've seen a couple of strange things 
which I wanted to check on. 

Firstly, all I've done to make it work is to return YES from +autosavesInPlace.

Now, what I notice is the following sequence of events:


1) App starts: 
windowControllerDidLoadNib 
2) Enter Versions browser
NSDocumentRevisionsDebugMode=YES
: kCGErrorFailure: CGSDisplayID: App trying to enumerate [0 to 
CGSGetNumberOfDisplays()] instead of using CGSGetDisplayList().  Compensating...
: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to 
catch errors as they are logged.
windowControllerDidLoadNib 
Entered Versions: NSConcreteNotification 0x108658620 {name = 
NSWindowDidEnterVersionBrowserNotification; object = }
3) Exit Versions (by clicking Done button in Versions browser)
Window will close  / 
Open windows 1 (logged in windowWillClose:)
Exited Versions: NSConcreteNotification 0x1091a22c0 {name = 
NSWindowDidExitVersionBrowserNotification; object = }
4) Exit App
Window will close  / 
Open windows 1 (logged in windowWillClose:)

Some questions:

a) Why is it that I don't have 2 open windows in step 3)?
b) What is the first window doing while the Versions browser is open? It seems 
the same document is opened again, judging by the NSWindow objects.
c) What are the Errors reported just after entering Versions?

Perhaps I'm not understanding how this stuff works yet, so any enlightenment 
would be gratefully received.

As a side question, where are the different versions of the document kept? I've 
read that they are kept in the document, but inspection of the (XML-based) Core 
Data document shows that's not the case. The app is actually a manager of other 
(text) files on disk, and I'm amazed to see that the versions actually reflect 
the state of the managed text files, even though the save core data document 
does not store the file contents. The file contents are stored temporarily in a 
core data entity as a transient property. Can I then conclude that these 
transient properties are stored in the different versions? I've tried reading 
through the documentation on this, and I've watched the WWDC11 session on this, 
but perhaps I need to do that again.

Best wishes,

Martin




___

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

Please do not post admin requests or moderator comments to the list.
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


cannot form weak reference to ..

2012-01-03 Thread Roland King
I have this line of code, just before a block is enqueued onto a dispatch 
queue. weakSelf is used in that block. 

RKHIPCard __weak *weakSelf= self;

which is generating the following error 

objc[15245]: cannot form weak reference to instance (0x89b4100) of 
class RKHIPCard

in certain very occasional circumstances. A bit of logging and it's clear that 
those circumstances are when the RKHIPCard, self, is in the middle of being 
deallocated. In other cases the object is perfectly fine for forming weak 
references. 

I read through the ARC spec and all the underlying methods which store into a 
__weak pointer are documented something like this (this one is objc_storeWeak( 
id *object, id value )

"If value is a null pointer or the object to which it points has begun 
deallocation, object is assigned null and unregistered as a __weak object. 
Otherwise, object is registered as a __weakobject or has its registration 
updated to point to value."

That's the case we have here, value points to an object which has begun 
deallocation, so it seems the language spec makes provisions for that and the 
store should work and store null into the weak pointer, which would actually 
work just fine. 

Is this an ARC implementation bug, or is it being trapped before the 
objc_xxxWeak() method is called or is that piece of the spec advisory-only and 
the runtime is free not to complain loudly if you do this? It's not very hard 
to work around, it's just a timing issue, in fact it's fixed already, but I had 
expected the weak variable assignment to 'just work' if the object is in fact 
being deallocated and was surprised that it doesn't. 

___

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

Please do not post admin requests or moderator comments to the list.
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: Static variables reset inside CFPlugin code

2012-01-03 Thread Jens Alfke

On Jan 2, 2012, at 6:27 PM, Grandinetti Philip wrote:

> But I'm troubled by this solution.   If I set debugger break points in the 
> "Units" library the debugger no longer stops at those breakpoints when called 
> by the plugin, but it does stop at those breakpoints when called by the main 
> app.   Makes me think I have two copies of code for my static units library 
> running after the plugin is loaded.   Does that make sense?

Yes. That’s what a static library is. As I said, it gets *copied* into the 
binary at link time. So you do have two copies of the code for the units 
library. If you only want one copy of the code, make a dynamic library instead 
(or a framework, which is just a dynamic library packaged with header files and 
resources.)

If you make Units a dynamic library, you won’t have to mess with 
CFBundleGetDataPointerForName either. Just make sure ‘unitsLibrary’ gets 
exported from Units, and declare it extern in the code that wants to use it.

—Jens

smime.p7s
Description: S/MIME cryptographic 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: File UTI on 10.6.8

2012-01-03 Thread Quincey Morris
On Jan 3, 2012, at 02:11 , Martin Hewitson wrote:

> Actually, it seems that the NSWorkspace method behaves differently, (assuming 
> I'm using it correctly):
> 
> [[NSWorkspace sharedWorkspace] filenameExtension:@"pdf" 
> isValidForType:(NSString *)kUTTypeText]
> 
> returns YES
> 
> whereas the UTTypeConformsTo() solution returns NO.

One thing to consider is that your UTType… approach uses the *preferred* UTI 
for '.pdf', which may indeed not conform to the text type. But there could be 
another '.pdf'-based UTI defined on your system that does conform. AFAICT the 
standard UTIs don't contain a text-conforming UTI for '.pdf', but it's 
certainly possibly that some app has added the association.


___

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

Please do not post admin requests or moderator comments to the list.
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: File UTI on 10.6.8

2012-01-03 Thread Martin Hewitson

On 3, Jan, 2012, at 07:14 PM, Quincey Morris wrote:

> On Jan 3, 2012, at 02:11 , Martin Hewitson wrote:
> 
>> Actually, it seems that the NSWorkspace method behaves differently, 
>> (assuming I'm using it correctly):
>> 
>> [[NSWorkspace sharedWorkspace] filenameExtension:@"pdf" 
>> isValidForType:(NSString *)kUTTypeText]
>> 
>> returns YES
>> 
>> whereas the UTTypeConformsTo() solution returns NO.
> 
> One thing to consider is that your UTType… approach uses the *preferred* UTI 
> for '.pdf', which may indeed not conform to the text type. But there could be 
> another '.pdf'-based UTI defined on your system that does conform. AFAICT the 
> standard UTIs don't contain a text-conforming UTI for '.pdf', but it's 
> certainly possibly that some app has added the association.
> 
> 

I see. I don't know how to check that. In any case, I'm left wondering which 
one to use. I want that .pdf is not a text file, so I guess I'll stick with the 
UTTypeConformsTo() solution, though this all feels a little fragile. I may make 
hard-coded exceptions for typical extensions that the app deals with, and 
always return YES from my -isText method for these particular extensions.

Thanks for your thoughts,

Martin


Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer 
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: martin.hewit...@aei.mpg.de
WWW: http://www.aei.mpg.de/~hewitson






___

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

Please do not post admin requests or moderator comments to the list.
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: Mouse up events ignored when sandboxing is turned on?

2012-01-03 Thread Nick Zitzmann

On Dec 30, 2011, at 12:49 PM, Nick Zitzmann wrote:

> The really strange thing is, this works as expected when sandboxing is turned 
> off. It also works as expected if the window was active. But I can't ship the 
> application with sandboxing on unless I can figure out how to fix or work 
> around this. Has anyone seen this before, and if so, then how do I make this 
> work?


Well, I reproduced the problem in a sample app, and filed the problem & sample 
as bug #10636986.

Nick Zitzmann


___

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

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

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

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


Re: File UTI on 10.6.8

2012-01-03 Thread Quincey Morris
On Jan 3, 2012, at 10:29 , Martin Hewitson wrote:

> I don't know how to check that. In any case, I'm left wondering which one to 
> use. I want that .pdf is not a text file, so I guess I'll stick with the 
> UTTypeConformsTo() solution, though this all feels a little fragile. I may 
> make hard-coded exceptions for typical extensions that the app deals with, 
> and always return YES from my -isText method for these particular extensions.

Incidentally, this:

[[NSWorkspace sharedWorkspace] filenameExtension:@"pdf" 
isValidForType:(NSString *)kUTTypeText]

returns NO for me. You could try investigating 
'UTTypeCreateAllIdentifiersForTag' to find all of the '.pdf'-associated UTIs on 
your Mac. That might give a clue. You could also investigate the Finder's "Open 
With…" menu (for some '.pdf' file), to see what applications have registered 
themselves as accepting PDF. Perhaps one of them registered a non-standard UTI.


___

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

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

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

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


Re: What are the best macros to use to know when compiling is for Mac OS X v.s. iOS?

2012-01-03 Thread Greg Parker
On Dec 30, 2011, at 10:34 AM, lbland wrote:
> On Dec 30, 2011, at 1:16 PM, Conrad Shultz wrote:
> 
>> http://developer.apple.com/library/mac/#documentation/developertools/conceptual/cross_development/Using/using.html
> 
> So...
> 
> __MAC_OS_X_VERSION_MAX_ALLOWED
> 
> is better than:
> 
> TARGET_OS_IPHONE

Both will work. Personally, I prefer the TargetConditionals version because it 
also provides macros for iOS simulator and device.

http://www.sealiesoftware.com/blog/archive/2010/8/16/TargetConditionalsh.html


-- 
Greg Parker gpar...@apple.com Runtime Wrangler


___

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

Please do not post admin requests or moderator comments to the list.
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: ALLOC/FREE problems with a NIB..

2012-01-03 Thread Martin Wierschin
Hi Robert,

> I seem to be crashing with the following message:
> malloc: *** error for object 0x104839c08: incorrect checksum for freed object 
> - object was probably modified after being freed.
> *** set a breakpoint in malloc_error_break to debug
> 
> However, malloc_error_break never gets called.
> I have a malloc stack log going, and when I do a malloc_history for my 
> object, I get a tonne of the following (this is the last entry):

The last entry in malloc_history isn't necessarily the cause of the problem. 
You'll want to inspect and think about all the objects that ever existed at 
0x104839c08, especially those you control more directly. 

It's very unlikely that the NIB loading code is the source of your problems; 
the NIB loading code is just reusing the memory address. What's more likely is 
that some object/memory you allocated earlier was deallocated, and your code is 
still incorrectly trying to use this now deallocated object.

Have you tried using NSZombie yet?

~Martin

___

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

Please do not post admin requests or moderator comments to the list.
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: ALLOC/FREE problems with a NIB..

2012-01-03 Thread Robert Monaghan
Hi Martin,

Thanks for the suggestion!
Believe it or not, it ended up being a for loop overwriting memory under a very 
specific condition.
This would cause a malloc to be corrupted, (for instance.)

Nothing like a wild goose chase. I looked everywhere for this one.

Best Regards,

bob.

On Jan 3, 2012, at 3:50 PM, Martin Wierschin wrote:

> Hi Robert,
> 
>> I seem to be crashing with the following message:
>> malloc: *** error for object 0x104839c08: incorrect checksum for freed 
>> object - object was probably modified after being freed.
>> *** set a breakpoint in malloc_error_break to debug
>> 
>> However, malloc_error_break never gets called.
>> I have a malloc stack log going, and when I do a malloc_history for my 
>> object, I get a tonne of the following (this is the last entry):
> 
> The last entry in malloc_history isn't necessarily the cause of the problem. 
> You'll want to inspect and think about all the objects that ever existed at 
> 0x104839c08, especially those you control more directly. 
> 
> It's very unlikely that the NIB loading code is the source of your problems; 
> the NIB loading code is just reusing the memory address. What's more likely 
> is that some object/memory you allocated earlier was deallocated, and your 
> code is still incorrectly trying to use this now deallocated object.
> 
> Have you tried using NSZombie yet?
> 
> ~Martin
> 

___

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

Please do not post admin requests or moderator comments to the list.
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: Modal Window for NSTextField

2012-01-03 Thread Graham Cox

On 03/01/2012, at 8:29 PM, Dany Golubitsky wrote:

> Calling for TextField and waiting for return value.


> Getting return value in some other place is not an option.


It simply doesn't work that way. In fact there's almost no code in Cocoa that 
does work that way, with the possible exception of NSAlert.

Read the documentation about the "field editor" and how it works, and how it is 
used by controls such as NSTextField. It's not especially complicated, but it's 
not as simplistic as you are assuming. Blindly throwing your own misconceptions 
about how the framework works at the problem will certainly lead to 
disappointment and frustration.

--Graham


___

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

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

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

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


Re: Why is +[NSFileVersion(NSTemporaryCompatibility) unresolvedConflictsExistForItemAtURL:] hanging/

2012-01-03 Thread John Chang
On Thu, 29 Dec 2011 11:41:22 -0700 James Bucanek wrote:
> I recently upgraded my primary development system to Lion and I'm 
> encountering a phenomenon with a lot of different applications (not just my 
> own) where the app will hang for 20 seconds or more when it's first launched 
> or a document it opened.
> + 2794 +[NSFileVersion(NSTemporaryCompatibility) 
> unresolvedConflictsExistForItemAtURL:] (in Foundation) + 64 [0x9602c57b]
> + 2794 LBRevisionHasUnsavedConflictForURL (in Librarian) + 57 [0x7b8786]

I've been having this same problem with Lion. Found this: 
http://www.macworld.com/article/163227/2011/10/fix_a_lion_file_opening_hang_in_mac_os_x_10_7_2.html

Seems to help some, but always.

Best,
/John

___

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

Please do not post admin requests or moderator comments to the list.
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


Custom NSDocument class will not save to file

2012-01-03 Thread Erik Stainsby
I'm certain this is a trivial error on my part, but my custom document class 
will not write the file to the local filesystem.  I have several other files 
which I can write, and I can write the content when I use an NSString to encode 
the text first.  But once I init my own document, setup the attributedText and 
try to writeToURL: or saveToURL: phht!  

"File could not be saved because the specified format is not supported."


This is the passage in my app delegate which drives the save operation in 
response to a web page being loaded into a webView:

NSError * error = nil;  
self.htmlText = [[NSMutableAttributedString alloc] initWithString: 
html];

WebHistoryItem * item = [[webview backForwardList] currentItem];
if( ! [history containsObject:item]) {
[history addObject:item];
}

NSString * urlString = [webview mainFrameURL];
NSString * filename = nil;

if( ! [htmlList itemWithTitle:urlString] )
{
[self configureWorkingSiteFolders:urlString];

if(nil==filename) 
{
if( [[[NSURL URLWithString:urlString] relativePath] 
isEqualToString:@"/"]) 
{
filename = [[@"" 
stringByAppendingPathComponent:@"index"]
 
stringByAppendingPathExtension:@"html"];
}
else {
filename = [urlString lastPathComponent];
}
}

// instantiate htmlDocument

RSSHTMLDocument * htmlDocument = [[RSSHTMLDocument alloc] init];
[htmlDocument readFromURL:[NSURL URLWithString:urlString] 
ofType:NSHTMLTextDocumentType error:&error];
[htmlDocument setTitle:[webview mainFrameTitle]];

NSURL * fileURL = NSUserDefaults standardUserDefaults] 
URLForKey:kRSSProjectDirectoryURL] 
URLByAppendingPathComponent:@"index" 
isDirectory:NO] 
URLByAppendingPathExtension:@"html"];

[htmlDocument saveToURL:fileURL ofType:NSHTMLTextDocumentType 
  forSaveOperation:NSSaveOperation error:&error ];
if( error ) {
[self presentError:error];
error = nil;
}
[htmlList addItemWithTitle:filename];
}


And here is the custom saveToURL:  implementation:


- (BOOL) saveToURL:(NSURL *)url ofType:(NSString *)typeName 
  forSaveOperation:(NSSaveOperationType)saveOperation 
error:(NSError **)outError {

BOOL saveSuccess = NO;
NSString * page = @"";
NSData * data = [attributedText dataFromRange:NSMakeRange(0, 
[attributedText length]) documentAttributes:nil error:outError];

if( outError ) {
[NSApp presentError:*outError];
outError = nil;
}
if(!filename) {
filename = [@"unnamed-file" 
stringByAppendingPathExtension:@"html"];
}

if(data) {
page = [[NSString alloc] initWithData:data 
encoding:NSUTF8StringEncoding];
NSLog(@"%@ [%04d] %@ %@",[self className],__LINE__, 
NSStringFromSelector(_cmd),page);
[page writeToURL:[[[NSUserDefaults standardUserDefaults]  
URLForKey:kRSSCSSDirectoryURL] 
URLByAppendingPathComponent:filename 
isDirectory:NO] 
  atomically:YES encoding:NSUTF8StringEncoding 
error:outError];

if( outError ) { 
[NSApp presentError:*outError];
outError = nil;
}
saveSuccess = YES;
}
return saveSuccess;
}


My question I suppose is how do I get saveToURL:  to write a plaintext version 
of the contents of my class? 

TIA,
Erik


___

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

Please do not post admin requests or moderator comments to the list.
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


[Moderator] Re: 360MacDev Conference Room Split?

2012-01-03 Thread Scott Anguish

On Dec 27, 2011, at 11:45 AM, Mac QA wrote:

> Hi,
> 
> I'm going to the 360MacDev conference in Denver on Feb 3-4. I'm
> writing to see if anyone going to the 360MacDev conference might be
> interested in splitting a 2-bed room at the conference hotel to help
> reduce costs. I'll be flying in on the 2nd, and out on the 5th. Please
> send me a direct e-mail to discuss further. Thanks.

Please, while the conference might be Cocoa related, room requests aren’t.

Please keep the talk here technical.

Thanks

Scott___

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

Please do not post admin requests or moderator comments to the list.
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


Copying objects between CoreData stores

2012-01-03 Thread Rick Mann
I'm working on a Core Data-based CAD app. The schema includes Parts and 
PartInstances. There is a to-many relationship from Part to PartInstance. The 
Library contains Parts, but a CAD file contains Parts and PartInstances.

When the user creates a new PartInstance in a document, I need to copy the Part 
object from the Library to the document. This is not just a copy from one 
NSManagedObjectContext to another, it's also a copy from one peristent store to 
another. That's fine.

But when the user instantiates a new PartInstance of the same Part again, this 
time I don't want to copy the Part over, because it already exists. I need a 
way to determine if the Part object already exists in the document's MOC.

I can create a UUID of sorts to use, but I'm wondering if I can do something to 
create the new object (in the new persistent store) with the same objectID as 
the object from which it's coming. That makes it much easier to then check for 
the existence of that object in the new store/context before creating it. Note 
that I have several other entities in the overall schema, and it would be nice 
not to have to add a uuid to each of those, as well.

Any recommendations?

Thanks,
Rick

___

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

Please do not post admin requests or moderator comments to the list.
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