memory advice for still learning coder

2009-10-03 Thread Rick C.
hello,

i'm having a few memory issues where my memory climbs over time although using 
leaks it shows i have no leaks.  i have gone over my code many times making 
sure i release items that need it and have gone over the docs looking for 
something i might be missing.  i'm thinking my problem might be in these 2 
design areas and if anyone could give some input that would be great:

1.  i have a handful of mutable arrays that i need for the lifetime of my app.  
i alloc/init them upon startup and at various places i do removeAllObjects and 
then addObjectFromArray with the other array being convenience created.  in 
dealloc i do release.

2.  i use NSObject performSelectorInBackground for a few methods so they do not 
tie up my main thread.  one of these background methods uses NSTask.  in every 
background method i init the autorelease pool and release it according to the 
docs.  i also release the NSTask i use.  and i do modify a few of the above 
mentioned mutable arrays in these background methods in the way i described 
above.

i know i'm not including code here so i hope this is not too vague.  but i was 
thinking someone might be able to tell me if i'm on the wrong track here.  i'm 
trying to pinpoint where the problem can be and it seems everytime i initiate 
performSelectorInBackground my memory usage goes up and is not reclaimed.  i 
know starting a new thread increases memory but i'm expected it to be 
reclaimed.  to be honest i don't need to use so many threads just one would do, 
but i used performSelectorInBackground to make things a bit more simple.  i can 
provide more info if needed.  thank you very much,

rick


  
___

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

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

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

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


releasing a object containing others in a array

2009-10-03 Thread Nick Rogers

Hi,

I have a class as following:

@interface NodeTypeOrph : NSObject {
int count;
ItemTypeOrph*key[4];   // Warning: indexing starts at 0, not 1
NodeTypeOrph*branch[5];   // Fake pointers to child nodes
}

when I'll send a release to an object of this type, will it  
automatically release the arrays of ItemTypeOrph and NodeTypeOrph  
objects.

Or do I have to explicitly traverse and release?

Wishes,
Nick

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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-03 Thread Keith Blount
Many thanks, Aki, much appreciated.

> You can do:
> NSGraphicsContext *context = [NSGraphicsContext
> currentContext];
> [context saveGraphicsState];
> [yourCustomColor set];
> [super showPackedGlyphs:...];
> [context restoreGraphicsState];
> 

This works perfectly, thank you.

> There is no rendering primitive method like this for
> underlines.  You still need to use temporary attributes
> for that purpose.  I believe the temporary attribute
> approach is efficient enough for that kind of usage
> patterns.

Returning to the original question for the underlines, is the most efficient 
approach to override -temporaryAttributesAtIndex... and check for the underline 
+ custom attribute there and modify the returned dictionary, or to use 
-addTemporaryAttributes: on any changed text every time it is changed (e.g. in 
-textStorage:edited:range:changeInLength:invalidatedRange:)?

Thanks again!
Keith

> 
> Aki
> 
> On 2009/10/02, at 17:32, Keith Blount wrote:
> 
> > Hi Aki,
> > 
> > Many thanks for your reply, much appreciated. Would
> you mind giving me a little more information on how to
> override this method? The docs are a little sparse in this
> regard. For instance, if I try passing a different colour
> into super's method, it has no effect; instead, it seems
> that I need to use [color set] before calling super (which
> would seem to be hinted at by the docs, as they say "if for
> any reason you modify the set color or font..."). Do I call
> [customColor set] using my own colour, then call super, then
> call [color set] using the passed-in colour after calling
> super?
> > 
> > My custom attributes set only the colour, so this
> should be fine. (Although I'm not sure how I would use this
> method if I wanted, say, the underline to be a different
> colour from the text, which I need for certain link
> attributes.)
> > 
> > Many thanks again and all the best,
> > Keith
> > 
> > --- On Fri, 10/2/09, Aki Inoue 
> wrote:
> > 
> >> From: Aki Inoue 
> >> Subject: Re: NSLayoutManager and best override
> point for temporary attributes
> >> To: "Keith Blount" 
> >> Cc: "Martin Wierschin" ,
> cocoa-dev@lists.apple.com
> >> Date: Friday, October 2, 2009, 10:24 PM
> >> Keith,
> >> 
> >> If your custom attributes modifies just the
> graphics state
> >> (don't affect the layout), you can override
> >> -[NSLayoutManager
> >>
> showPackedGlyphs:length:glyphRange:atPoint:font:color:printingAdjustment:].
> >> 
> >> The method is the bottleneck for calling CG
> APIs.  You
> >> can query the text attribute using
> glyphRange.location and
> >> see if there is one of your custom attributes.
> >> 
> >> You should be able to customize alpha, color,
> blending
> >> mode, compositing mode, clipping, etc.
> >> 
> >> Aki
> >> 
> >> On 2009/10/02, at 7:04, Keith Blount wrote:
> >> 
> >>> Hi,
> >>> 
> >>> Looking at this again, would
> NSLayoutManager's
> >>> 
> >>> 
> >>
> -textStorage:edited:range:changeInLength:invalidatedRange:
> >>> 
> >>> method be a good candidate for overriding to
> add
> >> temporary attributes? The text storage calls this
> whenever
> >> it's edited and provides it with the new range of
> >> characters. So it seems that I could add any
> temporary
> >> attributes to the range that gets passed in here,
> checking
> >> that changeInLength > 0.
> >>> 
> >>> Or, what if in the -addAttribute:...,
> >> -setAttributes:... and removeAttribute:... methods
> of my
> >> NSTextStorage, I called through to all of the text
> storage's
> >> layout managers to ask them to add the temporary
> attribute
> >> if necessary, after -edited:range:changeInLength:
> gets
> >> called?
> >>> 
> >>> Many thanks again!
> >>> 
> >>> All the best,
> >>> Keith
> >>> 
> >>> --- On Thu, 10/1/09, Martin Wierschin 
> >> wrote:
> >>> 
>  From: Martin Wierschin 
>  Subject: Re: NSLayoutManager and best
> override
> >> point for temporary attributes
>  To: "Keith Blount" 
>  Cc: cocoa-dev@lists.apple.com
>  Date: Thursday, October 1, 2009, 1:50 AM
>  Hi Keith,
>  
> > I have certain custom text attributes
> that are
> >> used in
>  my NSTextStorage to which I would like to
> add
> >> temporary
>  attributes via the NSLayoutManager.
>  
>  What version of OSX are you testing under?
> Under
> >> Leopard
>  there's a bug in -[NSLayoutManager
>  
> >>
> temporaryAttribute:atCharacterIndex:longestEffectiveRange:inRange:]
>  that calculates effective ranges that are
> too
> >> short. For
>  specific test cases this caused big
> inefficiencies
> >> in the
>  text system. I believe this bug is fixed
> in Snow
> >> Leopard.
>  
> > more recently I have taken to
> overriding
>  NSLayoutManager's
>  
> >>
> -temporaryAttributesAtCharacterIndex:effectiveRange:
>  
>  If this is too slow, then I'd look to
> using some
> >> kind of
>  cache for your calculations. But really,
> >> NSLayoutManager's
>  temporary attributes are already a cache;
> one
> >> likely to

Re: releasing a object containing others in a array

2009-10-03 Thread Roland King
Well follow the memory management rules. You retained the objects when  
you put them in the array so you must release them.




On 03-Oct-2009, at 16:10, Nick Rogers  wrote:


Hi,

I have a class as following:

@interface NodeTypeOrph : NSObject {
   intcount;
   ItemTypeOrph*key[4];   // Warning: indexing starts at 0, not 1
   NodeTypeOrph*branch[5];   // Fake pointers to child nodes
}

when I'll send a release to an object of this type, will it  
automatically release the arrays of ItemTypeOrph and NodeTypeOrph  
objects.

Or do I have to explicitly traverse and release?

Wishes,
Nick

___

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

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

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

This email sent to r...@rols.org

___

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

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

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

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


objc_atomicCompareAndSwapInstanceVariable

2009-10-03 Thread André Berg

Hi,

In  I found this functions:

OBJC_GC_EXPORT BOOL objc_atomicCompareAndSwapPtr(id predicate, id 
replacement, volatile id *objectLocation)
OBJC_GC_EXPORT BOOL objc_atomicCompareAndSwapInstanceVariable(id 
predicate, id replacement, volatile id *objectLocation);
OBJC_GC_EXPORT BOOL objc_atomicCompareAndSwapGlobal(id predicate, id 
replacement, volatile id *objectLocation);


This sounds exiting! But I couldn't find any documentation for it other 
than the comment in the header.
I presume these work like the functions from libkern 
() ?


Can the predicate be any predicate or is it more like OSAtomic... 
functions in that it must have some correlation with the value at 
objectLocation (replacement will only be set as new value if predicate 
and objectLocation are equal, at least that's how I understood what  
"man atomic(3)" was saying about the equivalent functions from OSAtomic)?


And how do you pass the objectLocation of an instance variable without 
accessing them directly (e.g. "obj->ivar" which will be a hard error in 
the future according to compiler warnings)?


Or aren't we supposed to touch those functions at all?

I don't need to know this, just got me interested that's all.

Thanks for reading!

André
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: objc_atomicCompareAndSwapInstanceVariable

2009-10-03 Thread Greg Parker

On Oct 3, 2009, at 2:13 AM, André Berg wrote:

In  I found this functions:

OBJC_GC_EXPORT BOOL objc_atomicCompareAndSwapPtr(id predicate, id  
replacement, volatile id *objectLocation)
OBJC_GC_EXPORT BOOL objc_atomicCompareAndSwapInstanceVariable(id  
predicate, id replacement, volatile id *objectLocation);
OBJC_GC_EXPORT BOOL objc_atomicCompareAndSwapGlobal(id predicate, id  
replacement, volatile id *objectLocation);


This sounds exiting! But I couldn't find any documentation for it  
other than the comment in the header.
I presume these work like the functions from libkern (OSAtomic.h>) ?


Can the predicate be any predicate or is it more like OSAtomic...  
functions in that it must have some correlation with the value at  
objectLocation (replacement will only be set as new value if  
predicate and objectLocation are equal, at least that's how I  
understood what  "man atomic(3)" was saying about the equivalent  
functions from OSAtomic)?


These are exactly like OSAtomic's compare and swap with barrier, but  
for use when you're modifying GC-scanned storage. They tell the  
garbage collector about the assignment, if any. (If you use the  
OSAtomic functions directly with GC-scanned storage, then you can  
confuse the garbage collector which may delete your objects  
unexpectedly.)



And how do you pass the objectLocation of an instance variable  
without accessing them directly (e.g. "obj->ivar" which will be a  
hard error in the future according to compiler warnings)?


`obj->ivar` is perfectly legal, as long as you respect the ivar's  
access permissions. You won't get a warning if you access the class's  
own @private ivars, or its superclass's @protected ivars, or any other  
class's @package or @public ivars.



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


___

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

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

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

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


Re: memory advice for still learning coder

2009-10-03 Thread Ken Thomases

On Oct 3, 2009, at 2:38 AM, Rick C. wrote:

i'm having a few memory issues where my memory climbs over time  
although using leaks it shows i have no leaks.


Leaks aren't the only way to use excessive memory.  For example, if  
you keep allocating objects and putting them in a collection somewhere  
(like the mutable arrays you describe below) but never use them and  
your code effectively forgets they are there due to a logic error,  
they haven't officially leaked but the effect is similar.


You can use the Object Alloc instrument.  When examining the recorded  
data, you can select a range of data.  Set its beginning to a point in  
time after your app should have reached equilibrium -- after it has  
set up those objects which are meant to stick around for the whole  
lifetime or your app.  Set the end of the range to any point afterward  
where the memory use has inexplicably risen.  Tell the instrument to  
show only the still living objects.  This effectively shows you  
objects which were allocated and expected to be temporary, but which  
are still around.



1.  i have a handful of mutable arrays that i need for the lifetime  
of my app.  i alloc/init them upon startup and at various places i  
do removeAllObjects and then addObjectFromArray with the other array  
being convenience created.  in dealloc i do release.


So long as you really are invoking removeAllObjects when you expect to  
be, and the other array only contains what you think it should, that  
sounds fine.



2.  i use NSObject performSelectorInBackground for a few methods so  
they do not tie up my main thread.  one of these background methods  
uses NSTask.  in every background method i init the autorelease pool  
and release it according to the docs.  i also release the NSTask i  
use.


There have been reported issues with NSTask: if you don't run the run  
loop of the thread from which it was created and launched, then it  
might not clean up its resources.  -waitUntilExit should be  
sufficient.  If you're not waiting for the NSTask to complete, then  
there's little reason to launching it from a background thread.  So,  
you might be better of launching it from the main thread, where  
there's extra effort required to make sure the run loop is run.  In  
fact, you can always use an NSTask from the main thread in an  
asynchronous fashion, and that may be a better design choice,  
depending on what else your background thread is doing.


 and i do modify a few of the above mentioned mutable arrays in  
these background methods in the way i described above.


I hope you're being careful to properly guard against multiple threads  
accessing any given mutable array at the same time.



i'm trying to pinpoint where the problem can be and it seems  
everytime i initiate performSelectorInBackground my memory usage  
goes up and is not reclaimed.  i know starting a new thread  
increases memory but i'm expected it to be reclaimed.


Of course, you have to allow the thread to exit by returning from the  
method named by the selector.  I assume you know that.  :)


