Re: Faster adding of files to targets

2009-10-06 Thread Greg Guerin

Sorry, sent to wrong list.  Please ignore prior post.

  -- GG

___

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

Please do not post 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: CoreData async fetch request

2009-10-06 Thread Ben Trumbull


On Oct 5, 2009, at 7:00 PM, enki1...@gmail.com wrote:

I am doing a simple query search for a text string pattern (ie 'SELF  
like foo') on ~10 million small records stored persistently using  
sqlite. This is a performance test to make sure I get reasonable  
performance from my database engine before I commit too much code to  
it.


Well, @self like 'foo' is a different problem than @self like  
'*foo*'.  LIKE queries require Unicode compliant regex and are  
intrinsically expensive.  If you do not have a wildcard, you are  
better off use an == query.  The DerivedProperty ADC example shows how  
to transform the text to make it much faster to search.


If you do need to use a wildcard, you'll really want to stick with 1,  
either prefix matching or suffix matching.  The DerivedProperty  
example shows prefix matching.  It's possible to structure this to use  
a binary index, and make the query extremely fast even for millions of  
records.  There is a huge difference in computational complexity.   
Prefix matching can use an index, and therefore can run O(lg(N)).


*foo* (contains) searches are slow, and cannot use an index.  You  
really want to avoid these.  Even Spotlight does not do arbitrary  
substring matching.  Compare help with elp in your Spotlight  
results.  If you want word matching, you can use Spotlight or  
SearchKit to build a supplemental FTS index.


The query is taking over 3 minutes with a small result set. This is  
on a new 13 macbook pro w 4gb memory.


... a full table scan executing a regex on each of 10 million rows on  
a 5400 rpm drive ?  Well, for doing all that, 3 minutes sounds pretty  
fast.


Just as a reference point, if you grab the objectIDs from the result  
set, and execute an IN query selecting those objects, how long does it  
take ?  50ms ?  100ms ?


The query is taking too long for a user to sit and wait for it. Is  
there a way to speed it up? Can indexing be applied to it?


I had thought if I could display results as they are found that  
might be reasonable. In my tests, if I use setFetchBatchSize and  
setOffset to restart it, then it ends up repeating the query taking  
that many times longer to get a result. Not reasonable. It does not  
seem to start the query where it left off, as a database cursor  
would do.


You can use -com.apple.CoreData.SQLDebug 1 to see the SQL we pass to  
the database.  This also has nothing to do with Core Data.  This is  
how offset queries behave.  I realize it's not what you expected,  
which is why I recommended using -setFetchBatchSize: instead.


My impression is that my usage scenario is not an appropriate use of  
core data.


Core Data is just passing the query off to the database.  I'm not sure  
why you think going to the database directly will do anything for the  
179.9 / 180.0 seconds it takes to evaluate the query in the database.



I was planning to try SQLite directly. Would it be more appropriate?


You can try it directly, but it won't have any meaningful effect on  
your performance results except that SQLite's built in LIKE operator  
doesn't support Unicode.  It'll be a tiny bit faster for that, but  
still the same order of magnitude.  And then, either you'll have to  
integrate ICU support as Core Data does, and it'll be exactly the  
same, or be stuck with ASCII.


Regardless, you'll need to make your searches eligible for an index.   
The DerivedProperty example shows how to do that.


- Ben



Thanks

On Oct 5, 2009 7:14pm, Ben Trumbull trumb...@apple.com wrote:
 Is there a way to do an asynchronous fetch request against Core data
 returning partial results?

 That depends on whether it's the query part that's expensive (e.g.  
WHERE clause with complex text searching and table scans) or simply  
the quantity of the row data that's your problem.  For the latter,  
you can just use -setFetchBatchSize: and be done.



 You can use a separate MOC on a background thread to perform  
asynchronous work.  You can then pass over results to the main  
thread to display to the user.  However, unless your search terms  
are very expensive, it's usually easier and faster to use - 
setFetchBatchSize: synchronously.  For well indexed queries, it can  
handle a million or two rows per second.  Not sure why you'd subject  
your users to that kind of experience.  It's common to use fetch  
limits, count requests, and only show the top N results.  What's  
your user going to do with a hundred thousand results anyway ?



 If you need to attack the computational expense of your query  
terms, that's more complicated.  Obviously it would be best to  
optimize the queries and ensure they are using an index.  But if  
that's not enough, you can execute the queries in a background MOC,  
fetching objectIDs + row data (put in the the row cache) and then  
have the other MOC materialize the objects by ID from the row  
cache.  There's a BackgroundFetching example in /Developer/Examples/ 
CoreData.  It shows how to do 

[iPhone] WebView and problem with rotation

2009-10-06 Thread Bartosz Białecki
Hi,
I have a problem with rotation. I have one root controller which switch 
between two views. In one of these views I have a webview control. In 
webview I show a tif or pdf file which size is bigger than window, so 
webview added scroll. The problem is when I rotate a device to 
landscape, I change a size of webview but scroll stays at position like 
in portrait mode. Does anybody know why?

Best regards
Bartosz Bialecki


Wygraj wymarzony skuter!
Wyznacz najprostszą drogę - docelu.pl - Kliknij:
http://klik.wp.pl/?adr=http%3A%2F%2Fcorto.www.wp.pl%2Fas%2Fchapman1.htmlsid=863


___

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

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

2009-10-06 Thread Jeremy Pereira


On 6 Oct 2009, at 05:00, Dragos Ionel wrote:


I have the following scenario:
A UIViewController, called BookViewController represents a book.

Another UIViewController, ChapterViewController, represents a  
chapter in the

book.

BookViewController initializes and displays one  
ChapterViewController, that

represents the current chapter that is read.

The user moves through the pages of the chapter, back and forth. This
functionality belongs to ChapterViewController.

When the last page of the chapter is reached and the user tries to  
get to
the next page, the code inside the ChapterViewController has somehow  
to tell
the parent controller, BookViewController that it needs to be  
released and

another chapter to be initialized.


The short answer is to maintain a weak reference (i.e. non retained)  
to the BookViewController in the ChapterViewController and send a  
message to it when the chapter is finished.


However, you might consider separating the model and the controllers a  
bit more explicitly.  I would have a Book object which contains an  
ordered collection of Chapter objects as the model.  The  
ChapterViewController would have a reference to the book object and  
the chapter object it is currently displaying.  When the reader gets  
to the end of a chapter, the ChapterViewController would request the  
next chapter from the Book object and redisplay its view with the new  
chapter.





How can this be achieved?

Your help is appreciated.
Dragos
___

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

Please do not post 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/adc%40jeremyp.net

This email sent to a...@jeremyp.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/archive%40mail-archive.com

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


Re: NSOutlineView - Automatically select newly added item - Help needed

2009-10-06 Thread Corbin Dunn
Mario,

On Oct 5, 2009, at 4:44 PM, Mario Kušnjer wrote:

 Hello to the list !
 
 Request for help regarding a little problem.
 So I have this piece of code:
 
 - (IBAction)addNewItem:(id)sender
 {
   if ([lsOutlineView selectedRow]  0)
   {
   [sourceListLevelZero addObject:[Parent new]];
   [lsOutlineView reloadItem:nil reloadChildren:YES];
   [lsOutlineView expandItem:nil expandChildren:YES];
   [lsOutlineView selectRowIndexes:[NSIndexSet 
 indexSetWithIndex:[lsOutlineView rowForItem:[Parent new]]] 
 byExtendingSelection:NO];
   }
   ...
 }

In addition to what others said, your main misunderstanding is two things:

1. The outlineview identifies unique objects by the pointer address, not 
isEqual. Thus this line creates a new Parent object:

   [sourceListLevelZero addObject:[Parent new]];

and this line creates a new (different) Parent object:

 [lsOutlineView rowForItem:[Parent new]]]

2. I highly recommend reading up on memory management in Cocoa (unless you are 
creating a GC application). The [Parent new] lines are leaking memory. new is a 
shortcut for 'alloc/init' and returns a retained object.

corbin___

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

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

2009-10-06 Thread Michael Grant
You're aware, I hope, that self release is illegal in several southern states?

M
___

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

Please do not post 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: grouping undo across method calls in CoreData [with possible solutions]

2009-10-06 Thread Jim Thomason
Figured I'd address all the comments inline in one batch, and then
point out what I came up with. An almost viable solution is up top for
reference purposes, and a seemingly better one is towards the bottom.

Hm, do operations using primitive accessors also get registered on the undo 
stack? If not, you could maybe use that approach, so the setting of the 
ordered value would not ever get registered?

This actually worked in that I didn't end up with the extra undo
into the interim state, but the array controller put the objects into
the wrong row. My array controller was sorted on the ordered value,
and by setting it through the primitives, the notes never fired to
re-sort it. Firing the KVO notes myself fixed it, but that also added
an empty frame onto the stack again, so back to square one.

I was able to make this work by subclassing NSArrayController and
overriding addObject: to fetch immediately afterwards.

-(void) addObject:(id) newObject {
  [super addObject:newObject];
  [self fetch:nil];
}

In fact, using this approach, I didn't need to detach the selector at
all and could just set the value in awakeFromInsert:, though I don't
have any idea if not detaching and setting it directly is going to
cause other bad problems. But, there's a slight visual hiccup
sometimes using this approach - When I tried integrating it into my
actual app, you could briefly see both items appear and then one
vanish. As a result, I'm not thrilled with using this approach.

