metadata to propertyList

2010-12-19 Thread Rainer Standke
Helo,

I want to get file metadata into a propertyList. 

My first question is how to get the metadata for a specific file. I gather that 
there is not a way to get a NSMetadataItem for a specific file, other than to 
perform a NSMetadataQuery - which seems silly, since I have the file path to 
begin with. So I am considering to use an NSTask with mdls. Is that a good 
choice?

The second question is about how to parse the output of mdls. I am using 
NSScanner and a couple of NSString methods to distill the info I need. I am 
surprised that there is not a more succinct way of doing this. Am I overlooking 
something?

Thanks a lot for any insight you might provide,

Rainer___

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

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


NSToolbar help

2010-12-19 Thread lorenzo7620
I'm trying to add an NSToolbar to an existing application. I need  
compatibility with 10.4, so I'm creating the toolbar programmatically,  
initializing and configuring the toolbar in my -init. On launch, the  
toolbar does not appear and none of its delegate methods are called even  
though I setDelegate:self in -init. If I remove any of the delegate  
methods, I get an error in the console:


2010-12-19 13:13:21.415 ToolbarTest[16973:903] ERROR: invalid delegate  
 (does not implement all required methods), and so  
can not be used!


This output actually came from a bare bones test application I created in  
an attempt to isolate the problem. Here is my code:

mainWindow is an NSWindow instance setup as an IBOutlet

@implementation ToolbarTest

-(id)init{

if(self = [super init]){

toolBar = [[[NSToolbar alloc] initWithIdentifier:@"MainToolbar"]  
autorelease];

[toolBar setAllowsUserCustomization:YES];
[toolBar setAutosavesConfiguration:YES];
[toolBar setDisplayMode: NSToolbarDisplayModeIconAndLabel];
[toolBar setDelegate:self];

[mainWindow setToolbar:toolBar];

NSLog(@"Init called");
}
return self;


}
- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar{

return [NSArray arrayWithObjects:NSToolbarPrintItemIdentifier,
NSToolbarShowColorsItemIdentifier,
NSToolbarShowFontsItemIdentifier,
NSToolbarCustomizeToolbarItemIdentifier,
NSToolbarFlexibleSpaceItemIdentifier,
NSToolbarSpaceItemIdentifier,
NSToolbarSeparatorItemIdentifier, nil];

}

//- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar  
itemForItemIdentifier:(NSString *)itemIdentifier  
willBeInsertedIntoToolbar:(BOOL)flag{

//
// return nil;
//}


- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar{

return nil;
}


- (void)toolbarDidRemoveItem:(NSNotification *)notification{
return;
}

- (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar{
return nil;
}

- (void)toolbarWillAddItem:(NSNotification *)notification{
return;
}

@end

The application into which I'd like to add the toolbar has an NSTableView  
as well. Since the toolbar delegates aren't being called but the  
tableview's are, I added this to one of the tableview delegate methods just  
see what was going on with the toolbar:



- (int)numberOfRowsInTableView:(NSTableView *)aTableView{

[toolBar setVisible:YES];
BOOL cansee;
cansee = [toolBar isVisible]; // Returns NO

return 5;
}
Anyone have any ideas what's going on? Oh and I'm using Xcode 3.1.4 on  
Intel under 10.6

___

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

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

2010-12-19 Thread Knut Lorenzen

Am 19.12.2010 um 20:20 schrieb lorenzo7...@gmail.com:

> I'm trying to add an NSToolbar to an existing application. I need 
> compatibility with 10.4, so I'm creating the toolbar programmatically, 
> initializing and configuring the toolbar in my -init.

Just a shot in the dark, but perhaps -init is too early? Have you tried to set 
up your toolbar in -awakeFromNib instead?

Cheers,

Knut



___

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

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

2010-12-19 Thread lorenzo7620

On Dec 19, 2010 1:48pm, k...@highrolls.net wrote:
toolbarAllowedItemIdentifiers should return the array of allowed  
items ... returning nil says there are not items, ergo no toolbar!

On Dec 19, 2010, at 12:20 PM, lorenzo7...@gmail.com wrote:



toolbarAllowedItemIdentifiers






Thanks for the reply. I'll keep this in mind, but what I've found is that  
if I initialize the toolbar in awakeFromNib, it appears. Its empty, but its  
there and the hide/customize menu options are enabled. I can customize the  
toolbar and add items to the to toolbar.

Alright, now I'm cookin' with gas!
___

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

Please do not post 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: NSTextView scrolls to top on Save

2010-12-19 Thread Andy Lee
On Dec 18, 2010, at 10:38 PM, Andy Lee wrote:
> As a learning experience, I'm trying to make a trivial document-based app: a 
> window with a text view that can edit and save RTF files.
> 
> What I have now almost works, except that whenever I save changes, the text 
> view scrolls to the top.  Needless to say, this would be very annoying in a 
> real text-editing app.  I suspect it's something trivial about document-based 
> apps and/or bindings that I just don't understand.  Can someone explain 
> what's going on?

Following up... I found Apple's equivalent of what I was doing: 
.
  It doesn't use bindings.  When I followed the instructions the resulting app 
worked fine.

However, it bugged me that it has an ivar that sometimes is a copy, possibly 
out of date, of the text view's contents.  It seemed like unnecessary 
duplication of data to me, so I tweaked the example to use an NSTextStorage for 
the ivar, which it then plugs into the text view.  The resulting document class 
has fewer lines of code, even with the missing dealloc that I added.  And it 
doesn't need to be the delegate of the text view, so even the nib is a teeny 
bit simpler.

I can understand why Apple wouldn't use a bindings-based solution for this 
example, since bindings is an advanced topic unto itself, but I think using an 
NSTextStorage would be appropriate given the context.  Unless someone spots a 
fatal flaw, I'll submit it as a doc suggestion.

Here's the code I ended up with.  I never did figure out why my bindings-based 
app scrolls to the top.

--Andy


//  MyDocument.h

#import 

@interface MyDocument : NSDocument
{
NSTextStorage *mString;

IBOutlet NSTextView *textView;
}

@end



//  MyDocument.m

#import "MyDocument.h"

@implementation MyDocument

- (id)init
{
self = [super init];
if (self)
{
mString = [[NSTextStorage alloc] init];
}

return self;
}

- (void)dealloc
{
[mString release];

[super dealloc];
}

- (NSString *)windowNibName
{
return @"MyDocument";
}

- (void)windowControllerDidLoadNib:(NSWindowController *) aController
{
[super windowControllerDidLoadNib:aController];

if (mString)
{
[[textView layoutManager] replaceTextStorage:mString];
}
}

- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
{
[textView breakUndoCoalescing];

return [mString dataFromRange:NSMakeRange(0, [mString length])
   documentAttributes:[NSDictionary 
dictionaryWithObject:NSRTFTextDocumentType  
 
  
forKey:NSDocumentTypeDocumentAttribute]
error:outError];
}

- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError 
**)outError
{
[mString release];
mString = [[NSTextStorage alloc] initWithData:data
  options:nil
   documentAttributes:NULL
error:outError];

return (mString != nil);
}

@end

___

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

Please do not post 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 "set tab stops" in a UITextView?

2010-12-19 Thread Gordon Apple
Welcome to the lame world of UITextView.  No styles, no attributes.
Obviously, Apple, Inc. has something better, as shown in Pages, but they are
not sharing it with the rest of us.  Other than rolling your own with
CoreText (which I have partly done -- and it's not easy), the only
alternative I know of is Phitext , also based on CoreText,
but it's not free.  Hopefully, some future system upgrade will remedy this
deficiency.


On 12/19/10 2:01 PM, "cocoa-dev-requ...@lists.apple.com"
 wrote:

> I would like to be able to control what is displayed in a UITextView when the
> text contains a "tab" character.  (I conjecture that if there is a mechanism
> to do that, it might be common to both UITextView and NSTextView, so if anyone
> knows anything about the latter, please speak up.)
> 
> More specifically:
> 
> Testing suggests that when there are tab characters in a text string being
> displayed in a UITextView, the system behaves as if "tab stops" were set every
> eight characters; that is, the next character after a tab is displayed at the
> next horizontal position that would correspond to it being preceded by a
> number of blank spaces that is a multiple of eight.
>  
> Is there a way to make that position be a multiple of something other than
> eight?  I do not need the full generality of completely adjustable tab stops,
> I just want to be able to change "eight" to another value.
> 
> My work-around is to watch text as it is typed or pasted into the view and
> deal with tabs there, on my own, or I suppose that if I were a dedicated
> masochist I could in principle override a "draw" method somewhere, but it
> would be easier to use a built-in mechanism if there is one.
> 
> I posted a query about this in the forums, and I have of course googled the
> usual suspects.
> 
> Thanks.
> 
> --  Jay Reynolds Freeman



___

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

Please do not post 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 "set tab stops" in a UITextView?

2010-12-19 Thread Kyle Sluder
On Sun, Dec 19, 2010 at 4:01 PM, Gordon Apple  wrote:
> Welcome to the lame world of UITextView.  No styles, no attributes.
> Obviously, Apple, Inc. has something better, as shown in Pages, but they are
> not sharing it with the rest of us.  Other than rolling your own with
> CoreText (which I have partly done -- and it's not easy), the only
> alternative I know of is Phitext , also based on CoreText,
> but it's not free.  Hopefully, some future system upgrade will remedy this
> deficiency.

The rich text editor used in OmniGraffle and OmniGraphSketcher is
called OUIEditableFrame and is available as part of the Omni
Frameworks: 
https://github.com/omnigroup/OmniGroup/blob/master/Frameworks/OmniUI/iPad/OUIEditableFrame.h

Our license doesn't require you to pay us, but you should certainly
read it anyway: http://www.omnigroup.com/company/developer/

--Kyle Sluder
___

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

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

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

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


Re: NSTextView scrolls to top on Save

2010-12-19 Thread Kyle Sluder
On Sun, Dec 19, 2010 at 1:20 PM, Andy Lee  wrote:
> I can understand why Apple wouldn't use a bindings-based solution for this 
> example, since bindings is an advanced topic unto itself, but I think using 
> an NSTextStorage would be appropriate given the context.  Unless someone 
> spots a fatal flaw, I'll submit it as a doc suggestion.

The reason they didn't use bindings here is because it's not
appropriate for hooking up an NSTextStorage to an NSTextView.

Bindings (really, KVO) can't deal with mutable value types. In the
world of KVO, all changes mean that the actual object identity has
changed, not merely the value it contains.

NSTextViews can be used as editors for simple immutable NSString
properties, which is when using them with bindings is appropriate.

--Kyle Sluder
___

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

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

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

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


Re: NSTextView scrolls to top on Save

2010-12-19 Thread Andy Lee
On Dec 19, 2010, at 8:04 PM, Kyle Sluder wrote:
> On Sun, Dec 19, 2010 at 1:20 PM, Andy Lee  wrote:
>> I can understand why Apple wouldn't use a bindings-based solution for this 
>> example, since bindings is an advanced topic unto itself, but I think using 
>> an NSTextStorage would be appropriate given the context.  Unless someone 
>> spots a fatal flaw, I'll submit it as a doc suggestion.
> 
> The reason they didn't use bindings here is because it's not
> appropriate for hooking up an NSTextStorage to an NSTextView.

To be clear, my original version, with bindings, used an NSAttributedString 
(actually an NSMutableAttributedString, which may have confused matters; I 
should have used NSAttributedString for the ivar).

I introduced the NSTextStorage not because I expected it to work with bindings, 
but because I thought it was a design improvement to Apple's sample code.

> Bindings (really, KVO) can't deal with mutable value types. In the
> world of KVO, all changes mean that the actual object identity has
> changed, not merely the value it contains.

Indeed, the V in KVO refers to the object's identity and not its contents.  But 
if I go back to the bindings approach and turn on "Continuously Updates Value", 
I can see from NSLogs that the setter for the ivar gets called when I make any 
change to the text, even though the id of the ivar has not changed, only its 
content.  So NSTextView's attributedString binding seems designed to work the 
way I would want...

...*except* for that bit about scrolling to the top when I do a Save.  And I 
just discovered this only happens if the text view had first responder at the 
time of the Save.  If I select something else in the window and *then* do a 
Save, the text view stays right where it was.  I think this must be a bug.  
Unless someone can explain why it isn't, I'll file a Radar.

--Andy

___

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

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


Core Data mergeChangesFromContextDidSaveNotification: does not *completely* update the context ?

2010-12-19 Thread Aurélien Hugelé
Hi!

I think mergeChangesFromContextDidSaveNotification: does not work as most 
people expect:
I have a mainthread and a subthread. My subthread updates a managed object 
(change one of the property value) and save.
In the mainthread, I use [mainThreadContext 
mergeChangesFromContextDidSaveNotification:subThreadNotification]; and it 
merges the main thread context as expected (binded UI is updated)

What is not expected is :

1/ asking the main thread for its updatedObjects (just after the 
mergeChangesFromContext... but before the save:) does not show the changes made 
in the subthread! So updated objects in subthread are not seen as updated in 
the main thread after the mergeChangesFromContext call!
2/ Saving the main thread generates a did save notification, that does not 
contain changes made in the subthread (and merged) !

The subthread is temporary (does it job in an NSOperation that terminates 
quickly), its context is also temporary. 

In the mainthread, *many* controllers are observers of the did save 
notification of the main thread context. How am I supposed to make them listen 
to changes made in a temporary, dumb, subthreaded managed context without using 
mergeChangesFromContext... call ???

I'm pertty sure, most developers expect the 
mergeChangesFromContextDidSaveNotification: API to really merge the data in the 
main thread context and set the merged updated objects as *really* updated, as 
if the change really occured in the main thread!

Aurélien,
Objective Decision Team

___

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

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


UIWebview: scrolling vs anchors

2010-12-19 Thread Donald Hall
I have a UIWebview in my app that I want to use to load an HTML 
document containing anchors so that I can jump around the document by 
tapping on the links to the various anchors. (e.g. a link at the 
bottom of the page to jump to the top of the page)


I have the links and anchors working fine, except that for example 
when I am at the bottom of the page and tap on the link to jump to 
the top of the page, then scroll down from the top to the bottom, 
then tap the link to go to the top again, nothing happens. It's as if 
the webview thinks it is still at the top of the page.


Is there any way to get the webview to realize that the top of the 
page is no longer visible after scrolling? I tested this on my Mac 
with Safari, and scrolling does not affect the action of the link and 
anchor there.


Thanks for any help. I have spent several hours searching with no luck.

Don
--
Donald S. Hall, Ph.D.
Apps & More Software Design, Inc.
d...@appsandmore.com
http://www.appsandmore.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


UIBezierPath: trying to create an array with CGPointMake

2010-12-19 Thread colo
I'm in the processing of trying to create an array of Path points to
draw a UIBezierPath CGRectMake onto each control point.

Right now I am getting an error of
error: void value not ignored as it ought to be

I could totally be going about this the wrong way but until I know I
better I am trying to convert this
post from 
http://cocoawithlove.com/2008/07/coregraphics-curves-and-lines-sample.html
over to the ipad/iphone
Daunting for me but it's fun.



- (IBAction)resetControlPoints:(id)sender
{

UIBezierPath *path = [UIBezierPath bezierPath]; {
[path moveToPoint:CGPointMake(0,0)];
return path;
}
points[0] = [path moveToPoint:CGPointMake(30, 70)];
points[1] = [path moveToPoint:CGPointMake(30, 70)];
points[2] = [path moveToPoint:CGPointMake(30, 70)];
points[3] = [path moveToPoint:CGPointMake(30, 70)];

}
___

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

Please do not post 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: scrolling vs anchors

2010-12-19 Thread John Joyce

On Dec 20, 2010, at 12:08 AM, Donald Hall wrote:

> I have a UIWebview in my app that I want to use to load an HTML document 
> containing anchors so that I can jump around the document by tapping on the 
> links to the various anchors. (e.g. a link at the bottom of the page to jump 
> to the top of the page)
> 
> I have the links and anchors working fine, except that for example when I am 
> at the bottom of the page and tap on the link to jump to the top of the page, 
> then scroll down from the top to the bottom, then tap the link to go to the 
> top again, nothing happens. It's as if the webview thinks it is still at the 
> top of the page.
> 
> Is there any way to get the webview to realize that the top of the page is no 
> longer visible after scrolling? I tested this on my Mac with Safari, and 
> scrolling does not affect the action of the link and anchor there.
> 
> Thanks for any help. I have spent several hours searching with no luck.
> 
> Don
> -- 
Named anchors tend to appear in URLs...
might be a bug, but might not, think about logging and manipulating the URL...



___

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

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