Does Activity Monitor show the thread count of your app steadily  
rising, or does it fall back to equilibrium when it should?


Regards,
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: releasing a object containing others in a array

2009-10-03 Thread Ken Thomases

On Oct 3, 2009, at 3:10 AM, Nick Rogers wrote:


I have a class as following:

@interface NodeTypeOrph : NSObject {
int count;
ItemTypeOrph*key[4];   // Warning: indexing starts at 0, not 1
NodeTypeOrph*branch[5];   // Fake pointers to child nodes
}

when I'll send a release to an object of this type, will it  
automatically release the arrays of ItemTypeOrph and NodeTypeOrph  
objects.

Or do I have to explicitly traverse and release?


What's the rule for an object pointer instance variable that's not in  
an array?  Why would you expect the more complicated case to be easier  
to handle?


None of your instance variables are automatically released for you.   
You are responsible for overriding -dealloc and releasing all of your  
instance variables (and anything else which is owned by your object,  
if it's somehow stored in something other than an instance variable;  
that is, you have to discharge your ownership responsibilities, no  
matter the form they take).


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


CFNumberFormatterCreate question

2009-10-03 Thread Dmitry Markman

Hi,
I'd like to emulate %15.4g format with CFNumberFormatterCreate

I have a problem with padding for exponential notation

patterns like
* ##...@###e00 don't work

Note: pattern * ##...@### works fine

icu returns error for patterns like * ##...@###e00
from other hand
documentation for decimal format allows patterns like * ##...@###e00  
(as far as I can see)



 pattern:= subpattern (';' subpattern)?
 subpattern := prefix? number exponent? suffix?
 number := (integer ('.' fraction)?) | sigDigits
 prefix := '\u'..'\uFFFD' - specialCharacters
 suffix := '\u'..'\uFFFD' - specialCharacters
 integer:= '#'* '0'* '0'
 fraction   := '0'* '#'*
 sigDigits  := '#'* '@' '@'* '#'*
 exponent   := 'E' '+'? '0'* '0'
 padSpec:= '*' padChar
 padChar:= '\u'..'\uFFFD' - quote

Not indicated in the BNF syntax above:
	• The grouping separator ',' can occur inside the integer and  
sigDigits elements, between any two pattern characters of that  
element, as long as the integer or sigDigits element is not followed  
by the exponent element.
	• Two grouping intervals are recognized: That between the decimal  
point and the first grouping symbol, and that between the first and  
second grouping symbols. These intervals are identical in most  
locales, but in some locales they differ. For example, the pattern  
"#,##,###" formats the number 123456789 as "12,34,56,789".
	• The pad specifier padSpec may appear before the prefix, after the  
prefix, before the suffix, after the suffix, or not at all.
	• In place of '0', the digits '1' through '9' may be used to  
indicate a rounding increment.




thanks

Dmitry Markman

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: objc_atomicCompareAndSwapInstanceVariable

2009-10-03 Thread André Berg
Thanks Greg! This really clears up a lot! And also thanks about 
clarifying the bit about the objc->ivar syntax. Seems I jumped to 
conclusions when I accidentally tried to access another object's ivar 
that way.


Personally I think you're doing a great job with the GC, Dispatch and 
Blocks support! These are extremely exciting times to be a Mac developer 
and I am glad I made the switch.


Keep it up :)

André





--- Original Nachricht ---
Absender: Greg Parker
Datum: 03.10.2009 11:39 Uhr
 (If you use the OSAtomic functions directly with GC-scanned storage, 
then you can confuse the garbage collector which may delete your 
objects unexpectedly.)




`obj->ivar` is perfectly legal, as long as you respect the ivar's 
access permissions. You won't get a warning if you access the class's 
own @private ivars, or its superclass's @protected ivars, or any other 
class's @package or @public ivars.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: memory advice for still learning coder

2009-10-03 Thread Rick C.
i appreciate the reply ken.  i'll try to answer your questions:

1.  got it about the Object Alloc instrument.  i'll have to spend some more 
time with it to interpret everything and i will do so.
2.  yes on the mutable arrays.  besides memory issues if i didn't release and 
then add objects correctly it would affect my results as well.
3.  i'm actually not using -waitUntilExit with my task.  maybe this is an error 
i can correct.  i have checked in the past and my task always shows completed 
before i release it.  also the rest of my thread would not work properly if the 
task was not complete.  but for an added safety i can put it.  i know i can use 
readInBackgroundAndNotify to get asynchronous results and i started this way 
but i changed it because i got better results doing it on a thread.  except for 
of course these memory issues.  but only one selector in background method has 
a task the other 3 or 4 do not.
4.  i don't believe i'm having a problem with the arrays being accessed the 
same time by different threads.  although i am not using a lock.
5.  returning i am not doing. :-(  maybe a bad error on my part.  in the thread 
method my first line i alloc/init an autorelease pool and the last line i 
release the pool.  should my last line be return?  the method is void.
6.  activity monitor in snow leopard shows the threads terminating but the 
memory is not reclaimed.  in leopard i do not see the threads terminating or 
the memory being reclaimed.

at this point it seems my issue is with my threads.  i have maybe 4 methods i 
call by performSelectorinBackground and everytime i use this call i see the 
memory jump.  if i will test all the areas of my project and trigger all the 
thread calls my memory will jump the most.  once i will trigger one thread call 
even if i will repeat that call in my project the memory will jump to a certain 
point and that's it.  but if i will trigger another thread call the memory will 
jump again.  i know i need to get this right as i originally tried getting 
around using a thread by using a timer but it didn't quite cut it.  thanks 
again,

rick






From: Ken Thomases 
To: Rick C. 
Cc: cocoa dev 
Sent: Saturday, October 3, 2009 7:15:13 PM
Subject: Re: memory advice for still learning coder

On Oct 3, 2009, at 2:38 AM, Rick C. wrote:

> i'm having a few memory issues where my memory climbs over time although 
> using leaks it shows i have no leaks.

Leaks aren't the only way to use excessive memory.  For example, if you keep 
allocating objects and putting them in a collection somewhere (like the mutable 
arrays you describe below) but never use them and your code effectively forgets 
they are there due to a logic error, they haven't officially leaked but the 
effect is similar.

You can use the Object Alloc instrument.  When examining the recorded data, you 
can select a range of data.  Set its beginning to a point in time after your 
app should have reached equilibrium -- after it has set up those objects which 
are meant to stick around for the whole lifetime or your app.  Set the end of 
the range to any point afterward where the memory use has inexplicably risen.  
Tell the instrument to show only the still living objects.  This effectively 
shows you objects which were allocated and expected to be temporary, but which 
are still around.


> 1.  i have a handful of mutable arrays that i need for the lifetime of my 
> app.  i alloc/init them upon startup and at various places i do 
> removeAllObjects and then addObjectFromArray with the other array being 
> convenience created.  in dealloc i do release.

So long as you really are invoking removeAllObjects when you expect to be, and 
the other array only contains what you think it should, that sounds fine.


> 2.  i use NSObject performSelectorInBackground for a few methods so they do 
> not tie up my main thread.  one of these background methods uses NSTask.  in 
> every background method i init the autorelease pool and release it according 
> to the docs.  i also release the NSTask i use.

There have been reported issues with NSTask: if you don't run the run loop of 
the thread from which it was created and launched, then it might not clean up 
its resources.  -waitUntilExit should be sufficient.  If you're not waiting for 
the NSTask to complete, then there's little reason to launching it from a 
background thread.  So, you might be better of launching it from the main 
thread, where there's extra effort required to make sure the run loop is run.  
In fact, you can always use an NSTask from the main thread in an asynchronous 
fashion, and that may be a better design choice, depending on what else your 
background thread is doing.

>  and i do modify a few of the above mentioned mutable arrays in these 
> background methods in the way i described above.

I hope you're being careful to properly guard against multiple threads 
accessing any given mutable array at the same time.

Re: memory advice for still learning coder

2009-10-03 Thread Ken Thomases

On Oct 3, 2009, at 9:17 AM, Rick C. wrote:

5.  returning i am not doing. :-(  maybe a bad error on my part.  in  
the thread method my first line i alloc/init an autorelease pool and  
the last line i release the pool.  should my last line be return?   
the method is void.


Allowing the method to return doesn't require that there's a return  
statement.  I only mean that you allow execution to leave the method  
back to the caller.  As opposed to, for example, leaving it in a  
permanent loop or blocking call, such that the method (and, thus, the  
thread) never exits.



at this point it seems my issue is with my threads.  i have maybe 4  
methods i call by performSelectorinBackground and everytime i use  
this call i see the memory jump.  if i will test all the areas of my  
project and trigger all the thread calls my memory will jump the  
most.  once i will trigger one thread call even if i will repeat  
that call in my project the memory will jump to a certain point and  
that's it.  but if i will trigger another thread call the memory  
will jump again.


If you can trigger a very clear memory jump, that's a perfect  
candidate for the Object Alloc instrument analysis I described.   
Select a range covering the jump, have it show only the still-living  
objects, and those will be the ones accounting for the jump.


Regards,
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: memory advice for still learning coder

2009-10-03 Thread Ken Thomases

Oh, and I forgot to respond to this:

On Oct 3, 2009, at 9:17 AM, Rick C. wrote:

4.  i don't believe i'm having a problem with the arrays being  
accessed the same time by different threads.  although i am not  
using a lock.


If I'm understanding what you're saying, you're courting disaster.  If  
there's any chance at all that a mutable array is being mutated in one  
thread at the same time as another thread is accessing the array, then  
you must guard that with a lock.  The fact that (you think) you've  
never seen a problem in your testing so far is no guarantee that your  
app won't have a problem under different loads, on machines with  
different numbers of CPU cores, or just randomly but with somewhat low  
probability.  The possible problem might be obvious, like a crash, but  
it might be insidious like data corruption that isn't immediately  
noticed.


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

2009-10-03 Thread Frederick Bartram

Is there a way to do an asynchronous fetch request against Core data
returning partial results?
Try spawning the fetch in a background thread. There is an example of  
this in the CoreData sample project 'BackgroundFetching'. You will  
need to read up on the threading issues as in "don't share contexts!",  
"share coordinators."


I've used it the past for handling large/slow fetch requests.
gl.

Rick Bartram
*-
* Stop spam before it gets to your mailbox! Support blocklists.
* I use http://www.spamcop.net/.
* my PGP key id: 0x63fa758 keyserver: http://keyserver1.pgp.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


whether to use core data...

2009-10-03 Thread Colin Howarth
This is a long (but witty and interesting) rambling post about design,  
apple documentation, learning Obj-C & Cocoa and so on.



I'm writing a raytracing / lens design program. This is basically my  
fist serious attempt at a real Cocoa program, and whist I'm quite  
happy with C and Perl, I don't like Java and hate C++. So far  
Objective C is nice and simple, except that the compiler doesn't help  
much :-)


I've read Aaron's 'Cocoa Programming for Mac OS X' (1st & 3rd  
editions) which is, of course, excellent, and have Scott et all. 's  
'Cocoa Programming' which is, ummm, big (and good)  :-) (It's an old  
2003 edition though, so doesn't have anything on Core Data).



I've got over the initial "Huh? What's going on? Where's the code?"  
frustration. And the way IB keeps changing from one version to the  
next. Now I'm happy with Aaron's "click here, ctrl-drag that there,  
alt swish here - and look: it works!"


Right - now to the subject at hand...


Whilst scribbling some of my classes down on a bit of paper, and  
sorting out which objects are supposed to know what, I ended up with a  
class with just one instance (a singleton, I guess) called Lens. It  
contains an array of glass data (refractive index, dispersion  
constants etc.). It also contains an array of Elements (an 'element'  
being a single lens-shaped bit of glass. A 'lens' usually has lots of  
elements). [Well, that's wrong for starters! What does a Lens have to  
do with Schott's glass catalogue? Answer: nothing. The Element class  
needs to know what the various values are for the instances it creates  
- but I don't want the whole table in each element. A class variable  
in Element would have been ok...]


The actual program (which works) at present uses an array of Surfaces,  
but I realized that's not right.


Say you're holding a simple element (e.g. a magnifying glass). What's  
the surface made of? :-)