Also note that it wouldn't scale well, since it'd cause a refetch of
the entire array's contents upon every insert. Fortunately, I have
fairly small object sets, so this may be viable for me.

I hope I list a better idea at the end of this email.

I guess it is tricky dealing with begin/endUndoGrouping when using delayed 
invoking. Still, AFAIK it should work. Can you elaborate on why it does not?

I don't remember exactly what was happening with it, I could make it
crash, but haven't been able to reproduce in simplified test cases so
I'm assuming the error existed elsewhere. Regardless in further
testing, if I begin/end in the method performed after the delay, it
has no effect and I still need to do it in two steps. If I begin in
awake from insert and end in the method after the delay, I get the
duplicate row on the array controller.

I also tried popping all references to the newly created object off
the stack and using prepareWithInvocationTarget: with a method that
just drops the object:
Which extra undo state do you have? What is the registered undo that does 
nothing?

The problem was that the object's creation apparently creates two
separate sets of undo information - one for the object itself, and one
for its managed object context. I remove the undo actions for the
object, but can undo twice because one undo calls my prepared
invocation, and the second undo undoes the object add that the context
performed.

That's also why I can now redo twice and create a ghost object - my
object is recreated, but the managed object context also redoes its
object insertion, so it shows up as a default object with no post-set
values. Further, I refer to it as a ghost since it doesn't actually
exist - if you save the document and re-open it, the ghost vanishes.

If I try to use the undo manager to remove all actions on the context
(a dangerous action anyway, since I'm not sure what other existing
actions may be there), I can still undo twice. But this time, once the
doc is back in its clean newly opened state, the context still lists
the ghost as being deleted. An attempt to save here causes the app to
crash, which makes sense, since it'd be attempting to delete a
non-existent object.

I haven't a clue if it's possible to make this technique work.


You might consider a different approach. Instead of trying to bend Core Data 
undo to your will, you might be able to finesse the situation by preparing 
all the information for your object creation *first*, then creating the object 
in a single event cycle (and hence undo action).

I considered this...but that would then require a lot of management
outside of creation to ensure that I'm keeping this cached calculated
value in sync with reality. Including making sure that the cached
value is incremented upon object insertion, and properly decremented
upon deletion (it's decremented only if you delete the highest order
object - if you delete something in the middle, we end up with a hole
in the order, but that's okay, we just keep marching ever upward). So
that would've meant finding places to add hooks for add and delete and
just generally seemed like a mess. I'm pretty sure I would've needed
an additional method call before all deletions, as per an earlier
thread of mine about coredata pre-delete hooks.

===

But, through all of that, I may actually have a viable solution - I
subclassed NSArrayController and added createOrder to my addObject:
method there:

@implementation MyArrayController

-(void) addObject:(id) 

Re: NSOutlineView - Automatically select newly added item - Help needed

2009-10-06 Thread Mario Kušnjer

Hi all !

Thanks for your replies everybody !
I have reviewed my code according to yours inputs and I found where  
the problem was.

Here's the reviewed code:

if ([lsOutlineView selectedRow]  0)
{
Parent *parent = [Parent new];  --- create new Parent 
object
NSLog(@1 - %@, parent);

		[sourceListLevelZero addObject:parent];		---	add newly created  
Parent object to the root array
		[lsOutlineView reloadItem:nil reloadChildren:YES];		---	reload  
outline view


		NSUInteger index = [lsOutlineView rowForItem:parent];		---	get the  
row index of the newly created Parent object from the outline view

NSLog(@2 - %i, index);

		NSMutableIndexSet *indexSet = [NSMutableIndexSet new];		---	create  
new empty NSMutableIndexSet object

NSLog(@3 - %@, indexSet);

		[indexSet addIndex:index];		---	add row index of the Parent object  
to the indexSet

NSLog(@4 - %@, indexSet);

		[lsOutlineView expandItem:nil expandChildren:YES];		---	expand the  
root array objects and all of their children
		[lsOutlineView selectRowIndexes:indexSet byExtendingSelection:NO];		 
---	select row with index number from the indexSet without multiple  
row selection


[parent release];   --- release parent object
[indexSet release]; --- release indexSet
}

I assume this is correct way now because it works fine.
If someone has some objections, please state your comment, I am  
interested to hear (learn).


I will (when I make this code actually do something useful) post a  
link to the list for the entire source code so anyone interested to  
review it (and point out my mistakes) will

be most welcome.
Since I have no idea how to use Instruments (and until I do) this will  
be very helpful to me in future learning.


Thanks again.
Bye !


Mario Kušnjer
mario.kusn...@sb.t-com.hr
+385957051982
mariokusn...@skype

___

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

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


Applying temporaryAttributes from processEditing (_fillGlyphHoleForCharacterRange: crash)

2009-10-06 Thread Keith Blount
Hello,

I’m attempting to add temporary attributes (all of which do not require layout) 
to text as soon as it has been edited if it has a custom attribute applied 
(much how the text system automatically applies linkTextAttributes to any text 
with an NSLinkAttributeName attribute - although from my various tests and 
NSLogging it seems that the text system does that under the hood using some 
internal magic and doesn’t use temporary attributes). In another thread on a 
related issue Aki Inoue was kind enough to point out that I could override 
NSLayoutManager’s -showPackedGlyphs:etc... to change the colour of the text, 
but that doesn’t handle underlines or strikethroughs, for which I still need to 
apply temporary attributes.

My current solution is to try to override my custom text storage’s 
-processEditing method to iterate through the layout managers and apply any 
necessary temporary attributes there, something like this:

- (void)processEditing
{
[super processEditing];

NSRange dirtyRange = [self editedRange];
if (dirtyRange.length == 0)
return;

NSEnumerator *e = [[self layoutManagers] objectEnumerator];
NSLayoutManager *lm;
while (lm = [e nextObject])
{
if (dirtyRangeHasMyCustomAttribute)
[lm addTemporaryAttributes:tempAttribs 
forCharacterRange:dirtyRange];
}
}

However, the above has massive problems. In certain circumstances it causes 
this crash:

-[KBLayoutManager 
_fillGlyphHoleForCharacterRange:startGlyphIndex:desiredNumberOfCharacters:] *** 
attempted glyph generation while textStorage is editing.  It is not valid to 
cause the layoutManager to do glyph generation while the textStorage is editing 
(ie the textStorage has been sent a beginEditing message without a matching 
endEditing.)

I’m not entirely sure why, as I’ve NSLogged all of the beginEditing and 
endEditing messages and this code is only ever call after the last -endEditing, 
so beginEditing and endEditing should are matching (I even tested it out by 
putting it into -endEditing and processing things only after calling [super 
endEditing] but had the same crash).

I can avoid the crash by putting the temporary attribute application code into 
a separate method and calling it after a zero delay like this:

- (void)processEditing
{
[super processEditing];

[self performSelector:@selector(applyTempAttributesIfNecessaryToRange:) 
withObject:[NSValue valueWithRange:[self editedRange] afterDelay:0];
}

But this seems fragile to me. I’m not entirely sure why calling the same code 
after a delay of 0 would prevent the crash, or confident that it will work in 
all situations.

Has anyone tried to do something similar and found a better solution to what 
I’m trying to do?

Many thanks in advance and all the best,
Keith



___

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

Please do not post 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: NSLayoutManager and best override point for temporary attributes

2009-10-06 Thread Ross Carter

On Oct 5, 2009, at 3:12 PM, Keith Blount wrote:

I tried saving the edited range of text in the text storage and then  
having my layout manager check this from:


-textStorage:edited:range:changeInLength:invalidatedRange:

Then my layout manager adds temp attribs in this method. Turns out  
that this is a Bad Thing (which I should have realised beforehand),  
as it can cause glyph generation before the text storage has ended  
editing. D'oh.


I haven't tried fixing temporary attributes in NSTextStorage - 
fixFontAttributeInRange:, but that might be worth a try.


Ross
___

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

Please do not post 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: NSOutlineView - Automatically select newly added item - Help needed

2009-10-06 Thread Mario Kušnjer

Again me !
Just a little update !
I packed previous code in combined message calls.
Here's how it looks now:

if ([lsOutlineView selectedRow]  0)
{
Parent *parent = [Parent new];  --- create new Parent 
object
		[sourceListLevelZero addObject:parent];		---	add newly created  
Parent object to root array

[lsOutlineView reloadItem:nil reloadChildren:YES];
[lsOutlineView expandItem:nil expandChildren:YES];  
		[lsOutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex: 
[lsOutlineView rowForItem:parent]] byExtendingSelection:NO];		---	 
select row according to index from indexSet created with row index of  
outline view for item - parent

[parent release];   --- release Parent object
}

Again this works fine.
Ok, that's it.
Bye !


Mario Kušnjer
mario.kusn...@sb.t-com.hr
+385957051982
mariokusn...@skype

___

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

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


Triggering a Method when a Core Data Property is Altered.

2009-10-06 Thread Joshua Garnham
Hi.

I am trying to trigger a method when A Core Data property is changed, e.g A 
Text Fields Text in a Table (connected to Core Data) is changed. I have looked 
into Key Value Observing but haven't had much luck.

Cheers.




___

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

Please do not post 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: Xcode 3.2 and NSTextField exceptions

2009-10-06 Thread albert jordan Mobility

Thanks a lot Jens,

Appologies, I thought I did post it on a different list.

regards,

Albert
On Oct 6, 2009, at 7:46 AM, Jens Alfke wrote:



On Oct 6, 2009, at 7:39 AM, albert jordan Mobility wrote:

I just upgraded to Snow Leopard and Xcode 3.2, and I'm having a  
number of problems.


You should post this to cocoa-dev, since it's an AppKit issue, not  
Xcode. This sounds like your app is doing something that's not  
compatible with 10.6.


2009-10-06 07:26:10.652 SkypeAPITest[3761:8503] Exception Unlocking  
Focus on wrong view (NSTextField: 0x418db0), expected NSView:  
0x43e690 raised during heart beat. Ignoring


Set a breakpoint (Run  Stop On Objective-C Exceptions) and see what  
the backtrace of the exception looks like, that could be a clue.


2009-10-06 07:27:26.594 SkypeAPITest[3761:8503] Exception NSImage:  
Insufficient memory to allocate pixel data buffer of 1480320 bytes  
raised during heart beat. Ignoring


This sounds like the app is leaking memory, likely because of the  
first exception.


—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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Launching and application in 32-bit in Leopard

2009-10-06 Thread John Horigan
Does Leopard provide a means for controlling whether an application  
launches in 32-bit or 64-bit? Snow Leopard has the new NSWorkspace  
method launchApplicationAtURL:options:configuration:error:


But I can't find an equivalent method that works for OS X 10.5. How  
did XCode do it?


-- john horigan
___

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

Please do not post 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: Launching and application in 32-bit in Leopard

2009-10-06 Thread Sean McBride
On 10/6/09 10:36 AM, John Horigan said:

Does Leopard provide a means for controlling whether an application
launches in 32-bit or 64-bit? Snow Leopard has the new NSWorkspace
method launchApplicationAtURL:options:configuration:error:

See 'man arch' for one way.

--

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com
Mac Software Developer  Montréal, Québec, Canada


___

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

Please do not post 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: Triggering a Method when a Core Data Property is Altered.

2009-10-06 Thread Volker in Lists

Josh,

depending on where you need to get a notification:

a) within the same NSManagedObject or a relationship: 
http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Protocols/NSKeyValueObserving_Protocol/Reference/Reference.html#//apple_ref/occ/clm/NSObject/keyPathsForValuesAffectingValueForKey:

b) in any other object: just register as observer as described in KVO  
basics: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/KeyValueObserving/Concepts/KVOBasics.html


Take note: The triggering happens not on the change of the  
TextFieldCell in a table, but due to a property changing.


When you have looked into KVO - what have you tried already?


Cheers,
Volker

Am 06.10.2009 um 18:45 schrieb Joshua Garnham:


Hi.

I am trying to trigger a method when A Core Data property is  
changed, e.g A Text Fields Text in a Table (connected to Core Data)  
is changed. I have looked into Key Value Observing but haven't had  
much luck.


Cheers.




___

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

Please do not post 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/volker_lists%40ecoobs.de

This email sent to volker_li...@ecoobs.de


___

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

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

2009-10-06 Thread Andy Lee

On Oct 6, 2009, at 10:52 AM, Michael Grant wrote:
You're aware, I hope, that self release is illegal in several  
southern states?


See #8: http://www.sticksoftware.com/developer/cocoajoke.html.

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


NSSecureTextField - changing the default bullets to ****

2009-10-06 Thread Arun
Hi All,

I am using NSSecureTextField for entering the password.
Is there any way by which i can make the SecureTextCell to display
 instead of default solid circle bullets?

Thanks
Arun
___

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

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


Constructive Criticism

2009-10-06 Thread Mick Walker

Hi everyone,

I am currently reading through Learn Objective-C on the Mac (M  
Dalrymple  S Knaster). While working through the provided examples, I  
want to back up what I am learning by attempting to put into practice  
what is being demonstrated to me.


To this end, I would like to post some of my own code, to get  
feedback, basically to find out if I am doing things correctly, and if  
not, why not; especially in the realms of memory management (I think I  
understand the concept, but I want to reaffirm it).


The first program I tried to write, is a simple console program which  
uses math to calculate the date of easter for a given year, my code is  
below:


--- Easter.h ---
#import Cocoa/Cocoa.h


@interface Easter : NSObject {
int Year;
}
- (id) init;

- (void) setYear: (int) year;

- (void) CalculateYear;

@end


--- Easter.m ---
#import Easter.h


@implementation Easter

- (id) init {
if(self == [super init]){
Year = 0;
orignalYear = 0;
}
return (self);
}

-(void) setYear: (int) year {
Year = year;
orignalYear = year;
}

- (void) CalculateYear {
if(Year == 0){
NSLog(@Error: No Year Specified);   
}
int day;
int month;

int g = Year % 19;
int c = Year / 100;
int h = h = (c - (int)(c / 4) - (int)((8 * c + 13) / 25) + 19 * g  
+ 15) % 30;
int i = h - (int)(h / 28) * (1 - (int)(h / 28) * (int)(29 / (h +  
1)) * (int)((21 - g) / 11));


day= i - ((Year + (int)(Year / 4) + i + 2 - c + (int)(c /  
4)) % 7) + 28;

month= 3;

if (day  31)
{
month++;
day -= 31;
}
	NSLog(@The date of Easter sunday in the year %d is %d/%d/%d, Year,  
day, month,Year);

}

- (void) dealloc {

[super dealloc];
}

@end

--- Easter Calculator.m ---
#import Foundation/Foundation.h
#import Easter.h


int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

Easter *myEaster = [[Easter alloc]init];

[myEaster setYear:2010];
[myEaster CalculateYear];
[myEaster release];
[pool drain];
return 0;
}

As I mentioned before, all criticism is welcome. If what I have wrote  
is dire, feel free to flame me.


Regards
Mick
___

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

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

2009-10-06 Thread Bill Bumgarner

On Oct 6, 2009, at 2:26 PM, Mick Walker wrote:
 #import Cocoa/Cocoa.h
 @interface Easter : NSObject {
   int Year;
int year;
 }
 - (id) init;
 
 - (void) setYear: (int) year;
@property int year;
 
 - (void) CalculateYear;
- (void) calculateYear;
 
 @end
 
 
 --- Easter.m ---
 #import Easter.h
 
 
 @implementation Easter
@synthesize year;
   
 - (id) init {
   if(self == [super init]){
   Year = 0;
   orignalYear = 0;
   }
   return (self);
 }
 

-- delete --
 -(void) setYear: (int) year {
   Year = year;
   orignalYear = year;
 }