Also, how does a Surface know the distance to the next Surface? [--  
embarrassed silence -- Well? -- OK, it has a pointer to the app and  
accesses the app's array of surfaces... :-( --  Arrrgh! How *could*  
you?  -- OK, ok, I'm designing it now, all right?



Anyway, I ended up with a graph of Objects and methods which looks  
nice and consistent and -- clean!  :-)



The punchline:

Then, because it reminded me of something in Aaron's book, I just  
added  save:, load:, new: and -- undo: and thought "Ooooh, that looks  
like a perfect example of a Core Data application...



The reason for the post:

There's *a lot* of documentation to read on Core Data [oh, and on KVC,  
KVO, Instruments, Memory Management, Shark, GDB, Scripting, Unit  
Testing, Cocoa Drawing, Quartz, OpenGL, OpenCL and various other  
bits... "Haven't you read the documentation yet?", they ask. No, not  
all of it.]


But the Core Data documentation starts like this:

...
Core Data is not an entry-level technology.
...
You should not simply try to read [The Core Data Programming Guide]  
straight through to understand Core Data.

...
Do not attempt the NSPersistentDocument Core Data Tutorial unless or  
until you also understand Cocoa bindings.

...
Although Cocoa bindings and Core Data are independent and address  
different issues, both provide abstraction layers that—while  
individually they are reasonably straightforward to grasp—can be  
challenging to master simultaneously.



Bloody hell!

WARNING! Do not even ATTEMPT the NSPersistentDocument Core Data  
Tutorial! Your very MIND is in MORTAL DANDER!


Now that's a shame, because save: load: sounds like a persistent  
document to me. But if even Apple's documentation says WARNING, Do NOT  
attempt to read the Programming GUIDE in order to understand Core Data  
-- well, I believe 'em!


To be honest, I find Apple's documentation to be -- unhelpful -- at  
the best of times...



On the other hand, somewhere else it says that if I'm starting a new  
project (I am) or it does the sort of thing mine does (it does) I  
should definitely consider using Core Data. It even says "you should  
Definitely Consider it! OK? Got it? Good." which is sort of a threat.


Sooo, (you still with me?)

Should I face up to the dangers and brave the world of Core Data  
(damn! even "Core" sounds intimidating now) because, of course, the  
rewards (automatic undo, you don't need to write any code (hah!)) are  
great. And Aaron's example (click, click, bind, bind, click, swish -  
ooh! Look! You have an RDBMS with a GUI and undo -- and you didn't  
even touch the keyboard! Is that cool?) looks enticingly *simple* :-)


Or should I just have a nice simple "Lens" instance, which contains an  
array of "Element"s and will give me a nice array of "Surface"s if I  
ask it. And then do something more interesting, like turning the point  
spread function (done that) into a modulation transfer function,  
creating merit functions and bounds and implementing the relaxed,  
damped, orthonormal minimization routine? :-)


And 

Re: whether to use core data...

2009-10-03 Thread Sherm Pendley
On Sat, Oct 3, 2009 at 11:14 AM, Colin Howarth  wrote:
>
> But the Core Data documentation starts like this:
>
> ...
> Core Data is not an entry-level technology.
> ...
> You should not simply try to read [The Core Data Programming Guide] straight
> through to understand Core Data.
> ...
> Do not attempt the NSPersistentDocument Core Data Tutorial unless or until
> you also understand Cocoa bindings.
> ...
> Although Cocoa bindings and Core Data are independent and address different
> issues, both provide abstraction layers that—while individually they are
> reasonably straightforward to grasp—can be challenging to master
> simultaneously.
>
>
> Bloody hell!
>
> WARNING! Do not even ATTEMPT the NSPersistentDocument Core Data Tutorial!
> Your very MIND is in MORTAL DANDER!

Overreact much? We're talking about technical documentation, not an
H.P. Lovecraft novel. Cocoa bindings are a prerequisite for learning
Core Data, so you should learn that first. This is no different than
needing to learn algebra before attempting calculus. If you try it the
other way around, you'll waste a lot of time and probably end up
confused - not the best result, but a far cry from "mortal danger."

> Now that's a shame, because save: load: sounds like a persistent document to
> me. But if even Apple's documentation says WARNING, Do NOT attempt to read
> the Programming GUIDE in order to understand Core Data -- well, I believe
> 'em!

What part of "... should not simply try to read [it] straight through
..." implies that you shouldn't read it at all? You need to do the
exercises, maybe backtrack a little (or a lot) to review material you
didn't quite get the first time through, etc. Apple is simply saying
that the guide is a technical tutorial, not the latest John Grisham
novel!

> To be honest, I find Apple's documentation to be -- unhelpful -- at the best
> of times...

It'd be far more helpful if you skipped all the melodrama. It's not
"warning" you of "mortal danger," it's just describing the
prerequisites to learning about Core Data.

> And finally, how do Apple manage to make load: save: undo: sound more
> intimidating than quantum interference?

It's no more intimidating than a college catalog that says "you must
complete FOO101 before you can take BAR220."

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
___

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

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

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

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


Re: whether to use core data...

2009-10-03 Thread I. Savant


On Oct 3, 2009, at 11:14 AM, Colin Howarth wrote:

This is a long (but witty and interesting) rambling post about  
design, apple documentation, learning Obj-C & Cocoa and so on.



 [ big, massive, much-needed snip ]

  FOCUS!!!

  I get that you're trying to be witty, but I was forced to skim much  
of your "question" because it's mostly rambling. Witty is fine. Even a  
good dose of funny irrelevance, but you do need at least a *little*  
focus. :-)


  Following will be matter-of-fact, but not at all hostile. Please  
keep this in mind.


  You appear to be saying / asking four things:

1 - The documentation is large and unhelpful.

2 - You're trying for your first real Cocoa application.

3 - Is Core Data right for your project?

4 - How do I model my idea?


A1: A lot of beginners complain about this. A lot of intermediate to  
pros recognize that the documentation is far better than most  
platforms. The trick is, you just have to take the time to familiarize  
yourself with it. Study, study, study. This is a very large platform  
with a lot of powerful technologies. It's not a toy language or API by  
any stretch of the imagination. Finding your way around will take  
time. Learning what are clearly labeled as "advanced" technologies  
will require you to master the basics first (surprise!), so give it  
time and study.


A2: All the more reason to heed the warnings and stick to basics.  
Whether Core Data is a good match for your project or not (more on  
that in a second) is largely irrelevant since you have already  
indicated (I think - the rambling makes this hard to say for sure)  
that you haven't read the more basic technologies upon which Core Data  
is built. Therefore, your first app should use the most basic methods.  
Build your data structures with dictionaries, arrays, and NSCoder- 
compliant custom objects as you wish ... then write the main container  
to a file. There's your document format. Start with the basics, then  
move on to the voodoo.


A3: Is it right for your project? Possibly (see A4), but the better  
question is, "is it right for my skill level?" Best answer: an  
emphatic NO.


A4: The short answer: I have no idea. None whatsoever. It's hard to  
tell what your model is because your e-mail is extremely disorganized.  
I refer back to my opening point: You need to organize your thoughts  
into pointed descriptions and questions. Throw in some funny as you  
wish, but your entire e-mail is all but inscrutable. Clearly describe  
your best guess at the model layer (not a stream-of-consciousness  
ramble with lots of inline corrections) and the list will probably be  
able to help describe how your Managed Object Model should be  
constructed. As it stands, I couldn't tell what you were really trying  
to build.


  In closing: If you want help, follow technical mailing list  
etiquette and ask coherent questions. If you want to ramble and  
lament, tell it to the blogosphere. :-)


--
I.S.






I'm writing a raytracing / lens design program. This is basically my  
fist serious attempt at a real Cocoa program, and whist I'm quite  
happy with C and Perl, I don't like Java and hate C++. So far  
Objective C is nice and simple, except that the compiler doesn't  
help much :-)