-- end delete --

 
 - (void) CalculateYear {
- (void) calculateYear {
   if(Year == 0){
if (self.year == 0) {
   NSLog(@Error: No Year Specified); 
@throw ... some kind of fatal exception ...
Or, if it is recoverable, switch this to using the (NSError **) pattern 
pervasive to Cocoa
   }
   int day;
   int month;


int localYear = self.year;

s/Year/localYear/ throughout the following chunk o' code.
   
int g = Year % 19;
int c = Year / 100;
int h = h = (c - (int)(c / 4) - (int)((8 * c + 13) / 25) + 19 * g + 15) % 
 30;
int i = h - (int)(h / 28) * (1 - (int)(h / 28) * (int)(29 / (h + 1)) * 
 (int)((21 - g) / 11));
   
day= i - ((Year + (int)(Year / 4) + i + 2 - c + (int)(c / 4)) % 7) 
 + 28;
month= 3;
   
if (day  31)
{
month++;
day -= 31;
}
   NSLog(@The date of Easter sunday in the year %d is %d/%d/%d, Year, 
 day, month,Year);
 }
 
 - (void) dealloc {

if there is nothing to release or do in -dealloc, skip the implementation 
entirely.

   
   [super dealloc];
 }
 
 @end
 
 --- Easter Calculator.m ---
 #import Foundation/Foundation.h
 #import Easter.h
 
 
 int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
 
Easter *myEaster = [[Easter alloc]init];
   
   [myEaster setYear:2010];
   [myEaster CalculateYear];
[myEaster calculateYear];
   [myEaster release];
[pool drain];
return 0;
 }

I'd also consider renaming calculateYear to something like -easterSunday.  
Something like:

- (NSDate *) easterSunday;

Then calculate and return the date object, to be processed, managed, or output 
by the caller.  It makes the Easter class slightly thinner and considerably 
more reusable.

b.bum

___

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

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

2009-10-06 Thread Dave Carrigan


On Oct 6, 2009, at 2:26 PM, Mick Walker wrote:


Hi everyone,

I am currently reading through Learn Objective-C on the Mac (M  
Dalrymple  S Knaster). While working through the provided examples,  
I want to back up what I am learning by attempting to put into  
practice what is being demonstrated to me.


To this end, I would like to post some of my own code, to get  
feedback, basically to find out if I am doing things correctly, and  
if not, why not; especially in the realms of memory management (I  
think I understand the concept, but I want to reaffirm it).


The first program I tried to write, is a simple console program  
which uses math to calculate the date of easter for a given year, my  
code is below:


--- Easter.h ---
#import Cocoa/Cocoa.h


@interface Easter : NSObject {
int Year;


The usual convention is to use lowercase for member names. If you  
follow the convention, then your class will support key-value coding  
for free.



}
- (id) init;

- (void) setYear: (int) year;


You don't have a corresponding getter such as

- (int)year;

In addition, I would declare this as a property:

@property int year;

That gives you -setYear: and -year for free.


- (void) CalculateYear;


The usual convention is to start selector names with a lowercase letter:

- (void)calculateYear;

From a design perspective, I would make calculateYear return a  
NSDate; it makes the class more flexible for future use.




@end


I would also consider declaring a designated initializer of

- (id)initWithYear:(int)theYear;

Especially since it seems that a year of 0 is not allowed, so callers  
will always need to be doing setYear after initialization.





--- Easter.m ---
#import Easter.h


@implementation Easter

- (id) init {
if(self == [super init]){


This is just wrong, it should be

if (self = ([super init])) {

You're using the comparison operator instead of the assignment  
operator. It's also quite an insidious bug, because it will usually  
work, except in cases where [super init] returns some other pointer  
than self.




Year = 0;
orignalYear = 0;


I didn't see a decl for originalYear anywhere.


}
return (self);
}

-(void) setYear: (int) year {
Year = year;
orignalYear = year;
}


If you used properties, you could replace this with

@synthesize year;

I'm not sure what that originalYear variable is there for.



- (void) CalculateYear {
if(Year == 0){
NSLog(@Error: No Year Specified);   
}
int day;
int month;

   int g = Year % 19;
   int c = Year / 100;
   int h = h = (c - (int)(c / 4) - (int)((8 * c + 13) / 25) + 19 * g  
+ 15) % 30;
   int i = h - (int)(h / 28) * (1 - (int)(h / 28) * (int)(29 / (h +  
1)) * (int)((21 - g) / 11));


   day= i - ((Year + (int)(Year / 4) + i + 2 - c + (int)(c /  
4)) % 7) + 28;

   month= 3;

   if (day  31)
   {
   month++;
   day -= 31;
   }
	NSLog(@The date of Easter sunday in the year %d is %d/%d/%d,  
Year, day, month,Year);

}

- (void) dealloc {

[super dealloc];
}

@end

--- Easter Calculator.m ---
#import Foundation/Foundation.h
#import Easter.h


int main (int argc, const char * argv[]) {
   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

   Easter *myEaster = [[Easter alloc]init];

[myEaster setYear:2010];
[myEaster CalculateYear];
[myEaster release];
   [pool drain];
   return 0;
}

As I mentioned before, all criticism is welcome. If what I have  
wrote is dire, feel free to flame me.


--
Dave Carrigan
d...@rudedog.org
Seattle, WA, USA

___

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

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

2009-10-06 Thread Alastair Houghton

In addition to Bill's comments, which covered most things I think...

On 6 Oct 2009, at 22:26, Mick Walker wrote:


   int g = Year % 19;
   int c = Year / 100;
   int h = h = (c - (int)(c / 4) - (int)((8 * c + 13) / 25) + 19 * g  
+ 15) % 30;
   int i = h - (int)(h / 28) * (1 - (int)(h / 28) * (int)(29 / (h +  
1)) * (int)((21 - g) / 11));


   day= i - ((Year + (int)(Year / 4) + i + 2 - c + (int)(c /  
4)) % 7) + 28;


You *do* know that in C the / operator will do *integer* division  
unless one of the quantities is floating point, right?  So there's no  
need for all of those (int) casts.


And I'd be inclined to give my variables meaningful names, rather than  
g, c, h and i...


Oh, and since I'm in the dot-syntax-is-evil camp, s/self.year/[self  
year]/g in Bill's code :-D :-D


Of course, not everyone agrees with me on that (there are many  
respected developers on both sides of the argument), but I *intensely*  
dislike the fact that the syntax looks like member variable access  
(though if you look closely, of course, it becomes apparent that it  
isn't) while simultaneously sending messages---which can in general  
have side effects.


(As you've probably realised by now, a lot of the changes being  
suggested are stylistic.)


Kind regards,

Alastair.

--
http://alastairs-place.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/archive%40mail-archive.com

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


Re: NSSecureTextField - changing the default bullets to ****

2009-10-06 Thread Alastair Houghton

On 6 Oct 2009, at 19:24, Arun wrote:


I am using NSSecureTextField for entering the password.
Is there any way by which i can make the SecureTextCell to display
 instead of default solid circle bullets?


And thereby make your application inconsistent with the platform?

Why would you want to do this?  (Being consistent with an  
application on another platform is not a good enough reason; Mac apps  
should look and feel like Mac apps, just as Windows apps should look  
and feel like Windows apps, and so on...)


Kind regards,

Alastair.

--
http://alastairs-place.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/archive%40mail-archive.com

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


Re: Constructive Criticism

2009-10-06 Thread Mick Walker

Hi Dave,

Thank you for you're reply.

One question: If I was to create an initializer such as the one you  
suggested. Would I still need the if(self =([super init]))... in the  
initializer?


Regards.

On 6 Oct 2009, at 22:43, Dave Carrigan wrote:



On Oct 6, 2009, at 2:26 PM, Mick Walker wrote:


Hi everyone,

I am currently reading through Learn Objective-C on the Mac (M  
Dalrymple  S Knaster). While working through the provided  
examples, I want to back up what I am learning by attempting to put  
into practice what is being demonstrated to me.


To this end, I would like to post some of my own code, to get  
feedback, basically to find out if I am doing things correctly, and  
if not, why not; especially in the realms of memory management (I  
think I understand the concept, but I want to reaffirm it).


The first program I tried to write, is a simple console program  
which uses math to calculate the date of easter for a given year,  
my code is below:


--- Easter.h ---
#import Cocoa/Cocoa.h


@interface Easter : NSObject {
int Year;


The usual convention is to use lowercase for member names. If you  
follow the convention, then your class will support key-value coding  
for free.



}
- (id) init;

- (void) setYear: (int) year;


You don't have a corresponding getter such as

- (int)year;

In addition, I would declare this as a property:

@property int year;

That gives you -setYear: and -year for free.


- (void) CalculateYear;


The usual convention is to start selector names with a lowercase  
letter:


- (void)calculateYear;

From a design perspective, I would make calculateYear return a  
NSDate; it makes the class more flexible for future use.




@end


I would also consider declaring a designated initializer of

- (id)initWithYear:(int)theYear;

Especially since it seems that a year of 0 is not allowed, so  
callers will always need to be doing setYear after initialization.





--- Easter.m ---
#import Easter.h


@implementation Easter

- (id) init {
if(self == [super init]){


This is just wrong, it should be

if (self = ([super init])) {

You're using the comparison operator instead of the assignment  
operator. It's also quite an insidious bug, because it will usually  
work, except in cases where [super init] returns some other pointer  
than self.




Year = 0;
orignalYear = 0;


I didn't see a decl for originalYear anywhere.


}
return (self);
}

-(void) setYear: (int) year {
Year = year;
orignalYear = year;
}


If you used properties, you could replace this with

@synthesize year;

I'm not sure what that originalYear variable is there for.



- (void) CalculateYear {
if(Year == 0){
NSLog(@Error: No Year Specified);   
}
int day;
int month;

  int g = Year % 19;
  int c = Year / 100;
  int h = h = (c - (int)(c / 4) - (int)((8 * c + 13) / 25) + 19 * g  
+ 15) % 30;
  int i = h - (int)(h / 28) * (1 - (int)(h / 28) * (int)(29 / (h +  
1)) * (int)((21 - g) / 11));


  day= i - ((Year + (int)(Year / 4) + i + 2 - c + (int)(c /  
4)) % 7) + 28;

  month= 3;

  if (day  31)
  {
  month++;
  day -= 31;
  }
	NSLog(@The date of Easter sunday in the year %d is %d/%d/%d,  
Year, day, month,Year);

}

- (void) dealloc {

[super dealloc];
}

@end

--- Easter Calculator.m ---
#import Foundation/Foundation.h
#import Easter.h


int main (int argc, const char * argv[]) {
  NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

  Easter *myEaster = [[Easter alloc]init];

[myEaster setYear:2010];
[myEaster CalculateYear];
[myEaster release];
  [pool drain];
  return 0;
}

As I mentioned before, all criticism is welcome. If what I have  
wrote is dire, feel free to flame me.


--
Dave Carrigan
d...@rudedog.org
Seattle, WA, USA



___

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

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

2009-10-06 Thread Bill Bumgarner

On Oct 6, 2009, at 3:08 PM, Mick Walker wrote:

 One question: If I was to create an initializer such as the one you 
 suggested. Would I still need the if(self =([super init]))... in the 
 initializer?

Yes.

___

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

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

2009-10-06 Thread Kyle Sluder
On Tue, Oct 6, 2009 at 3:08 PM, Mick Walker mick.wal...@me.com wrote:
 One question: If I was to create an initializer such as the one you
 suggested. Would I still need the if(self =([super init]))... in the
 initializer?

You *always* need to call super's initializer, check its return value,
and assign it to self.

--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: [Performance issue] Resizing an alert sheet = blinks

2009-10-06 Thread Iceberg-Dev


On Oct 6, 2009, at 1:29 AM, Jens Alfke wrote:



On Oct 5, 2009, at 3:12 PM, Iceberg-Dev wrote:

Is it the intended behavior that resizing an Alert Sheet in Mac OS  
X 10.5.8 on a MacBook Pro produces a lot of blinking?
I have a custom alert sheet that can be resized and when I resize  
it on a MacBook Pro (either 9400 or 9600 GPU), the resize  
operation produces flicking.


No, it should be smooth.
Is the entire sheet window appearing and disappearing, or just the  
contents?


The contents. It's a bit as if there was a patchwork of rectangles  
and a random set of these rectangles would not be redrawn when the  
window size increases by 1 pixel and then another set for the  
following pixel.


I used Quartz Debug to check that there was not too much refresh and  
it looks fine.


I tried both with a 64 bit executable and a 32 bit executable.

Finally, I tried running the same code on Snow Leopard on the same  
MacBook and it's working correctly there. So definitely an issue with  
Leopard.


Is anything being logged to the console while resizing, like error/ 
exception messages?


Nope.

___

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

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


disabling Open Recent menu items

2009-10-06 Thread kvic...@pobox.com
i need to disable opening any files via the Open Recent menu items 
until the user has specified some information that i save in my app's 
prefs. this situation can occur if the user has deliberately or 
accidentally deleted the prefs. now, i can (and do) override 
-[NSDocumentController openDocumentWithContentsOfURL:display:error:] 
which takes care of the situation in which the user double clicks a 
file in the finder.


however, in addition to this, i would like to dim/disable any files 
that happen to be in the Open Recents file (sub-)menu. for the time 
being, i'm overriding -[NSDocumentController validateMenuItem:] and 
seeing if the action for the passed in menuItem is 
_openRecentDocument:. but since this is an undocumented api, i prefer 
to accomplish this in a more legal manner, but i don't know what 
that is.


can anyone suggest a legal way to disable the items in the Open 
Recent menu?


thanx,
ken

___

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

Please do not post 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: [Performance issue] Resizing an alert sheet = blinks

2009-10-06 Thread Jens Alfke


On Oct 6, 2009, at 3:29 PM, Iceberg-Dev wrote:

The contents. It's a bit as if there was a patchwork of rectangles  
and a random set of these rectangles would not be redrawn when the  
window size increases by 1 pixel and then another set for the  
following pixel.


That sounds like a graphics driver problem. Have you made sure you  
have the latest firmware updates on that particular machine? (IIRC,  
there were bugs in the drivers for some of the graphics cards used on  
Mac Pros.)


—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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


class variables

2009-10-06 Thread Colin Howarth

Hi,

I'm coming across the odd instance where the use of a class variable  
would seem to make sense.


I can do this with a static definition in the class implementation  
file, I suppose.


Question is: is this particularly frowned upon in the Cocoa world? If  
so, why?


Thanks,

--colin
___

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

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

2009-10-06 Thread Luke the Hiesterman
The canonical implementation of a singleton class uses a static to  
hold the singleton instance. There are other examples in Apple sample  
code of using class statics. So, I would say that it's not frowned  
upon as long as there's a good reason to do it.


Luke

On Oct 6, 2009, at 4:48 PM, Colin Howarth wrote:


Hi,

I'm coming across the odd instance where the use of a class variable  
would seem to make sense.


I can do this with a static definition in the class implementation  
file, I suppose.


Question is: is this particularly frowned upon in the Cocoa world?  
If so, why?


Thanks,

--colin
___

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

Please do not post 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/luketheh%40apple.com

This email sent to luket...@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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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


Re: class variables

2009-10-06 Thread Bill Bumgarner

On Oct 6, 2009, at 4:48 PM, Colin Howarth wrote:
 I'm coming across the odd instance where the use of a class variable would 
 seem to make sense.
 
 I can do this with a static definition in the class implementation file, I 
 suppose.
 
 Question is: is this particularly frowned upon in the Cocoa world? If so, why?

Static variables within the scope of the file are the way to go.  It isn't 
particularly frowned upon, but initialization can sometimes be tricky.   As 
well, global variables are generally an impediment to subsequent refactoring;  
what if you want two distinct and isolated subsystems that would then need 
their own distinct versions of the globals, for example?

b.bum

___

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

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

2009-10-06 Thread Colin Howarth

On 7 Oct, 2009, at 01:53, Bill Bumgarner wrote:

On Oct 6, 2009, at 4:48 PM, Colin Howarth wrote:
I'm coming across the odd instance where the use of a class  
variable would seem to make sense.


I can do this with a static definition in the class implementation  
file, I suppose.


Question is: is this particularly frowned upon in the Cocoa world?  
If so, why?


Static variables within the scope of the file are the way to go.  It  
isn't particularly frowned upon, but initialization can sometimes be  
tricky.


OK. Thanks Bill (and Luke).

As well, global variables are generally an impediment to subsequent  
refactoring;


Not likely to be a problem in the present case.

what if you want two distinct and isolated subsystems that would  
then need their own distinct versions of the globals, for example?


You'd have to do a global search and replace, I suppose? :-)



___

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

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


Problem using filewrappers under snow leopard

2009-10-06 Thread Eagle Offshore
And it is maddening because the error occurs outside my code.  My  
document class implements


- (NSFileWrapper *)fileWrapperOfType:(NSString *)aType error: 
(NSError**)errPtr


and this gets called fine.  It returns a new NSFileWrapper.  It has  
been working perfectly since Tiger (this app targets 10.4).


The return line is

return [[NSFileWrapper alloc]  
initDirectoryWithFileWrappers:fileWrappers];


where fileWrappers is an NSMutableDictionary of filename-NSData's.

In Snow Leopard, this gets called and executes to completion.   
However, the writing of the filewrapper to the disk fails and an alert  
sheet is presented The document Untitled could not be saved as New  
Document Name.


I haven't a clue why. No console message.  No exception is raised.   
Nothing.  It JUST DOESN'T WORK.  Although it works fine under earlier  
versions of the OS.


How am I supposed to diagnose this?

-Todd Blanchard

___

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

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


Suggest reasons for this crash?

2009-10-06 Thread Graham Cox

Hi all,

I'm getting a crash report from one user who has experienced the  
following crash more than once. No other user is reporting this so  
far. The crash is down in the text editing engine and I'm not sure  
what I should be looking at in my usage of this code that could be  
causing it. Suggestions welcome.


My first instinct is that the text view has been released and that I'm  
messaging a stale pointer, but if that's the case I can't see how the  
code could have made it as far as it has. Besides, the text view is  
retained by another object for as long as it lives - it's only  
released in -dealloc. I've checked that there are no other releases or  
autoreleases on it.


0   libobjc.A.dylib 0x9561991b objc_msgSend + 27
1   libobjc.A.dylib   	0x956213b2 prepareForMethodLookup +  
85

2   libobjc.A.dylib 0x95622657 lookUpMethod + 86
3   libobjc.A.dylib   	0x95619da7  
_class_lookupMethodAndLoadCache + 40

4   libobjc.A.dylib 0x95619953 objc_msgSend + 83
5   com.apple.AppKit  	0x94b6f2e1 -[NSTextView(NSSharing)  
setSelectedRange:] + 64
6   com.apple.AppKit  	0x94b6bd62 -[NSLayoutManager  
textStorage:edited:range:changeInLength:invalidatedRange:] + 445
7   com.apple.AppKit  	0x94b38100 -[NSTextStorage  
_notifyEdited:range:changeInLength:invalidatedRange:] + 132
8   com.apple.AppKit  	0x94b37921 -[NSTextStorage  
processEditing] + 218
9   com.apple.AppKit  	0x94b3781e -[NSTextStorage  
edited:range:changeInLength:] + 272
10  com.apple.Foundation  	0x95d8063c - 
[NSConcreteMutableAttributedString  
replaceCharactersInRange:withAttributedString:] + 413
11  com.apple.AppKit  	0x94bd14c7 -[NSConcreteTextStorage  
replaceCharactersInRange:withAttributedString:] + 102



0   libobjc.A.dylib 0x9561992c objc_msgSend + 44
1   com.apple.AppKit  	0x94b6f2e1 -[NSTextView(NSSharing)  
setSelectedRange:] + 64
2   com.apple.AppKit  	0x94b6bd62 -[NSLayoutManager  
textStorage:edited:range:changeInLength:invalidatedRange:] + 445
3   com.apple.AppKit  	0x94b38100 -[NSTextStorage  
_notifyEdited:range:changeInLength:invalidatedRange:] + 132
4   com.apple.AppKit  	0x94b37921 -[NSTextStorage  
processEditing] + 218
5   com.apple.AppKit  	0x94b3781e -[NSTextStorage  
edited:range:changeInLength:] + 272
6   com.apple.Foundation  	0x95d8063c - 
[NSConcreteMutableAttributedString  
replaceCharactersInRange:withAttributedString:] + 413
7   com.apple.AppKit  	0x94bd14c7 -[NSConcreteTextStorage  
replaceCharactersInRange:withAttributedString:] + 102


The code here looks like this:

- (NSTextView*)			editText:(NSTextStorage*) text inRect:(NSRect) rect  
delegate:(id) del drawsBackground:(BOOL) drawBkGnd

{
	NSAssert( text != nil, @text was nil when trying to start a text  
editing operation);

NSAssert( rect.size.width  0, @editing rect has 0 or -ve width);
NSAssert( rect.size.height  0, @editing rect has 0 or -ve height);

if ([self isTextBeingEdited])
[self endTextEditing];

	// editor's frame is expanded by five points to ensure all characters  
are visible when not using screen fonts

// container text inset is later set to compensate for this.

NSRect editorFrame = NSInsetRect( rect, -5, -5 );

if( m_textEditViewRef == nil )
		m_textEditViewRef = self class] classForTextEditor] alloc]  
initWithFrame:editorFrame];

else
[m_textEditViewRef setFrame:editorFrame];

[m_textEditViewRef setAllowsUndo:NO];

	NSRange textRange = NSMakeRange( 0, [[m_textEditViewRef textStorage]  
length]);
	[[m_textEditViewRef textStorage] replaceCharactersInRange:textRange  
withAttributedString:text];


___

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

Please do not post 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: Problem using filewrappers under snow leopard

2009-10-06 Thread Graham Cox


On 07/10/2009, at 11:23 AM, Eagle Offshore wrote:


where fileWrappers is an NSMutableDictionary of filename-NSData's.



But that's not what the documentation says you should pass. The  
dictionary should contain other NSFileWrappers keyed by their  
preferred filenames, not NSData. That you got away with it in the past  
is a fluke.



Initializes the receiver as a directory file wrapper, with a given  
file-wrapper list.


- (id)initDirectoryWithFileWrappers:(NSDictionary *) 
childrenByPreferredName


Parameters
childrenByPreferredName
Key-value dictionary of file wrappers with which to initialize the  
receiver. The dictionary must contain entries whose values are the  
file wrappers that are to become children and whose keys are  
filenames. See Working With Directory Wrappers in Application File  
Management for more information about the file-wrapper list structure.


Return Value
Initialized file wrapper for fileWrappers.