I've read Aaron's 'Cocoa Programming for Mac OS X' (1st & 3rd  
editions) which is, of course, excellent, and have Scott et all. 's  
'Cocoa Programming' which is, ummm, big (and good)  :-) (It's an old  
2003 edition though, so doesn't have anything on Core Data).



I've got over the initial "Huh? What's going on? Where's the code?"  
frustration. And the way IB keeps changing from one version to the  
next. Now I'm happy with Aaron's "click here, ctrl-drag that there,  
alt swish here - and look: it works!"


Right - now to the subject at hand...


Whilst scribbling some of my classes down on a bit of paper, and  
sorting out which objects are supposed to know what, I ended up with  
a class with just one instance (a singleton, I guess) called Lens.  
It contains an array of glass data (refractive index, dispersion  
constants etc.). It also contains an array of Elements (an 'element'  
being a single lens-shaped bit of glass. A 'lens' usually has lots  
of elements). [Well, that's wrong for starters! What does a Lens  
have to do with Schott's glass catalogue? Answer: nothing. The  
Element class needs to know what the various values are for the  
instances it creates - but I don't want the whole table in each  
element. A class variable in Element would have been ok...]


The actual program (which works) at present uses an array of  
Surfaces, but I realized that's not right.


Say you're holding a simple element (e.g. a magnifying glass).  
What's the surface made of? :-)


Also, how does a Surface know the distance to the next Surface? [--  
embarrassed silence -- Well? -- OK, it has a pointer to the app and  
accesses the app's array of surfaces... :-( --  Arrrgh! How *could*  
you?  -- 

Keeping NSWindow below all other windows

2009-10-03 Thread PCWiz

Hi,

I have a full screen borderless NSWindow. The problem is that it  
covers all other windows (Finder windows and app windows). How do I  
make it so that the window is kept below ALL other windows.


Thanks
___

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

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

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

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


Re: whether to use core data...

2009-10-03 Thread Izidor Jerebic


On 3.10.2009, at 17:14, Colin Howarth wrote:



Now that's a shame, because save: load: sounds like a persistent  
document to me. But if even Apple's documentation says WARNING, Do  
NOT attempt to read the Programming GUIDE in order to understand  
Core Data -- well, I believe 'em!




On the other hand, somewhere else it says that if I'm starting a new  
project (I am) or it does the sort of thing mine does (it does) I  
should definitely consider using Core Data. It even says "you should  
Definitely Consider it! OK? Got it? Good." which is sort of a threat.




Extremely simplified way of describing CoreData is "easy to use  
database". So if you have something like a personal library  
application with list of books, CDs, DVDs etc. that can go into 1000s  
of items and application has GUI for searching, this would be natural  
choice for CoreData.


But not all persistent data is good choice for CoreData. If your  
application has few small objects (e.g. less than 100, each smaller  
than 10KB), and is using all of them (no searching), then simply  
persisting them with NSCoding protocol to a document file is probably  
good solution.


You can look at Sketch source code in Developer/Examples folder - this  
is a full drawing program with undo that saves its data in a document  
file using NSCoding protocol and not CoreData.



izidor

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: releasing a object containing others in a array

2009-10-03 Thread Kenneth Bruno II

As per:



"You take ownership of an object if you create it using a method whose  
name begins with “alloc” or “new” or contains “copy” (for example,  
alloc, newObject, or mutableCopy), or if you send it a retain message.  
You are responsible for relinquishing ownership of objects you own  
using release or autorelease. Any other time you receive an object,  
you must not release it."


If your object, at any point in its lifecycle, takes ownership of  
another object then it has to release that object or you'll have a  
potential resource leak.  Usually the best place to do this is in the  
dealloc method of the object.  When dealloc is called on your object  
it can run cleanup code and release anything it needs to release.  The  
runtime will then call dealloc on any objects that need it, and so  
on.  In this way your tree will traverse itself and deallocate any  
resources that need to be taken care of.


This is the great thing about following the memory management  
guidelines and good object oriented principles, your objects can  
mostly take care of themselves if you set them up properly.


Note that if you are using garbage collection most of this goes out  
the window.  The runtime will handle most of it for you, however you  
might still need to use stuff like the finalize method to take care of  
issues other than object ownership:





- Ken

On Oct 3, 2009, at 4:10 AM, Nick Rogers wrote:


Hi,

I have a class as following:

@interface NodeTypeOrph : NSObject {
int count;
ItemTypeOrph*key[4];   // Warning: indexing starts at 0, not 1
NodeTypeOrph*branch[5];   // Fake pointers to child nodes
}

when I'll send a release to an object of this type, will it  
automatically release the arrays of ItemTypeOrph and NodeTypeOrph  
objects.

Or do I have to explicitly traverse and release?


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: memory advice for still learning coder

2009-10-03 Thread Rick C.
thanks ken for all the input.  i will work on the things you've mentioned.  i 
really appreciate it!

rick






From: Ken Thomases 
To: Rick C. 
Cc: cocoa dev 
Sent: Saturday, October 3, 2009 10:37:11 PM
Subject: Re: memory advice for still learning coder

Oh, and I forgot to respond to this:

On Oct 3, 2009, at 9:17 AM, Rick C. wrote:

> 4.  i don't believe i'm having a problem with the arrays being accessed the 
> same time by different threads.  although i am not using a lock.

If I'm understanding what you're saying, you're courting disaster.  If there's 
any chance at all that a mutable array is being mutated in one thread at the 
same time as another thread is accessing the array, then you must guard that 
with a lock.  The fact that (you think) you've never seen a problem in your 
testing so far is no guarantee that your app won't have a problem under 
different loads, on machines with different numbers of CPU cores, or just 
randomly but with somewhat low probability.  The possible problem might be 
obvious, like a crash, but it might be insidious like data corruption that 
isn't immediately noticed.

Regards,
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: Keeping NSWindow below all other windows

2009-10-03 Thread Ron Fleckner


On 04/10/2009, at 3:12 AM, PCWiz wrote:


Hi,

I have a full screen borderless NSWindow. The problem is that it  
covers all other windows (Finder windows and app windows). How do I  
make it so that the window is kept below ALL other windows.


Thanks


[myWindow setLevel:];

check the docs.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Keeping NSWindow below all other windows

2009-10-03 Thread PCWiz

Thanks, setting the window level to -1 worked :)

On 2009-10-03, at 10:44 AM, Ron Fleckner wrote:



On 04/10/2009, at 3:12 AM, PCWiz wrote:


Hi,

I have a full screen borderless NSWindow. The problem is that it  
covers all other windows (Finder windows and app windows). How do I  
make it so that the window is kept below ALL other windows.


Thanks


[myWindow setLevel:];

check the docs.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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


Rounded NSBox/NSView?

2009-10-03 Thread PCWiz

Hi,

I want to create a NSBox or an NSView (doesn't matter which one) that  
has rounded corners. Now I know about NSBox's setCornerRadius method,  
and using NSBezierPath in an NSView subclass to draw a rounded rect.  
The problem with these 2 methods is that even though the rounded  
corners are drawn, anything inside the view (e.g. a table view) does  
not have rounded corners, only the view itself does. Is there any  
workaround for this?


Thanks
___

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

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

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

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


Re: Keeping NSWindow below all other windows

2009-10-03 Thread Sherm Pendley
On Sat, Oct 3, 2009 at 1:32 PM, PCWiz  wrote:
>
> On 2009-10-03, at 10:44 AM, Ron Fleckner wrote:
>
>>
>> [myWindow setLevel:];
>>
>> check the docs.
>
> Thanks, setting the window level to -1 worked :)

Don't do that. Magic numbers are considered very poor programming:




As Ron suggested - use one of the window level constants that are
described in the docs. That's why they're there!

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
___

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

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

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

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


Re: Keeping NSWindow below all other windows

2009-10-03 Thread PCWiz
The lowest constant I could find was 0 (NSNormalWindowLevel) and it  
still positioned itself above other windows. Is there a constant for  
-1 ?


On 2009-10-03, at 11:44 AM, Sherm Pendley wrote:


On Sat, Oct 3, 2009 at 1:32 PM, PCWiz  wrote:


On 2009-10-03, at 10:44 AM, Ron Fleckner wrote:



[myWindow setLevel:];

check the docs.


Thanks, setting the window level to -1 worked :)


Don't do that. Magic numbers are considered very poor programming:

   


As Ron suggested - use one of the window level constants that are
described in the docs. That's why they're there!

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net


___

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

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

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

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


Re: Keeping NSWindow below all other windows

2009-10-03 Thread Mike Abdullah

So logically you would specify your window to be:

[myWindow setLevel:(NSNormalWindowLevel - 1)];

On 3 Oct 2009, at 19:04, PCWiz wrote:

The lowest constant I could find was 0 (NSNormalWindowLevel) and it  
still positioned itself above other windows. Is there a constant for  
-1 ?


On 2009-10-03, at 11:44 AM, Sherm Pendley wrote:

On Sat, Oct 3, 2009 at 1:32 PM, PCWiz   
wrote:


On 2009-10-03, at 10:44 AM, Ron Fleckner wrote:



[myWindow setLevel:];

check the docs.


Thanks, setting the window level to -1 worked :)


Don't do that. Magic numbers are considered very poor programming:

  


As Ron suggested - use one of the window level constants that are
described in the docs. That's why they're there!

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net


___

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

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

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net

This email sent to cocoa...@mikeabdullah.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: whether to use core data...

2009-10-03 Thread Colin Howarth

On 3 Oct, 2009, at 18:07, Sherm Pendley wrote:

On Sat, Oct 3, 2009 at 11:14 AM, Colin Howarth   
wrote:


WARNING! Do not even ATTEMPT the NSPersistentDocument Core Data  
Tutorial!

Your very MIND is in MORTAL DANDER!


Overreact much? We're talking about technical documentation, not an
H.P. Lovecraft novel. Cocoa bindings are a prerequisite for learning
Core Data, so you should learn that first. This is no different than
needing to learn algebra before attempting calculus. If you try it the
other way around, you'll waste a lot of time and probably end up
confused - not the best result, but a far cry from "mortal danger."


I didn't _really_ think that I was in mortal danger, and H.P.Lovecraft  
isn't

scary at all.


What part of "... should not simply try to read [it] straight through
..." implies that you shouldn't read it at all? You need to do the
exercises, maybe backtrack a little (or a lot) to review material you
didn't quite get the first time through, etc.


I know, I know...


Apple is simply saying that the guide is a technical tutorial, not the
latest John Grisham novel!


Ah, but I don't read John Grisham novels. I read technical docs for  
fun and

relaxation. Usually they're precise, concise and clear.


To be honest, I find Apple's documentation to be -- unhelpful -- at  
the best

of times...


It'd be far more helpful if you skipped all the melodrama. It's not
"warning" you of "mortal danger," it's just describing the
prerequisites to learning about Core Data.


And finally, how do Apple manage to make load: save: undo: sound more
intimidating than quantum interference?


It's no more intimidating than a college catalog that says "you must
complete FOO101 before you can take BAR220."


OK, skipping the melodrama, there's something wrong with the Apple  
documentation,

but I can't quite put my finger on it.

The Perl man pages on nested data structures, say a dictionary  
containing arrays containing
other dictionaries which are actually representing objects, I find  
perfectly clear, for example.

And I did the first time I read it.

Take the Key-Value Coding Programming Guide which describes the  
NSKeyValueCoding informal protocol which
defines a mechanism allowing applications to access the properties of  
an object indirectly
by name (or key), rather than directly through invocation of an  
accessor method or as instance variables.


Translation: You'll find lots of useful things can happen if you  
access your instance variables
(e.g. the variable bar of the instance foo) like this:  baz =  
foo.bar;  foo.bar = baz; which is just
shorthand for baz = [foo bar]; and [foo setBar: baz]; . Other parts of  
your code can access bar simply

by knowing the string @"bar".

Actually, that's not a translation, it's more or less (less rather  
than more, I admit) the entire Key-Value

Coding Programming Guide. At least, it's enough to get you going.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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


Auto Install Login Item

2009-10-03 Thread David Blanton
Should my cocoa app write an entry to com.apple.loginitems.plist so it  
launches at login or is there a better way?


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: whether to use core data...

2009-10-03 Thread Mike Abdullah


On 3 Oct 2009, at 20:20, Colin Howarth wrote:

OK, skipping the melodrama, there's something wrong with the Apple  
documentation,

but I can't quite put my finger on it.

The Perl man pages on nested data structures, say a dictionary  
containing arrays containing
other dictionaries which are actually representing objects, I find  
perfectly clear, for example.

And I did the first time I read it.

Take the Key-Value Coding Programming Guide which describes the  
NSKeyValueCoding informal protocol which
defines a mechanism allowing applications to access the properties  
of an object indirectly
by name (or key), rather than directly through invocation of an  
accessor method or as instance variables.


Translation: You'll find lots of useful things can happen if you  
access your instance variables
(e.g. the variable bar of the instance foo) like this:  baz =  
foo.bar;  foo.bar = baz; which is just
shorthand for baz = [foo bar]; and [foo setBar: baz]; . Other parts  
of your code can access bar simply

by knowing the string @"bar".

Actually, that's not a translation, it's more or less (less rather  
than more, I admit) the entire Key-Value

Coding Programming Guide. At least, it's enough to get you going.


Well for a start your translation is wrong. Being able to do this:

baz = foo.bar;
foo.bar = baz;

is an Objective-C 2.0 feature – Dot Notation. It is completely  
orthogonal to Key-Value Coding.


Dot Notation works by the compiler figuring out which method calls the  
dots correspond to.


Key-Value Coding happens at run-time where the object receives a - 
valueForKey: or -setValue:forKey: message and then decides how to  
handle it based upon the key.


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Auto Install Login Item

2009-10-03 Thread Todd Heberlein


On Oct 3, 2009, at 12:30 PM, David Blanton wrote:

Should my cocoa app write an entry to com.apple.loginitems.plist so  
it launches at login or is there a better way?


Look at the documentation for launchd.

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Rounded NSBox/NSView?

2009-10-03 Thread Kyle Sluder

On Oct 3, 2009, at 10:35 AM, PCWiz  wrote:

The problem with these 2 methods is that even though the rounded  
corners are drawn, anything inside the view (e.g. a table view) does  
not have rounded corners, only the view itself does. Is there any  
workaround for this?


Set a mask on the graphics context? The problem is that the subviews  
don't expect rounded corners and will draw as normal, leading to  
artifacts like disappearing borders.


To do this satisfactorily you will need a wholly custom UI. Usually  
this is a red flag.


--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: Auto Install Login Item

2009-10-03 Thread Izidor Jerebic


On 3.10.2009, at 21:30, David Blanton wrote:

Should my cocoa app write an entry to com.apple.loginitems.plist so  
it launches at login or is there a better way?


See the documentation that answers exactly this question at:

< http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPSystemStartup/Articles/CustomLogin.html 
>



izidor

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: whether to use core data...

2009-10-03 Thread Colin Howarth

On 3 Oct, 2009, at 18:08, I. Savant wrote:


[ big, massive, much-needed snip ]


hmmph.


 FOCUS!!!

 I get that you're trying to be witty, but I was forced to skim much  
of your "question" because it's mostly rambling. Witty is fine. Even  
a good dose of funny irrelevance, but you do need at least a  
*little* focus. :-)


Yes, Master. I'll try to focus.


No! There is no "try"! There is only "do" or "do not"!


OK. I am focussed.

Hey I get it!  Lens Design Program...  focus.  Vry good!  :-)


 Following will be matter-of-fact, but not at all hostile. Please  
keep this in mind.


 You appear to be saying / asking four things:

1 - The documentation is large and unhelpful.


Yes. A bit. Sometimes.


A1: A lot of beginners complain about this.


OK.



2 - You're trying for your first real Cocoa application.


That was just for background info. Wasn't a complaint or question, as  
such.
(I was also trying to make it clear that I'm not a wannabe iPhone  
developer,

with a "write my app for me" question.)



3 - Is Core Data right for your project?


That was sort of my actual technical question. :-)

Should I face up to the dangers and brave the world of Core  
Data ... Or should I just have a nice simple "Lens" instance, [and  
get on with the guts of the program]


... and you came up with an exquisitely simple, clear and precise  
answer. :-)


A3: Is it right for your project? Possibly (see A4), but the better  
question is, "is it right for my skill level?" Best answer: an  
emphatic NO.


Thanks. Although, more precisely, the question is "should I dive in  
now and get to grips with it, or leave it for later." which only I can  
answer, I suppose.




4 - How do I model my idea?


Nooo.

Anyway, I ended up with a graph of Objects and methods which looks  
nice and consistent and -- clean!  :-)


I'm happy with my model. And I'm certain it would benefit from Core  
Data.



A1: A lot of beginners complain about this. A lot of intermediate to  
pros recognize that the documentation is far better than most  
platforms.


That's not saying much :-)

The trick is, you just have to take the time to familiarize yourself  
with it. Study, study, study. This is a very large platform with a  
lot of powerful technologies. It's not a toy language or API by any  
stretch of the imagination. Finding your way around will take time.  
Learning what are clearly labeled as "advanced" technologies will  
require you to master the basics first (surprise!), so give it time  
and study.


OK.

A2: All the more reason to heed the warnings and stick to basics.  
Whether Core Data is a good match for your project or not (more on  
that in a second) is largely irrelevant since you have already  
indicated (I think - the rambling makes this hard to say for sure)  
that you haven't read the more basic technologies upon which Core  
Data is built.


No, I read the Core Data Basics chapter of the  Core Data Programming  
Guide, I'm happy enough with KVC and KVO for now - at least my  
bindings between an NSTableView, NSArrayController and my NSArray are  
fine. So, I'm sort of OK with bindings, notifications and delegation,  
although not thoroughly immersed in the mind set. Yet. So, according  
to the recommended learning path, the next step would be going through  
the tutorial (which it later says, is NOT how you do things...)


Therefore, your first app should use the most basic methods. Build  
your data structures with dictionaries, arrays, and NSCoder- 
compliant custom objects as you wish ... then write the main  
container to a file. There's your document format. Start with the  
basics, then move on to the voodoo.


Right. Voodoo, later.

A3: Is it right for your project? Possibly (see A4), but the better  
question is, "is it right for my skill level?" Best answer: an  
emphatic NO.


A4: The short answer: I have no idea. None whatsoever. It's hard to  
tell what your model is because your e-mail is extremely disorganized.


Hah! It is not!


a) This is what I know so far.

b) This is what I've done / am doing.

c) I noticed that Core Data looks like it would fit well.

d) But, problem: The documentation looks a bit hairy.

e) Question: Should I have a go, or leave it for a bit?


I even put double lines in between sections :-)


I refer back to my opening point: You need to organize your thoughts  
into pointed descriptions and questions. Throw in some funny as you  
wish, but your entire e-mail is all but inscrutable.