--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: Suggest reasons for this crash?

2009-10-06 Thread Kyle Sluder
On Tue, Oct 6, 2009 at 5:37 PM, Graham Cox graham@bigpond.com wrote:
 6   com.apple.AppKit                    0x94b6bd62 -[NSLayoutManager
 textStorage:edited:range:changeInLength:invalidatedRange:] + 445

This is a hint.

        [[m_textEditViewRef textStorage] replaceCharactersInRange:textRange
 withAttributedString:text];

You haven't wrapped this in -[NSTextView
shouldChangeTextInRange:replacementString:] and -[NSTextView
didChangeText].

--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: Suggest reasons for this crash?

2009-10-06 Thread Graham Cox


On 07/10/2009, at 11:49 AM, Kyle Sluder wrote:


You haven't wrapped this in -[NSTextView
shouldChangeTextInRange:replacementString:] and -[NSTextView
didChangeText].



Aha! Thanks - can you point me to the relevant documentation on that?  
I was working on the principle that methods like this were high level  
and were managing that before-and-after notification/setup stuff for me.


--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: Suggest reasons for this crash?

2009-10-06 Thread Kyle Sluder
On Tue, Oct 6, 2009 at 5:53 PM, Graham Cox graham@bigpond.com wrote:
 Aha! Thanks - can you point me to the relevant documentation on that? I was
 working on the principle that methods like this were high level and were
 managing that before-and-after notification/setup stuff for me.

First Google result for shouldchangetextinrange: Text Editing
Progamming Guide, Subclassing NSTextView, Notifying about Changes to
the Text. 
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/TextEditing/Tasks/Subclassing.html

Also in the documentation for
-shouldChangeTextInRange:replacementString: (but if you know to look
there you probably already know the solution).

This is something you need to check for whenever you might possibly
ever hook up a text view (including the field editor!) to a text
storage.  So if you're storing text storages in your model, for
example, like in a word processor.  This isn't going to show up if
you're just using -setString: (the typical case).

--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: Suggest reasons for this crash?

2009-10-06 Thread Graham Cox

Thanks Kyle - that's really helpful.

I hadn't read the subclassing notes because I'm not subclassing. My  
model stores attributed strings (pity there's not a - 
setAttributedString: method on NSTextView that would deal with all the  
kinks necessary). I'd also missed the discussion on this method  
because I didn't know I needed to be using it - why read it if you  
don't need it, and how do I know I need it unless something else says  
so? - a typical chicken-and-egg situation.


Anyway, hopefully this will fix the problem. Thanks again.

--Graham


On 07/10/2009, at 12:01 PM, Kyle Sluder wrote:

On Tue, Oct 6, 2009 at 5:53 PM, Graham Cox graham@bigpond.com  
wrote:
Aha! Thanks - can you point me to the relevant documentation on  
that? I was
working on the principle that methods like this were high level and  
were

managing that before-and-after notification/setup stuff for me.


First Google result for shouldchangetextinrange: Text Editing
Progamming Guide, Subclassing NSTextView, Notifying about Changes to
the Text. 
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/TextEditing/Tasks/Subclassing.html

Also in the documentation for
-shouldChangeTextInRange:replacementString: (but if you know to look
there you probably already know the solution).

This is something you need to check for whenever you might possibly
ever hook up a text view (including the field editor!) to a text
storage.  So if you're storing text storages in your model, for
example, like in a word processor.  This isn't going to show up if
you're just using -setString: (the typical case).

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


remote binding problem

2009-10-06 Thread David Hirsch

Hello list-
Here is part of my app:

@interface ModeQuizDoc : NSDocument
{
QuizResults *quizResults;
}

@implementation ModeQuizDoc
- (id)init
{
self = [super init];
if (self) {
quizResults = [[[QuizResults alloc] init] retain];
}
}


@interface QuizResults : NSObject {
float currentScore;
}

In Interface Builder, I would like to bind a text field to the current  
score.  When I set up the text field value's binding to File's  
Owner.quizResults.currentScore, the app crashes inside loadNib (inside  
NSPopAutoreleasePool).  Is that expected behavior?  Do I need to set  
up the binding programatically?  Can I use an NSObjectController to  
get around this, as some web search results have implied (but I cannot  
make work)?


Thanks,
Dave


___

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

Please do not post 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: Suggest reasons for this crash?

2009-10-06 Thread Adam R. Maxwell

On Oct 6, 2009, at 6:14 PM, Graham Cox wrote:

 Thanks Kyle - that's really helpful.
 
 I hadn't read the subclassing notes because I'm not subclassing. My model 
 stores attributed strings (pity there's not a -setAttributedString: method on 
 NSTextView that would deal with all the kinks necessary). I'd also missed the 
 discussion on this method because I didn't know I needed to be using it - why 
 read it if you don't need it, and how do I know I need it unless something 
 else says so? - a typical chicken-and-egg situation.

I think it's worth noting that Apple's code examples don't do this:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/TextArchitecture/Tasks/SimpleTasks.html

The way I read the page Kyle linked to and 
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/TextEditing/Tasks/BatchEditing.html
 is that this is only for user-initiated changes (which may or may not be 
appropriate, depending on what you're doing).  

If this is really necessary, hopefully it'll be documented, or one of the text 
system guys can step in and clarify...I'd really like to know since I've been 
doing this for years without calling shouldChangeTextInRange:replacementString:.



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: remote binding problem

2009-10-06 Thread Graham Cox


On 07/10/2009, at 1:29 PM, David Hirsch wrote:


@interface ModeQuizDoc : NSDocument
{
QuizResults *quizResults;
}

@implementation ModeQuizDoc
- (id)init
{
   self = [super init];
   if (self) {
quizResults = [[[QuizResults alloc] init] retain];


You don't need to retain here. It's already retained, so the  
additional retain will cause quizResults to leak, assuming the extra  
retain isn't balanced somewhere.
However, that isn't your problem (though lack of understanding of  
memory management in general, which this indicates, may well be).




   }
}


@interface QuizResults : NSObject {
float currentScore;
}

In Interface Builder, I would like to bind a text field to the  
current score.  When I set up the text field value's binding to  
File's Owner.quizResults.currentScore, the app crashes inside  
loadNib (inside NSPopAutoreleasePool).  Is that expected behavior?   
Do I need to set up the binding programatically?  Can I use an  
NSObjectController to get around this, as some web search results  
have implied (but I cannot make work)?


There probably isn't enough here to give a definite answer.

My guess is that the class QuizResults is unknown at compile time, and  
thus the 'currentScore' property isn't being accessed correctly. Does  
your code emit any warnings when it is compiled? If so, fix them.


ModeQuizDoc needs at minimum a forward declaration for QuizResults,  
and the .m file should include QuizResults.h. More importantly, the  
QuizResults class and its currentScore property needs to be visible to  
anyone interested in it including IB. I would strongly recommend a  
property accessor for it instead of relying on accessing the ivar  
directly. If any code is assuming this property is type id instead of  
float, you'll probably get the crash that you seem to be getting.


--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: remote binding problem

2009-10-06 Thread David Hirsch


On Oct 6, 2009, at 7:56 PM, Graham Cox wrote:


In Interface Builder, I would like to bind a text field to the  
current score.  When I set up the text field value's binding to  
File's Owner.quizResults.currentScore, the app crashes inside  
loadNib (inside NSPopAutoreleasePool).  Is that expected behavior?   
Do I need to set up the binding programatically?  Can I use an  
NSObjectController to get around this, as some web search results  
have implied (but I cannot make work)?


There probably isn't enough here to give a definite answer.

My guess is that the class QuizResults is unknown at compile time,  
and thus the 'currentScore' property isn't being accessed correctly.  
Does your code emit any warnings when it is compiled? If so, fix them.


I get no problems at compile time

ModeQuizDoc needs at minimum a forward declaration for QuizResults,  
and the .m file should include QuizResults.h.