Damn! Just what I was complaining about :-(

Clearly describe your best guess at the model layer (not a stream-of- 
consciousness ramble with lots of inline corrections) and the list  
will probably be able to help describe how your Managed Object Model  
should be constructed. As it stands, I couldn't tell what you were  
really trying to build.


 In closing: If you want help, follow technical mailing list  
etiquette and ask coherent questions. If you want to ramble and  
lament, tell it 

NSPasteboard -> NSTextView

2009-10-03 Thread Knut Lorenzen

Dear List,

My App receives RTF (or RTFD) data via Drag & Drop:

- (BOOL)performDragOperation:(id )sender {
NSPasteboard *pboard;
pboard = [sender draggingPasteboard];
.
.
.

and checks with

if ( [[pboard types] containsObject: NSPasteboardTypeRTF] ) { ...

for available data types. The documentation on NSTextView is  
overwhelming to some degree, I only want to display the dropped data  
in a NSTextView (in code).


How do I assign the RTF(D) in NSPasteboard to my NSTextView  
*programmatically*?


Cheers,

Knut





___

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

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

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

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


Re: whether to use core data...

2009-10-03 Thread Colin Howarth

On 3 Oct, 2009, at 21:31, Mike Abdullah wrote:


Well for a start your translation is wrong. Being able to do this:

baz = foo.bar;
foo.bar = baz;

is an Objective-C 2.0 feature – Dot Notation. It is completely  
orthogonal to Key-Value Coding.


Dot Notation works by the compiler figuring out which method calls  
the dots correspond to.


Key-Value Coding happens at run-time where the object receives a - 
valueForKey: or -setValue:forKey: message and then decides how to  
handle it based upon the key.


Hey, stop trying to confuse me. :-)

I know the dot notation is an Objective C 2.0 feature - and I was  
assuming you experts knew it too. I didn't want to confuse things by  
mentioning attributed properties, since that's not the point.


If you use dot notation and properties, you are using the -value and - 
setValue: accessor methods, which is KVC compliant and means that KVO  
bits will get notified, no?___


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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: whether to use core data...

2009-10-03 Thread Colin Howarth

On 3 Oct, 2009, at 17:39, Volker in Lists wrote:
have you filled a bug report? - Yes, can do this for documentation.  
Might lead to the responsible person fastest. So, if not yet done,  
hurry and do so!


But the documentation isn't wrong. It isn't even unclear, if you know  
exactly what its trying to say. :-)


in addition: Yes, CoreData is nothing for the beginner - something  
you realize when you first run into trouble and need a very good  
understanding of the underlying techniques. But since you don't  
believe the docs, you won't believe me neither.


But if even Apple's documentation says WARNING, Do NOT attempt to  
read the Programming GUIDE in order to understand Core Data --  
well, I believe 'em!


??? I *DO* believe the docs.

--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: whether to use core data...

2009-10-03 Thread Colin Howarth

On 3 Oct, 2009, at 18:12, Izidor Jerebic wrote:


Extremely simplified way of describing CoreData is "easy to use  
database". So if you have something like a personal library  
application with list of books, CDs, DVDs etc. that can go into  
1000s of items and application has GUI for searching, this would be  
natural choice for CoreData.


But not all persistent data is good choice for CoreData. If your  
application has few small objects (e.g. less than 100, each smaller  
than 10KB), and is using all of them (no searching), then simply  
persisting them with NSCoding protocol to a document file is  
probably good solution.


Hmmm, thanks for pointing that out. Although, I liked the undo idea...


--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: NSPasteboard -> NSTextView

2009-10-03 Thread Kyle Sluder

On Oct 3, 2009, at 12:59 PM, Knut Lorenzen  wrote:

How do I assign the RTF(D) in NSPasteboard to my NSTextView  
*programmatically*?


Deserialize the data off the pasteboard, and mutate the text view's  
associated text storage. Undo events will be logged correctly, but you  
may want to set the undo group name to be a bit more descriptive.


Hope that helps,
--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: whether to use core data...

2009-10-03 Thread Greg Guerin

Colin Howarth wrote:


This is basically my first serious attempt at a real Cocoa program,


This statement has no context.

What less-than-serious attempts have you made at less-than-real Cocoa  
programs?  Were all those attempts successful, i.e. did they result  
in a working program for whatever less-than-real task they were  
supposed to perform?


One person's idea of "serious" or "real" can be very different from  
another person's.  You haven't described your experience level in  
making working Cocoa programs, so it's difficult to advise whether  
Core Data is beyond your skills or not.


You also haven't described your tolerance for risk or outright failure.

Suppose you create a Core Data model, and spend weeks or months  
trying to get the app working, but are not successful.  At what point  
would you be willing to say that you're in over your head and should  
stop trying to use Core Data?  In other words, when would you admit  
defeat and do something else?


Some risk-tolerance will depend on why you're writing the lens app in  
the first place, and what deadlines there are, if any.  If it's for  
your own learning and/or amusement, then maybe you should try Core  
Data, after reading the prerequisite docs first.  The primary goal is  
learning, even if the app never works.  However, if it's for a  
product that has to ship on someone else's schedule, maybe you  
shouldn't use Core Data right away, but get your basic design working  
first and then re-evaluate if necessary.  You may find that using  
other mechanisms gives you what you need, as well as a basis for  
possible future use of Core Data.


  -- 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: Auto Install Login Item

2009-10-03 Thread Jens Alfke


On Oct 3, 2009, at 12:38 PM, Todd Heberlein wrote:


On Oct 3, 2009, at 12:30 PM, David Blanton wrote:

Should my cocoa app write an entry to com.apple.loginitems.plist so  
it launches at login or is there a better way?


Look at the documentation for launchd.


No, launchd is not in charge of user-visible login items, only  
background agents. See the second answer to the question.


—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


Re: NSPasteboard -> NSTextView

2009-10-03 Thread Mark Munz
You might just go with some built-in NSTextView methods:

- (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard

which should take the richest data type available or if you want to
specify the type:

- (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard type:(NSString *)type



On Sat, Oct 3, 2009 at 1:13 PM, Kyle Sluder  wrote:
> On Oct 3, 2009, at 12:59 PM, Knut Lorenzen  wrote:
>
>> How do I assign the RTF(D) in NSPasteboard to my NSTextView
>> *programmatically*?
>
> Deserialize the data off the pasteboard, and mutate the text view's
> associated text storage. Undo events will be logged correctly, but you may
> want to set the undo group name to be a bit more descriptive.
>
> Hope that helps,
> --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/unmarked%40gmail.com
>
> This email sent to unmar...@gmail.com
>



-- 
Mark Munz
unmarked software
http://www.unmarked.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: Auto Install Login Item

2009-10-03 Thread Kyle Sluder

On Oct 3, 2009, at 2:26 PM, Jens Alfke  wrote:

No, launchd is not in charge of user-visible login items, only  
background agents. See the second answer to the question.


On 10.5 and up, launchd can now handle per-user agents that need to  
launch in a GUI bootstrap namespace. So if you are writing an agent  
that might display some UI, launchd is a valid option. (I keep waiting  
for iTunesHelper to move there and get the heck out of my login items.)


That said, just because your app doesn't have a dock icon does not  
mean you should start it with launchd. Apps like Twiterriffic belong  
in Login Items.


And if you're going to offer UI in your preferences for enabling  
launch at login, make sure you also have UI to turn that off. Better  
yet, don't offer that UI at all.


/rant

--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: whether to use core data...

2009-10-03 Thread Colin Howarth


On 3 Oct, 2009, at 23:05, Greg Guerin wrote:


Colin Howarth wrote:


This is basically my first serious attempt at a real Cocoa program,


This statement has no context.

What less-than-serious attempts have you made at less-than-real  
Cocoa programs?  Were all those attempts successful, i.e. did they  
result in a working program for whatever less-than-real task they  
were supposed to perform?


One person's idea of "serious" or "real" can be very different from  
another person's.  You haven't described your experience level in  
making working Cocoa programs, so it's difficult to advise whether  
Core Data is beyond your skills or not.


You also haven't described your tolerance for risk or outright  
failure.


Suppose you create a Core Data model, and spend weeks or months  
trying to get the app working, but are not successful.  At what  
point would you be willing to say that you're in over your head and  
should stop trying to use Core Data?  In other words, when would you  
admit defeat and do something else?


Some risk-tolerance will depend on why you're writing the lens app  
in the first place, and what deadlines there are, if any.  If it's  
for your own learning and/or amusement, then maybe you should try  
Core Data, after reading the prerequisite docs first.  The primary  
goal is learning, even if the app never works.  However, if it's for  
a product that has to ship on someone else's schedule, maybe you  
shouldn't use Core Data right away, but get your basic design  
working first and then re-evaluate if necessary.  You may find that  
using other mechanisms gives you what you need, as well as a basis  
for possible future use of Core Data.


 -- 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/colin%40howarth.de

This email sent to co...@howarth.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: Auto Install Login Item

2009-10-03 Thread John Joyce
Please don't do that without asking users first. To do so would be  
Microsoftian


iPhoneから送信

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Auto Install Login Item

2009-10-03 Thread Kyle Sluder
On Oct 3, 2009, at 2:50 PM, John Joyce > wrote:


Please don't do that without asking users first. To do so would be  
Microsoftian


It was Skype for me. But yes, this is a very important point, thank  
you for remembering to make it. :-)


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


KVC, KVO and dot notation. Was: whether to use core data...

2009-10-03 Thread Colin Howarth

On 3 Oct, 2009, at 23:51, Klaus Backert wrote:

On 3 Oct 2009, at 22:06, Colin Howarth wrote:

If you use dot notation and properties, you are using the -value  
and -setValue: accessor methods, which is KVC compliant and means  
that KVO bits will get notified, no?


No.

From the documentation "The Objective-C 2.0 Programming Language":
--
You can think of a property declaration as being equivalent to  
declaring two accessor methods. Thus

@property float value;
is equivalent to:
- (float)value;
- (void)setValue:(float)newValue;
A property declaration, however, provides additional information  
about how the accessor methods are implemented

--

Accessing using dot notation

myObject.value = x;
x = myObject.value;

is equivalent to accessing using conventional notation

[myObject setValue: x];
x = [myObject value];

This all may be something which is KVC compliant -- or it may not be  
--, as you can see in the "Key-Value Coding Programming Guide",  
chapter "Ensuring KVC Compliance".



OK, since this is perhaps a relevant example of what I was talking  
about, let's compare my off the cuff sentence with the Apple Docs:


If you use dot notation and properties, you are using the -value  
and -setValue: accessor methods, which is KVC compliant and means  
that KVO bits will get notified, no?





Ensuring KVC Compliance

In order for a class to be considered KVC compliant for a specific  
property, it must implement the methods required for valueForKey: and  
setValue:forKey: to work for that property.


Attribute and To-One Relationship Compliance

For properties that are an attribute or a to-one relationship, this  
requires that:


	• Your class implements a method named -, -is, or has an  
instance variable  or_.

• If the property is mutable, then it should also implement -set:.
	• Your implementation of the -set: method should not perform  
validation.
	• Your class should implement -validate:error: if validation is  
appropriate for the key.



<<< I have an instance variable named . The methods - and - 
set: have been synthesized. Validation is inappropriate >>>




Indexed To-Many Relationship Compliance

For indexed to-many relationships, KVC compliance requires that your  
class:


• Implements method named - that returns an array.
• Or has an array instance variable named  or _.
	• Or implements the method -countOf and one or both of - 
objectInAtIndex: or -AtIndexes:.
	• Optionally, you can also implement -get:range: to improve  
performance.



<<< I have an array instance variable named . Performance is not  
an issue. >>>




For a indexed ordered to-many relationship, KVC compliance requires  
that your class also:


	• Implement one or both of the methods -insertObject:inAtIndex:  
or -insert:atIndexes:.
	• Implement one or both of the methods -removeObjectFromAtIndex:  
or -removeAtIndexes:.
	• Optionally, you can also implement - 
replaceObjectInAtIndex:withObject: or - 
replaceAtIndexes:with: to improve performance.


<<< Oooh, tut, tut. That should probably read "For a MUTABLE indexed  
ordered to-many relationship", or, at least, "For AN indexed ..." >>>



Unordered To-Many Relationship Compliance

For unordered to-many relationships, KVC compliance requires that your  
class:


• Implements method named - that returns a set.
• Or has an set instance variable named  or _.
	• Or implements the methods -countOf, -enumeratorOf, and - 
memberOf:.



<<< Ah. Little typo: "Or has A set".   I don't have any set instance  
variables, but if I did, they would be named .  >>>




For a mutable unordered to-many relationship, KVC compliance requires  
that your class also:


• Implement one or both of the methods -addObject: or -add:.
	• Implement one or both of the methods -removeObject: or - 
remove:.
	• Optionally, you can also implement -intersect: and -set:  
to improve performance.


<<< I don't have a "mutable unordered to-many relationship" aka as a  
"set" >>>




So, on the assumption that I have the relevant instance variables,  
which I do, my statement is basically correct. Except that it doesn't  
cover instance variables that are "mutable unordered or indexed and/or  
ordered to-many relationships" - but then it (my statement) is a  
little shorter, isn't it?



--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: View shifted up on iPhone simulator

2009-10-03 Thread Anthony Smith
Thanks for the input. I was just trying to load a particular XIB based  
on the device being used. Each XIB would communicate something  
different. It sounds like I can scratch this idea for something  
simpler using UIViewController. I'll reread the programming and  
reference guides and rethink my solution. Again, thanks for the input!


On Oct 2, 2009, at 8:37 PM, Hank Heijink (Mailinglists) wrote:

I second the previous poster's opinion: view controllers are  
definitely the way to go here. They'll let you take care of rotation  
and plenty of other stuff: read the view controller programming  
guide. Using a view controller gives you many more places to  
customize what happens.


There's viewDidLoad for initial setup, viewDidUnload for cleanup,  
viewWillAppear, viewDidAppear, and related methods for more frequent  
stuff, you name it. See the documentation for UIViewController.


What you want to achieve is easily done in viewDidLoad, or if you  
want to have complete control without using Interface Builder, in  
loadView. Depending on how different your views are depending on the  
device, there may be simpler solutions.


Good luck,
Hank

On Oct 2, 2009, at 4:08 PM, Anthony Smith wrote:

Hm, I opted to set the view's programmatically rather than through  
a controller so I could control what view is initially displayed  
depending on the device (iPhone, iPod, etc.). I'm assuming I will  
be able to achieve something like this even when using view  
controllers?


On Oct 2, 2009, at 3:56 PM, Christopher J Kemsley wrote:


Hmm I have a few comments:

It look like you're seeing the superposition of two problems that  
look like one:


1) The status bar is covering up the very top of your view in the  
sim


2) The bottom button is 20px further from the bottom in the sim


The interface builder likes to make views default to a height of  
460, not 480. I always change mine to 480 before I start using  
them. From your pictures, it looks like this is the culprit -  
that, and the status bar covering up the top. In order to change  
it, you must disable the 'simulate status bar' option in the  
view's inspector.


I believe that view is designed to be shown in a view controller  
who takes the status bar into account already. I also believe that  
you simply added the view as a subview of the window, which is  
what caused the status bar to cover up the top. (also, the  
interface builder shows you what the view would look like in a  
view controller that takes the status bar into account)


From this, you have a few options:

1) Disable the status bar in your application, set the view's  
"Simulated Interface Elements" to not show the status bar, then  
change the hight of the view to 480. To disable the status bar in  
your application, go to its info.plist, add a new row, scroll to  
the bottom, select "Status Bar is Initially Hidden" and set it to  
TRUE.


2) Use a view controller to show your view. I didn't fully  
understand just what the controllers did until after a very long  
time of tinkering, but they're a godsend... or, an apple-send in  
this case. They'll help making stuff like that line up, though  
only after you understand them.


or 3) Use both the above options (this is my recommendation)




On 2 Oct 2009, at 12:28 PM, Anthony Smith wrote:

When I run my app in the iPhone simulator the view seems to be  
shifted up on the screen. If that doesn't make sense I've  
uploaded some images. Take a look and see if you've run into this  
before.


http://projects.sticksnleaves.com/iphonedev/ib.png

http://projects.sticksnleaves.com/iphonedev/sim.png

Thanks!___

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

Please do not post admin requests or moderator comments to the  
list.

Contact the moderators at cocoa-dev-admins(at)lists.apple.com

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

This email sent to kd7...@gmail.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/hank.list%40runbox.com

This email sent to hank.l...@runbox.com






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

main nib, firing a secondary nib and it's controller....

2009-10-03 Thread jon
i want to have a WindowController object and it's own nib separate  
from the main nib..


but i want this secondary nib and controller to fire up when the  
application launches...


what is the best way to do that?

thanks in advance,
Jon.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Keeping NSWindow below all other windows

2009-10-03 Thread PCWiz

Thanks, that works :-)

On 2009-10-03, at 12:14 PM, Alexander Heinz wrote:

You could just use (NSNormalWindowLevel - 1). That should be clear  
to anyone reading the code that you want the level below the lowest.


- Alex

On Oct 3, 2009, at 2:04 PM, PCWiz wrote:

The lowest constant I could find was 0 (NSNormalWindowLevel) and it  
still positioned itself above other windows. Is there a constant  
for -1 ?


On 2009-10-03, at 11:44 AM, Sherm Pendley wrote:

On Sat, Oct 3, 2009 at 1:32 PM, PCWiz   
wrote:


On 2009-10-03, at 10:44 AM, Ron Fleckner wrote:



[myWindow setLevel:];

check the docs.


Thanks, setting the window level to -1 worked :)


Don't do that. Magic numbers are considered very poor programming:

 


As Ron suggested - use one of the window level constants that are
described in the docs. That's why they're there!

sherm--


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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


Working with an Unsupported Character Encoding (ANSEL)

2009-10-03 Thread Thomas Wetmore
I am writing software to handle GEDCOM files. These files are usually  
in ASCII format, though some are in ANSEL format (the format they are  
supposed to be in), and in recent years more and more are in UNICODE  
encodings. A GEDCOM file is supposed to include an attribute that  
specifies its character set, but, as in HTML files, they are not  
always there, or if there, they are not always correct. And if they  
are in UNICODE the attribute does not specify the specific encoding.


ANSEL is an 8-bit encoding where the lower half is ASCII and the upper  
half includes some non-spacing diacritics as well as a few specific  
Latin letter and diacritic combinations. There is no Cocoa/NSString/ 
CFString support for ANSEL that I have found.


My current approach is to read the file using NSASCIIStringEncoding  
and to then determine the encoding of the file by scanning through it.  
I decided to do this since most files are indeed ASCII so in most  
cases no further I/O or character conversion is needed.


While scanning the file I look for the attribute that specifies what  
the file should be, but I also do other checks. For example I check  
whether any of the upper half bytes are illegal ANSEL. And I check for  
UTF-8 multi-byte encodings. At the end I know whether the file is  
either valid ASCII, not ASCII but valid ANSEL, not ASCII or ANSET but  
vaild UTF-8, and if it's not valid as any of those three I assume it's  
UTF-16.


If the file is UTF-8 or UTF-16 I can just reread it with the correct  
encoding. However, if it is ANSEL I must do some delicate fiddling to  
convert it to Unicode.


I am relatively new to Cocoa and NSStrings, so this has lead to a few  
questions.


1. Apparently reading a file to an NSString using the  
NSASCIIStringEncoding returns each of the bytes of the file exactly as  
they were, that is, the 8-bit bytes seem to be read exactly as they  
were. So is it true that reading with NSASCIIStringEncoding doesn't  
mess around with any of the 8-bit bytes in the file?


2. Given I have an NSString that I read in as NSASCIIStringEncoding  
but I later determine it should have been read as UTF8 or UTF16, can I  
transform that NSString in place, or must I reread the file with the  
proper encoding? I don't mind doing the latter, but if there is  
conversion solution it would have better performance.


3. I'm imagining two ways to do the ANSEL to UNICODE transformation to  
get the NSString.
   a. Create a C-array of 16-bit shorts and convert the ANSEL to pure  
UNICODE. Is there an API to convert a such a C-array of 16-bit shorts  
to an NSString?
   b. Create a new NSString directly by building it up character by  
character. Would performance suffer greatly over the former approach?

   c. Is there an easier approach I am not seeing?

Thanks very much for any advice.

Tom Wetmore
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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


Probs with "BetterAuthorizationSample"-code

2009-10-03 Thread Frank W. Tag

Dear all,

as a preface: Hopefully this is the right discussion group for my  
question - otherwise I apologize for the inconveniance and would ask  
you for a hint to the right one ...


I am trying around with the "BetterAuthorizationSample"-code to  
perform privileged system calls in a mostly secure environment.


Everything seemed to work right after introducing the sample stuff to  
my project but now I have some major problems that I cannot solve by  
myself:


1.	How can I debug my HelperTool? Obviously any breakpoints set in  
XCode won't work because the HelperTool is launched outside by the  
launchd.
2.	My idea is to use asl to debug "barefoot". But for that I have to  
install aeach time when I have compiled a modified version of the  
HelperTool to the system. But how to do this? InstallerTool does not  
do this itself.
3.	How can I deinstall the whole stuff and reinstall it again? To be  
more precise: I tried like described in 1. and 2. but now the whole  
thing does not work proper. I removed my files from any place it was  
stored by hand but the InstallerTool denied to re-install the  
HelperTool. And the launchd throws every 10 seconds an error message  
like "cannot start  ..." and so on. Than I copied the  
HelperTool (with root:admin) to the dedicated folder but lanchd has  
other probs. ... So my idea is to deinstall the whole stuff to clean  
up and start again from 0.


Any ideas? I would be very grateful for any input ...

Best regards
Frank

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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


list editor (iPhone)

2009-10-03 Thread Nigel Redmon
I'm writing a simple calculator-like security code lookup app--as a  
first iPhone app and learning experience, and because it's useful for  
me. It's for a brokerage service for which the user must go through a  
challenge-response process to log on. That is, after the user logs on  
with username and password, the system generates a pair of numbers,  
1-224 each. The user has a plastic card (credit-card sized) that has a  
list of 224 three-character codes, unique to their account. Mainly,  
this kind of system thwarts key-logging type scammers.


Looking the codes up on the card is a pain. Also, the brokerage now  
has an iPhone app, but of course if you don't carry the cards around  
with you at all times, you're out of luck trying to log on. So, I  
wrote an app that looks up the codes--tap one field, type in a number  
form 1-224, its corresponding code pops up, tap the other field, type  
the second number, and you now have your two sets of codes to type  
into the response field.


For my own use, I just typed my codes into a spread sheet, exported,  
formatted, and stuck it into an array of 3-character strings in the  
code. But since this would be useful for others, I might put to up as  
a free app, in which case I need to write an editor that allows a user  
to type in his own card-codes. I also support multiple accounts, since  
I have a main account and and ira account with the brokerage. More  
importantly, perhaps, is that it will serve as a good exercise  
(learnings both iPhone, Cocoa, and Objective-C for the first time) by  
turning it into a consumer-friendly completed app.


So, my question is... Is there an obvious format, or even pre-existing  
object, that would be convenient and adhere to the user interface  
guidelines?


To be clear: There would be 224 entries, labeled 1-224, and the user  
would enter three characters (capital A-Z, and 0-9). For example:


1: HV3
2: CGF
3: 6K7
...

I suppose I would have and Accounts page, where the user could make a  
new account and enter the values from the corresponding card, or edit  
and existing account's codes in case of entry error. I'll have  
something like a Picker view on the main calculator-like page so that  
the user can quickly change to another account for code lookup.


Any suggestions on the data entry/editing view? I can figure something  
out that works of course--I'm mainly asking here in order to see if  
there is a familiar and guidelines-friendly way to do it.


Thanks,

Nigel
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Probs with "BetterAuthorizationSample"-code

2009-10-03 Thread Todd Heberlein
1.	How can I debug my HelperTool? Obviously any breakpoints set in  
XCode won't work because the HelperTool is launched outside by the  
launchd.
2.	My idea is to use asl to debug "barefoot". But for that I have to  
install aeach time when I have compiled a modified version of the  
HelperTool to the system. But how to do this? InstallerTool does not  
do this itself.


I have used asl_log() messages as a substitute for printf(). The  
messages goes to your Console (the one under /Applications/Utilities)  
and not to the "Console" in Xcode, so make sure you are looking in the  
right place for output.


I think printf() will just cause the HelperTool to exit with error.

Every time I modify any code used by my helper tool I run

$ ./SampleUninstall.sh

I just had to change all the references in the shell script to my  
application's Identifier. For example, my modified shell script has  
the lines:


sudo launchctl unload -w /Library/LaunchDaemons/ 
com.netsq.ACManager.plist

sudo rm /Library/LaunchDaemons/com.netsq.ACManager.plist
sudo rm /Library/PrivilegedHelperTools/com.netsq.ACManager
sudo rm /var/run/com.netsq.ACManager.socket

And the Cocoa app's "Identifier" in the target's property window is:

com.netsq.${PRODUCT_NAME:rfc1034identifier}

(the Project is called ACManager) so "com.netsq.ACManager" is inserted  
in all the appropriate places in the script.


If things are really screwed up, you can look in the directories  
identified in the shell script, remove the appropriate files by hand,  
and then logout and log back in (if that doesn't solve your launchctl  
errors you may need to reboot as a crude but effective step).


But once you have your SampleUninstall.sh script set up correctly,  
running it each time you make code modifications should work.


Todd

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Working with an Unsupported Character Encoding (ANSEL)

2009-10-03 Thread Adam R. Maxwell


On Oct 3, 2009, at 8:11 AM, Thomas Wetmore wrote:

While scanning the file I look for the attribute that specifies what  
the file should be, but I also do other checks. For example I check  
whether any of the upper half bytes are illegal ANSEL. And I check  
for UTF-8 multi-byte encodings. At the end I know whether the file  
is either valid ASCII, not ASCII but valid ANSEL, not ASCII or ANSET  
but vaild UTF-8, and if it's not valid as any of those three I  
assume it's UTF-16.


Can you check for a Unicode BOM for UTF-16, too?  Regardless, instead  
of reading the file as an NSString, I'd recommend reading it into  
NSData, particularly if you want to look at raw bytes.  NSString is  
not a generic byte container, and you can run into problems if you  
specify an incorrect encoding.


If the file is UTF-8 or UTF-16 I can just reread it with the correct  
encoding. However, if it is ANSEL I must do some delicate fiddling  
to convert it to Unicode.


I am relatively new to Cocoa and NSStrings, so this has lead to a  
few questions.


1. Apparently reading a file to an NSString using the  
NSASCIIStringEncoding returns each of the bytes of the file exactly  
as they were, that is, the 8-bit bytes seem to be read exactly as  
they were. So is it true that reading with NSASCIIStringEncoding  
doesn't mess around with any of the 8-bit bytes in the file?


I don't know if you can rely on this; NSData is safer, as I mentioned  
above.