This is indeed the case.

More importantly, the QuizResults class and its currentScore  
property needs to be visible to anyone interested in it including IB.


It is: IB knows the contents of the .h files, right?  It knows that  
currentScore is a float, because when I bind to it, the placeholder  
fields in the Bindings inspector all say number value


I would strongly recommend a property accessor for it instead of  
relying on accessing the ivar directly.


But I can't bind through an accessor, can I?  I'm supposed to be able  
to bind to the ivar, I think.


If any code is assuming this property is type id instead of float,  
you'll probably get the crash that you seem to be getting.

--Graham





-Dave


___

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

Please do not post 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: Suggest reasons for this crash?

2009-10-06 Thread Graham Cox


On 07/10/2009, at 1:54 PM, Adam R. Maxwell wrote:


I think it's worth noting that Apple's code examples don't do this:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/TextArchitecture/Tasks/SimpleTasks.html

The way I read the page Kyle linked to andhttp://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/TextEditing/Tasks/BatchEditing.html 
 is that this is only for user-initiated changes (which may or may  
not be appropriate, depending on what you're doing).


If this is really necessary, hopefully it'll be documented, or one  
of the text system guys can step in and clarify...I'd really like to  
know since I've been doing this for years without calling  
shouldChangeTextInRange:replacementString:.



Hmmm, now I'm a little confused again.

It seems I should be doing beginEditing/endEditing and/or  
shouldChangeTextInRange:replacementString:/didChangeText but it's not  
clear whether it's either/or.


Doing both seems to be harmless, but I also don't yet have  
confirmation whether the crash is fixed, since it's not reproducible  
locally anyway.


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


Checking whether a file is a genuine PDF file

2009-10-06 Thread Michele (Mike) Hjorleifsson
what about using a digital signature ?  the current PDF standards and  
even ODF standards support a digital signature
that would ensure the file hasnt been tampered with since it was  
signed. Though i guess you could create a garbage PDF and sign it  if  
you wanted.


Best Regards,   
Michele (Mike) Hjorleifsson 

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: Suggest reasons for this crash?

2009-10-06 Thread Kyle Sluder
On Tue, Oct 6, 2009 at 7:54 PM, Adam R. Maxwell amaxw...@mac.com wrote:
 If this is really necessary, hopefully it'll be documented, or one of the 
 text system guys can step in and clarify...I'd really like to know since I've 
 been doing this for years without calling 
 shouldChangeTextInRange:replacementString:.

The main problem I've found is that NSTextView is incredibly lazy.
Like so lazy that if it doesn't have a text storage attached, and you
call -setSelectedRange:, it does nothing.  And then you hook up a
zero-length text storage to it, and you crash because the text view
still has a selection range of (0, 15) even you called
-setSelectedRange: on it.  (This is a real crash I experienced two
weeks ago.)

We are super paranoid about attaching and detaching text views to
existing text storages.  Granted, this is not a common thing to do.
Most often you have a text view that is permanently associated with a
text storage (word processor) or a field editor that creates and
destroys temporary text storages as it edits different controls.

Also, I'd ask What is the difference between a user-initiated change
and a non-user-initiated change?  If a user clicks on a Summarize
Document button in your word processor, is the resultant change to the
text storage not a user-initiated change?  It would seem to me that
the intended implementation would be a subclass of NSTextView with a
-summarize: action to which said button was targeted, in which case
the docs are quite clear on calling
-shouldChangeTextInRange:replacementString:.  But what if you move
that logic to your NSDocument subclass?  For what reason should you
not call this method?

The Batch Editing section seems to highlight the distinction between
-[NSTextStorage beginEditing], which exists so that you don't send
multiple text change notifications (and therefore multiple undo
events) for what should be a single atomic mutation, and -[NSTextView
shouldChangeTextInRange:replacementString:], which exists so that the
text storage can set itself and its delegate up for text storage
changes.

--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: remote binding problem

2009-10-06 Thread Graham Cox


On 07/10/2009, at 2:12 PM, David Hirsch wrote:

I would strongly recommend a property accessor for it instead of  
relying on accessing the ivar directly.


But I can't bind through an accessor, can I?  I'm supposed to be  
able to bind to the ivar, I think.



You bind to properties, not to ivars. Properties are often implemented  
in terms of ivars, but they are not the same thing conceptually.


You should generally arrange that properties are accessed via  
accessors. I believe that the ability to have Cocoa automatically  
find a property that is implemented as an ivar is a convenience too  
far, probably there for historic reasons. If you design classes on the  
principle that this convenience doesn't exist you'll be better off.  
Whether this has a bearing on your crash isn't clear however.


Is your document's -init method being called at all? Maybe quizResults  
is nil or uninitialized at the time that the currentScore property is  
accessed.


--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: CoreData async fetch request

2009-10-06 Thread David Melgar

Hello,
Thanks for the response. Seems that its straying somewhat from my  
original question.


Searching based on prefix matching is fine.  The predicate I'm using  
really is of the form SELF like foo, no wildcard, so it doesn't seem  
that it should be that expensive. You say its possible to structure  
this to use a binary index. How? I don't see any mention of indices in  
the Coredata documentation. If I use SQLite directory, presumably I  
can set indices on the fields I want and more closely manage the data  
model.


I don't see how setBatchFetchSize helps. Doesn't it just limit the  
number of results returned? I have no idea how quickly the results  
will come in. Setting a size 1 is therefore indeterminate and may  
take the full 3 minutes. If I set it to one, and I want to try and get  
the second row as well, it appears that it starts the query all over  
again, worst case resulting in 6 minutes before the 2nd result shows  
up. Doesn't seem that it scales reasonably if I want to display the  
first 10-20 entries.


My issue with Coredata is that it NSFetchRequest always returns ALL  
the results of the particular query at one time. If I use SQLite  
directly... assuming it supports cursors, I can get each result one at  
a time as they show up, display it to the user without slowing down  
the query as it continues to find other results.


NSFetchRequest could support a delegate to invoke some method when for  
each item that has been found, rather than blocking until all the  
results are received.
It also could have been implemented as a virtual queue, an object  
which could be read from while being written to in another thread.





On Oct 6, 2009, at 4:08 AM, Ben Trumbull wrote:



On Oct 5, 2009, at 7:00 PM, enki1...@gmail.com wrote:

I am doing a simple query search for a text string pattern (ie  
'SELF like foo') on ~10 million small records stored persistently  
using sqlite. This is a performance test to make sure I get  
reasonable performance from my database engine before I commit too  
much code to it.


Well, @self like 'foo' is a different problem than @self like  
'*foo*'.  LIKE queries require Unicode compliant regex and are  
intrinsically expensive.  If you do not have a wildcard, you are  
better off use an == query.  The DerivedProperty ADC example shows  
how to transform the text to make it much faster to search.


If you do need to use a wildcard, you'll really want to stick with  
1, either prefix matching or suffix matching.  The DerivedProperty  
example shows prefix matching.  It's possible to structure this to  
use a binary index, and make the query extremely fast even for  
millions of records.  There is a huge difference in computational  
complexity.  Prefix matching can use an index, and therefore can run  
O(lg(N)).


*foo* (contains) searches are slow, and cannot use an index.  You  
really want to avoid these.  Even Spotlight does not do arbitrary  
substring matching.  Compare help with elp in your Spotlight  
results.  If you want word matching, you can use Spotlight or  
SearchKit to build a supplemental FTS index.


The query is taking over 3 minutes with a small result set. This is  
on a new 13 macbook pro w 4gb memory.


... a full table scan executing a regex on each of 10 million rows  
on a 5400 rpm drive ?  Well, for doing all that, 3 minutes sounds  
pretty fast.


Just as a reference point, if you grab the objectIDs from the result  
set, and execute an IN query selecting those objects, how long does  
it take ?  50ms ?  100ms ?


The query is taking too long for a user to sit and wait for it. Is  
there a way to speed it up? Can indexing be applied to it?


I had thought if I could display results as they are found that  
might be reasonable. In my tests, if I use setFetchBatchSize and  
setOffset to restart it, then it ends up repeating the query taking  
that many times longer to get a result. Not reasonable. It does not  
seem to start the query where it left off, as a database cursor  
would do.


You can use -com.apple.CoreData.SQLDebug 1 to see the SQL we pass to  
the database.  This also has nothing to do with Core Data.  This is  
how offset queries behave.  I realize it's not what you expected,  
which is why I recommended using -setFetchBatchSize: instead.


My impression is that my usage scenario is not an appropriate use  
of core data.


Core Data is just passing the query off to the database.  I'm not  
sure why you think going to the database directly will do anything  
for the 179.9 / 180.0 seconds it takes to evaluate the query in the  
database.



I was planning to try SQLite directly. Would it be more appropriate?


You can try it directly, but it won't have any meaningful effect on  
your performance results except that SQLite's built in LIKE operator  
doesn't support Unicode.  It'll be a tiny bit faster for that, but  
still the same order of magnitude.  And then, either you'll have to  
integrate ICU support as 

[Solved] Re: remote binding problem

2009-10-06 Thread David Hirsch
Okay,  I'm an idiot.  I did have accessors, but the getter returned  
the wrong type.  (An early version of the quizResults ivar was an  
NSArray, and I neglected to fix the return type of the getter).  Sorry  
for wasting your time!  Hopefully somebody will read this in the  
archives and find their error in the future.


Note that I was thus incorrect: binding works through accessors,  
apparently.  This was not clear from the docs I had read.


-Dave



On Oct 6, 2009, at 8:21 PM, Graham Cox wrote:



On 07/10/2009, at 2:12 PM, David Hirsch wrote:

I would strongly recommend a property accessor for it instead of  
relying on accessing the ivar directly.


But I can't bind through an accessor, can I?  I'm supposed to be  
able to bind to the ivar, I think.



You bind to properties, not to ivars. Properties are often  
implemented in terms of ivars, but they are not the same thing  
conceptually.


You should generally arrange that properties are accessed via  
accessors. I believe that the ability to have Cocoa automatically  
find a property that is implemented as an ivar is a convenience  
too far, probably there for historic reasons. If you design classes  
on the principle that this convenience doesn't exist you'll be  
better off. Whether this has a bearing on your crash isn't clear  
however.


Is your document's -init method being called at all? Maybe  
quizResults is nil or uninitialized at the time that the  
currentScore property is accessed.


--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: Suggest reasons for this crash?

2009-10-06 Thread Adam R. Maxwell

On Oct 6, 2009, at 8:21 PM, Kyle Sluder wrote:

 On Tue, Oct 6, 2009 at 7:54 PM, Adam R. Maxwell amaxw...@mac.com wrote:
 If this is really necessary, hopefully it'll be documented, or one of the 
 text system guys can step in and clarify...I'd really like to know since 
 I've been doing this for years without calling 
 shouldChangeTextInRange:replacementString:.
 
 The main problem I've found is that NSTextView is incredibly lazy.
 Like so lazy that if it doesn't have a text storage attached, and you
 call -setSelectedRange:, it does nothing.  And then you hook up a
 zero-length text storage to it, and you crash because the text view
 still has a selection range of (0, 15) even you called
 -setSelectedRange: on it.  (This is a real crash I experienced two
 weeks ago.)

I've run into that problem when mutating a text storage where the user has 
something selected in the view, but I've always worked around it by setting the 
selected range to 0,0 beforehand (I'm thinking of a non-editable master-detail 
view, in particular).

 We are super paranoid about attaching and detaching text views to
 existing text storages.  Granted, this is not a common thing to do.
 Most often you have a text view that is permanently associated with a
 text storage (word processor) or a field editor that creates and
 destroys temporary text storages as it edits different controls.

Graham was just using the text storage associated with the view, as I read his 
code, not replacing it entirely...

 Also, I'd ask What is the difference between a user-initiated change
 and a non-user-initiated change?  If a user clicks on a Summarize
 Document button in your word processor, is the resultant change to the
 text storage not a user-initiated change?  It would seem to me that
 the intended implementation would be a subclass of NSTextView with a
 -summarize: action to which said button was targeted, in which case
 the docs are quite clear on calling
 -shouldChangeTextInRange:replacementString:.  But what if you move
 that logic to your NSDocument subclass?  For what reason should you
 not call this method?

That's a fair question; I don't have a good definition :).  However, if I have 
a master-detail view with a non-editable textview, or am updating a text view 
with live output from an NSTask, I don't care if the delegate gets notified of 
changes (so have never seen a reason to call 
shouldChangeTextInRange:replacementString:).  There are other situations where 
you might want to unconditionally replace the characters of the text storage, 
as well.  The doc examples I've seen don't call 
shouldChangeTextInRange:replacementString:, but I haven't done an exhaustive 
search.

 The Batch Editing section seems to highlight the distinction between
 -[NSTextStorage beginEditing], which exists so that you don't send
 multiple text change notifications (and therefore multiple undo
 events) for what should be a single atomic mutation, and -[NSTextView
 shouldChangeTextInRange:replacementString:], which exists so that the
 text storage can set itself and its delegate up for text storage
 changes.

That section discusses sshouldChangeTextInRange:replacementString: in context 
of ...new user actions in a text view, such as a menu action or key binding 
method that changes the text.  The only caveat I can see for modifying the 
text storage is that sending beginEditing/endEditing is good practice, but not 
strictly necessary.  Given that, I'm surprised that shouldChangeTextInRange:... 
would be necessary in all cases, but it wouldn't be the first time I've misread 
the docs.




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: Suggest reasons for this crash?

2009-10-06 Thread Adam R. Maxwell

On Oct 6, 2009, at 8:46 PM, Adam R. Maxwell wrote:

 However, if I have a master-detail view with a non-editable textview, or am 
 updating a text view with live output from an NSTask, I don't care if the 
 delegate gets notified of changes (so have never seen a reason to call 
 shouldChangeTextInRange:replacementString:).

And on a closer look at the docs, shouldChangeTextInRange:replacementString: 
would return NO for a non-editable view, so it's likely the wrong thing to do 
in that case, at least.



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: CoreData async fetch request

2009-10-06 Thread Karl Hsu

On Oct 6, 2009, at 1:08 AM, Ben Trumbull wrote:

Core Data is just passing the query off to the database.  I'm not  
sure why you think going to the database directly will do anything  
for the 179.9 / 180.0 seconds it takes to evaluate the query in the  
database.


I suspect that he wants a background thread that simply sits and  
passes results back to main thread directly from sqlite3_step(). I  
don't know of a way to incrementally return results in CoreData when  
the query is very expensive; using setOffset will re-issue the query  
and even fetching just IDs still has to wait for the entire query to  
finish before return any results.


Karl

___

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

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


Issues with NSWindowDelegate on multiple Mac OS X platforms

2009-10-06 Thread Tron Thomas

I recently got a MacBook Pro running Mac OS X 10.6.1 and Xcode 3.2

When I tried to build a project I was working on, I would get an error  
like this:


warning: class 'MyClass' does not implement the 'NSWindowDelegate'  
protocol


I was able to eliminate the warning by doing this:

@interface MyClass : NSResponder NSWindowDelegate

However when I go to build the same project on my PowerMac G5 running  
Mac OS X 10.5.8 with Xcode 3.1.3, I now get this compilation error:


error: cannot find protocol declaration for 'NSWindowDelegate'

What is needed so the project will build with no errors or warnings on  
both platforms?


___

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

Please do not post 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: Suggest reasons for this crash?

2009-10-06 Thread Kyle Sluder
On Tue, Oct 6, 2009 at 8:46 PM, Adam R. Maxwell amaxw...@mac.com wrote:
 That's a fair question; I don't have a good definition :).  However, if I 
 have a master-detail view with a non-editable textview, or am updating a text 
 view with live output from an NSTask, I don't care if the delegate gets 
 notified of changes (so have never seen a reason to call 
 shouldChangeTextInRange:replacementString:).  There are other situations 
 where you might want to unconditionally replace the characters of the text 
 storage, as well.  The doc examples I've seen don't call 
 shouldChangeTextInRange:replacementString:, but I haven't done an exhaustive 
 search.

If you have a non-editable text view, then you are probably just
calling -setString: or -setTextStorage: on it anyway.  In that case it
does not make sense to call
-shouldChangeTextInRange:replacementString:.  I can't imagine the
usefulness of replacing the contents of the text storage instead of
just swapping in the new one.

--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: Issues with NSWindowDelegate on multiple Mac OS X platforms

2009-10-06 Thread Kyle Sluder
Please read the 10.6 Foundation release notes, particularly the
section entitled Formal protocol adoption:
http://developer.apple.com/mac/library/releasenotes/Cocoa/Foundation.html

We compile dual-mode code using the following:

@interface Subclass : Superclass
#if MAC_OS_X_VERSION_MIN_REQUIRED = MAC_OS_X_VERSION_10_6
ConformingProtocol
#endif

In the case of conformance to multiple protocols, some of which are
unavailable pre-10.6, we use this:

@interface Subclass : Superclass Protocol1
#if MAC_OS_X_VERSION_MIN_REQUIRED = MAC_OS_X_VERSION_10_6
,Protocol2
#endif


It's a mess, but it works, and the benefit of static type checking far
outweighs the cost.  (And it also motivates you to drop 10.5 support.
:D)

--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: Suggest reasons for this crash?

2009-10-06 Thread Graham Cox


On 07/10/2009, at 3:37 PM, Kyle Sluder wrote:


I can't imagine the
usefulness of replacing the contents of the text storage instead of
just swapping in the new one.



I do this because previously I was replacing the text storage and that  
was causing a huge amount of upset for Undo, producing a crash deep  
inside the undo manager for a private object it maintains.  
(Essentially, the target for a text editing undo operation is the text  
storage, so if it's replaced the reference is stale, since Undo tasks  
do not retain their targets). In fact I recall that it was you who  
suggested that using -replaceTextStorage: would cause problems for  
Undo and suggested replacing the content instead. Indeed, that did  
seem to eradicate that particular source of problems. I didn't try it  
but -setTextStorage: would presumably have the same effect on Undo,  
making it unsafe.


However, there were other problems anyway so I ended up disabling Undo  
for typing when the text is being edited. I'd like to be able to re- 
enable it at some point but I can't see a very nice way to consolidate  
the two phases for Undo - typing, then just getting the typed text  
and setting it back into my data model, which is also undoable. At  
that point the undos relating to typing should be removed from the  
undo stack but I can't find a stable way to do that, hence disabling  
Undo for typing altogether.


http://www.cocoabuilder.com/archive/message/cocoa/2009/9/16/245160

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