2. Given I have an NSString that I read in as NSASCIIStringEncoding  
but I later determine it should have been read as UTF8 or UTF16, can  
I transform that NSString in place, or must I reread the file with  
the proper encoding? I don't mind doing the latter, but if there is  
conversion solution it would have better performance.


No, you'd need to reread it.  However, if you read it as NSData, you  
can create the string using initWithData:encoding:.


3. I'm imagining two ways to do the ANSEL to UNICODE transformation  
to get the NSString.
  a. Create a C-array of 16-bit shorts and convert the ANSEL to pure  
UNICODE. Is there an API to convert a such a C-array of 16-bit  
shorts to an NSString?


NSString's initWithCharacters:length: will read a C array of Unichars  
(UTF-16).


  b. Create a new NSString directly by building it up character by  
character. Would performance suffer greatly over the former approach?


I'd avoid that, unless you're dealing with small strings.  If your  
conversion operates at the character level, stick with C arrays or  
NSMutableData; if you need to combine a unichar buffer with the  
convenience of NSMutableString, you can use  
CFStringCreateMutableWithExternalCharactersNoCopy, but that can be  
tricky.



  c. Is there an easier approach I am not seeing?


I noticed that CFStringEncoding lists kCFStringEncodingANSEL as an  
external encoding, but CFStringIsEncodingAvailable returns false,  
unfortunately.  You could probably write a plugin for the Text  
Encoding Converter, but I've never tried that myself.


http://developer.apple.com/mac/library/documentation/Carbon/Conceptual/ProgWithTECM/tecmgr_about/tecmgr_about.html




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: main nib, firing a secondary nib and it's controller....

2009-10-03 Thread Jens Alfke


On Oct 3, 2009, at 4:19 PM, jon wrote:

i want to have a WindowController object and it's own nib separate  
from the main nib..
but i want this secondary nib and controller to fire up when the  
application launches...


Create and open an instance of that WindowController subclass from  
your app delegate's -applicationDidFinishLaunching: method.


—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


Re: Keeping NSWindow below all other windows

2009-10-03 Thread Jens Alfke
One oddity of low window levels is that below some level the windows  
become immune to Exposé, i.e. they stay in place. I think this happens  
because the Finder's desktop icons are in fact windows at a very low  
level, and Exposé needs to leave them alone.


This can be a useful effect if you want to create things like sticky  
notes on the desktop, or other stuff that can easily be exposed by  
pressing F11.


—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


Re: Probs with "BetterAuthorizationSample"-code

2009-10-03 Thread Jens Alfke


On Oct 3, 2009, at 6:04 AM, Frank W. Tag wrote:

1.	How can I debug my HelperTool? Obviously any breakpoints set in  
XCode won't work because the HelperTool is launched outside by the  
launchd.


You can use Xcode's Run > Attach command to attach GDB to it once it's  
launched. (Hopefully Xcode supports attaching to root-privileged  
processes; if not, you can debug it from the command line using "su  
gdb" and then "attach pid".)


—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


Bundle is not using icon or CFBundleIdentifier

2009-10-03 Thread Timothy Reaves
	I have a bundle defined as a document type for an app.  When I build  
one of these bundles, and double-click it, it opens in my app.  All  
well and good.  Except the following.


1) I have an icns file in my bundle, and have the CFBundleIconFile key  
in the info.plist in the bundle  set to the name of the icon.  The  
icns file is in the correct location in the bundle.  But the bundle  
does not display the icon.  It justuses the generic OS icon.


2) I have the CFBundleIdentifier key in the info.plist in the bundle  
set to a value.  Yet when I run mdls on the bundle directory,  
kMDItemContentType still shows as "public.foder" instead of the bundle  
identifier.


3) in my main application I have CFBundleTypeExtensions in the  
Info.plist set to my bundles extension. This works.  However, if I  
instead use LSItemContentTypes, and set it to the same value as  
CFBundleIdentifier from the bundle, the bundle shows as a standard  
folder and double-clicking it does not open it in my app.


	I'm using OS X 10.6.  I've done a good deal of searching, and I  
believe I'm using these values correctly.  I'm wanting to use  
LSItemContentTypes to be able to find my bundles via SpotLight (ala  
the CoreRecipes sample app).


Anyone want to point out what I'm doing wrong?  Any help appreciated.

Thanks.
___

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

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

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

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


Re: Working with an Unsupported Character Encoding (ANSEL)

2009-10-03 Thread Jens Alfke


On Oct 3, 2009, at 8:11 AM, Thomas Wetmore wrote:

1. Apparently reading a file to an NSString using the  
NSASCIIStringEncoding returns each of the bytes of the file exactly  
as they were, that is, the 8-bit bytes seem to be read exactly as  
they were. So is it true that reading with NSASCIIStringEncoding  
doesn't mess around with any of the 8-bit bytes in the file?


I'm surprised to hear that. Usually NSString's behavior is that if the  
data contains a character illegal for that encoding, it causes an  
error; so in the case of NSASCIIStringEncoding, any bytes >127 would  
cause it to return nil. Maybe reading a string from a file is an  
exception, but I wouldn't rely on this.


As Adam said, it's safer to read the file as NSData. Then you can cast  
its bytes to an array of char, allocate a C array of UniChar and fill  
it with the translated characters, and pass that array to an NSString  
initializer.


—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


Re: Bundle is not using icon or CFBundleIdentifier

2009-10-03 Thread Todd Heberlein

Anyone want to point out what I'm doing wrong?  Any help appreciated.


I think I had to do a Project->Add To Project... and then select the  
icon file in order to get the icon to be used. Dragging the icons into  
my project didn't do the trick.


Todd

___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)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: Making a new "ICNS file" with NSImage

2009-10-03 Thread Squ Aire

 <8f5c05b70909172123n2d83a5f8u8191ff101de9a...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0


Thanks for the reply=2C

However. I'm having a hard time testing this (i.e. see the difference in ma=
rgins) because whenever I put an NSImageView on the window in IB=2C and in =
code do something like this:

NSImage *baseImage =3D [NSImage imageNamed:@"myGreatIcon.icns"]=3B
[imageViewOutlet setImage:baseImage]=3B


all I end up seeing in the image view is not as big icon as the image view =
is=2C but the size is just restrained to 128x128 it seems. Note: This also =
happens if I set the image directly in IB=3B the icon fills the image view =
properly when viewed in IB=2C however when compiled and run only a 128 vers=
ion is displayed in the actual application's image view.

I'm also having this problem when making a custom NSView subclass and drawi=
ng into it within drawInRect method using [baseImage drawAtRect:...]


What's going on here? Do you happen to have a sample app that actually test=
s your code and clearly proves the difference in margins? Due to the proble=
ms I've mentioned I just cannot test it :(




> Hi Squ=2C
>
> I would recommend subclassing NSImageRep to do this. The new rep subclass=
 should retain the original image and draw it slightly inset.
>
> It's very similar to subclassing NSView. It looks something like this:
>
>
>
> @interface MarginalImageRep : NSImageRep {
>
>
> NSImage *_baseImage=3B
>
>
>
> CGFloat _margin=3B
>
>
>
> }
>
>
>
>
> - (id)initWithBaseImage:(NSImage *)baseImage margin:(CGFloat)margin=3B
>
>
>
>
>
> @property (readonly) NSImage *baseImage=3B
>
>
> @property (readonly) CGFloat margin=3B
>
>
>
>
> @end
>
>
>
>
>
>
> @implementation MarginalImageRep
>
>
>
>
> - (id)initWithBaseImage:(NSImage *)baseImage margin:(CGFloat)margin {
>
>
>
> NSParameterAssert(baseImage !=3D nil)=3B
>
>
>
>
>
>
> self =3D [super init]=3B
>
>
> if (self) {
>
>
> {
>
>
> _baseImage =3D [baseImage retain]=3B
>
>
> _margin =3D margin=3B
>
>
>
>
>
> NSSize sizeIncludingMargin =3D [baseImage size]=3B
>
>
>
> sizeIncludingMargin.width +=3D 2*margin=3B
>
>
>
> sizeIncludingMargin.height +=3D 2*margin=3B
>
>
>
>
>
>
> [self setSize:sizeIncludingMargin]=3B
>
>
> }
>
>
> }
>
>
>
>
>
> return self=3B
>
>
> }
>
>
>
>
> -(void)dealloc {
>
>
> [_baseImage release]=3B
>
>
>
> [super dealloc]=3B
>
>
> }
>
>
>
>
>
>
> - (BOOL)draw {
>
>
> NSRect bounds =3D (NSRect){NSZeroPoint=2C [self size]}=3B
>
>
>
> [_baseImage drawInRect:NSInsetRect(bounds=2C _margin=2C _margin) fromRect=
:NSZeroRect operation:NSCompositeSourceOver fraction:1.0]=3B
>
>
>
> return YES=3B
>
>
> }
>
>
>
>
> - (id)copyWithZone:(NSZone *)zone {
>
>
> MarginalImageRep *rep =3D [super copyWithZone:zone]=3B
>
>
>
> // careful - superclass uses NSCopyObject.
>
>
> rep->_baseImage =3D [_baseImage retain]=3B
>
>
>
> rep->_margin =3D _margin=3B
>
>
>
> return rep=3B
>
>
> }
>
>
>
>
> @synthesize baseImage=3D_baseImage=2C margin=3D_margin=3B
>
>
>
>
>
> @end
>
>
> We covered this technique in the WWDC 2009 talk about NSImage. If you hav=
e access=2C I'd recommend watching the presentation when it comes out. It e=
xplains some of the choices here.
>
>
> You'd use the image like this:
>
>
> MarginalImageRep *marginalRep =3D [[[MarginalImageRep alloc] initWithBase=
Image:baseImage margin:20] autorelease]=3B
>
>
>
> NSImage *marginalImage =3D [[[NSImage alloc] initWithSize:[marginalRep si=
ze]] autorelease]=3B
>
>
>
> [marginalImage addRepresentation:marginalRep]=3B
>
>
>
>
>
> // it's a waste of resources to cache here=2C because the baes image can =
maintain its own cache.
>
>
>
> [marginalImage setCacheMode:NSImageCacheNever]=3B
>
>
>
> -Ken
>
> On Thu=2C Sep 17=2C 2009 at 7:39 PM=2C Squ Aire> wrote:
>
>
>
> Introduction: I have an actual ICNS file with some nice icon in it. No ma=
tter where I draw it within my app=2C be it a 16x16 square or a 512x512 squ=
are=2C it draws nicely=2C scales properly=2C looks crisp at all times. It d=
oes this probably (among other things) by using the correct "representation=
" within the ICNS file to determine which size in that file it should use t=
o do the actual drawing. So far so good.
>
>
>
>
>
>
> My problem is this: I want to derive a new "icon file" (simulated by an N=
SImage somehow) which has some margins applied to it. The margins on each s=
ide should be the size of the area being drawn on divided by 100. So for in=
stance=2C if we are drawing the icon on a 300x300 area=2C the top=2Cbottom=
=2Cleft=2Cright margins should all be 3. If drawing on a 30x30 area the mar=
gins are .3 or simply negligible.
>
>
>
>
>
>
> In other words=2C I somehow want to make an instance of NSImage such that=
 if drawn on a 300x300 rect=2C it will look slightly smaller than that beca=
use of the margins=2C i.e. it will not fill out the whole rect as the origi=
nal ICNS would.
>
>
>
>
>
>
> But also note that this new derived "ICNS file" (simulated by