Re: get the list of controls in a NSView

2010-02-13 Thread Graham Cox

On 13/02/2010, at 12:46 PM, Roland King wrote:

> Remember the original poster is blind


Ah, I hadn't made the connection that this was the same thread. I must admit 
it's hard to see how Cocoa *development* can be made accessible with IB as it 
stands now.

--Graham


___

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

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

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

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


Re: UINavigationController inside a TabBarController

2010-02-13 Thread Laurent Daudelin
It is but I wanted to have the "bar" style, like in the Settings. So, there is 
no way to get a segmented control of that size without overriding the drawing 
method?

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://nemesys.dyndns.org
Logiciels Nemesys Software  
laurent.daude...@gmail.com
Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries

On Feb 12, 2010, at 22:10, Roland King wrote:

> What's the 'style' on the segmented control set to? The 'bar' style is 
> smaller than the 'plain' or 'bordered' styles. 
> 
> On 13-Feb-2010, at 1:54 PM, Laurent Daudelin wrote:
> 
>> Thanks, that was helpful but I had already figured it out. After examining 
>> the "Recipes" sample, which does exactly what I wanted to do, I did notice 
>> that the sample didn't have a pre-configured tableview. So, I removed my 
>> tableview from the view hierarchy and, in viewDidLoad, I did set the 
>> tableview to the view pre-configured in IB. Works perfect!
>> 
>> Now, if I could find how to get small UISegmentedControls, life would be 
>> good. You know, like in Settings->General, there is a small segmented 
>> control for the Location Services. It is small and fits well inside the 
>> tableview cell. However, the one I put from IB in my cell looks rather 
>> large. Is the only way to have it small by subclassing it and overriding its 
>> draw method?
>> 
>> -Laurent.
>> -- 
>> Laurent Daudelin
>> AIM/iChat/Skype:LaurentDaudelin  
>> http://nemesys.dyndns.org
>> Logiciels Nemesys Software   
>> laurent.daude...@gmail.com
>> Photo Gallery Store: 
>> http://laurentdaudelin.shutterbugstorefront.com/g/galleries
>> 
>> On Feb 12, 2010, at 21:11, Kevin Callahan wrote:
>> 
>>> 
>>> On Feb 12, 2010, at 8:34 PM, Laurent Daudelin wrote:
>>> 
 I'm not sure what I'm missing but I know it must be big. I started the 
 design of a TabBar-style app and now, I want one of the view to be a 
 navigation one. I did drag a UINavigationController to my xib, put it 
 inside the TabBarView and put my tableview under the navigation 
 controller. When I open the window in IB, I can see my tableview inside 
 the nav controller, in the first tab item but when I compile and go, only 
 the navigation view shows up when I select the tab item. I've been banging 
 my head, trying to find what connection or method I missed, I can't find 
 it.
 
 Anybody knows?
 
 Thanks in advance!
>>> 
>>> might this be helpful?
>>> 
>>> http://www.youtube.com/watch?v=LBnPfAtswgw
>>> 
>>> -Kevin
>>> 
>>> The Red Fantasy : 
>>> http://www.dobermaneditions.com//en/sheet-music-for-guitar/guitar-solo/p17554733.html
>>> The Fourth Stream:
>>> http://www.dobermaneditions.com//en/sheet-music-for-guitar/guitar-solo/p17554731.html
>>> Three River Moments:  
>>> http://www.henry-lemoine.com/en/catalogue/rechercheFiche.html?cotage=27461
>>> Accessorizer:   
>>> http://www.kevincallahan.org/software/accessorizer.html
>>> Homepage:   http://www.kevincallahan.org/
>>> http://www.xeniamara.com
>>> 
 
 
 
 
 -Laurent.
 -- 
 Laurent Daudelin
 AIM/iChat/Skype:LaurentDaudelin
 http://nemesys.dyndns.org
 Logiciels Nemesys Software 
 laurent.daude...@gmail.com
 Photo Gallery Store: 
 http://laurentdaudelin.shutterbugstorefront.com/g/galleries
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post 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/kcall%40mac.com
 
 This email sent to kc...@mac.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/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


Re: Validating unique objects in CoreData

2010-02-13 Thread daniele malcom
On Sat, Feb 13, 2010 at 4:06 AM, Roland King  wrote:

> That's not a horrible solution, except for the feeling that core data ought
> to let you do what you want without having to implement your own UUID cache.
> I'm still a bit surprised that a lookup for an object by one attribute is
> taking so long, over just 30,000 objects. You do have the uuid attribute
> marked as indexed right?
>
> I found
> http://cocoawithlove.com/2008/03/testing-core-data-with-very-big.htmlwhilst 
> hunting around for some examples of core data with big data sets.
> This guy was working on sets of 1 million objects and doing fetches with
> indexed properties was taking about 2 seconds, vs non-indexed, 600 seconds.
> There are some comments at the bottom from an apple engineer too.
>

Hi Roland,
Uhmmm probability there is something wrong with my code, because with
indexed messageid property it takes a very long time too (I can't see any
visible difference, 20k messages took minutes to be completed)
Here you will found my simple storage data model:
http://img197.imageshack.us/img197/4388/screenshot20100213at111.jpg

This is my code:
for (NSString *cMessage in messagedata) {
NSString *idd = [cMessage headerValueFor:ARTICLE_TAG_ID]; // takes the
MESSAGE UUID
if ([thegroup articleForID:idd inCtx:ctx] == nil) { // CHECK IF MESSAGE UUID
IS ALREADY ON DB
MCArticle *c = [MCArticle newArticleWithID:idd context:ctx]; // WE CAN MAKE
THE MESSAGE AND ADD IT TO COREDATA

// WE WANT TO CHECK FOR PARENT
NSString *parentidms = [[[f headerValueFor:ARTICLE_TAG_REFS]
reverseOrderedReferences] objectAtIndex:0];
MCArticle *parent = [thegroup articleForID:parentidms inCtx:ctx]; // WE
QUERY FOR PARENT UUID
if (parent != nil) {
// LINK BOTH PARENT AND CHILD
}
}
}

ArticleForID:inCtx: method follow (inCtx is required becase these functions
works in a multithreading environment)
(I've also tried to re-use fetchRequest object but it's not the main
problem...)

- (MCArticle *) articleForID:(NSString*) _msgid
inCtx:(NSManagedObjectContext*) ctx {
if (_msgid == nil) return nil;
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setFetchLimit:1];
[fetchRequest setEntity: [NSEntityDescription entityForName:@"MCArticle"
inManagedObjectContext:ctx]];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"messageid ==
%@",_msgid];
[fetchRequest setPredicate: predicate];
NSArray *results = [ctx executeFetchRequest:fetchRequest error:nil];
[fetchRequest release];
if ([results count]==0)return nil;
return [results objectAtIndex:0];
}

Finally the init method for Message object:

+ (MCArticle *) newArticleWithID:(NSString *) _messageID
context:(NSManagedObjectContext *) _context {
MCArticle *oj = (MCArticle*)[[NSManagedObject alloc]
initWithEntity:[NSEntityDescription entityForName:@"MCArticle"
  inManagedObjectContext:_context]
   insertIntoManagedObjectContext:_context];
[oj setValue:_messageID forKey:@"messageid"];
return oj;
}
___

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

Please do not post 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: setWidth pop-up list of NSComboBox

2010-02-13 Thread Steven Degutis
NSComboBox is an ordinary control just like any other. Thus, you can set
it's frame with the -setFrame: method of NSView, from which it inherits.

However, changing the width of this kind of control to accommodate its
contents is pretty uncommon in standard Cocoa apps.

-Steven

On Thu, Feb 11, 2010 at 1:43 PM, John Yeh  wrote:

> How to change the width of the pop-up list in NSComboBox? When a long
> string is added to the NSComboBox, it can't displayed completely. how to
> extend the width of the pop-up list?
> -John___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/steven.degutis%40gmail.com
>
> This email sent to steven.degu...@gmail.com
>



-- 
Steven Degutis
http://www.thoughtfultree.com/
http://www.degutis.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


Re: UINavigationController inside a TabBarController

2010-02-13 Thread Roland King
yes set the style to 'bar'

On 13-Feb-2010, at 6:08 PM, Laurent Daudelin wrote:

> It is but I wanted to have the "bar" style, like in the Settings. So, there 
> is no way to get a segmented control of that size without overriding the 
> drawing method?
> 
> -Laurent.
> -- 
> Laurent Daudelin
> AIM/iChat/Skype:LaurentDaudelin   
> http://nemesys.dyndns.org
> Logiciels Nemesys Software
> laurent.daude...@gmail.com
> Photo Gallery Store: 
> http://laurentdaudelin.shutterbugstorefront.com/g/galleries
> 
> On Feb 12, 2010, at 22:10, Roland King wrote:
> 
>> What's the 'style' on the segmented control set to? The 'bar' style is 
>> smaller than the 'plain' or 'bordered' styles. 
>> 
>> On 13-Feb-2010, at 1:54 PM, Laurent Daudelin wrote:
>> 
>>> Thanks, that was helpful but I had already figured it out. After examining 
>>> the "Recipes" sample, which does exactly what I wanted to do, I did notice 
>>> that the sample didn't have a pre-configured tableview. So, I removed my 
>>> tableview from the view hierarchy and, in viewDidLoad, I did set the 
>>> tableview to the view pre-configured in IB. Works perfect!
>>> 
>>> Now, if I could find how to get small UISegmentedControls, life would be 
>>> good. You know, like in Settings->General, there is a small segmented 
>>> control for the Location Services. It is small and fits well inside the 
>>> tableview cell. However, the one I put from IB in my cell looks rather 
>>> large. Is the only way to have it small by subclassing it and overriding 
>>> its draw method?
>>> 
>>> -Laurent.
>>> -- 
>>> Laurent Daudelin
>>> AIM/iChat/Skype:LaurentDaudelin 
>>> http://nemesys.dyndns.org
>>> Logiciels Nemesys Software  
>>> laurent.daude...@gmail.com
>>> Photo Gallery Store: 
>>> http://laurentdaudelin.shutterbugstorefront.com/g/galleries
>>> 
>>> On Feb 12, 2010, at 21:11, Kevin Callahan wrote:
>>> 
 
 On Feb 12, 2010, at 8:34 PM, Laurent Daudelin wrote:
 
> I'm not sure what I'm missing but I know it must be big. I started the 
> design of a TabBar-style app and now, I want one of the view to be a 
> navigation one. I did drag a UINavigationController to my xib, put it 
> inside the TabBarView and put my tableview under the navigation 
> controller. When I open the window in IB, I can see my tableview inside 
> the nav controller, in the first tab item but when I compile and go, only 
> the navigation view shows up when I select the tab item. I've been 
> banging my head, trying to find what connection or method I missed, I 
> can't find it.
> 
> Anybody knows?
> 
> Thanks in advance!
 
 might this be helpful?
 
 http://www.youtube.com/watch?v=LBnPfAtswgw
 
 -Kevin
 
 The Red Fantasy :
 http://www.dobermaneditions.com//en/sheet-music-for-guitar/guitar-solo/p17554733.html
 The Fourth Stream:   
 http://www.dobermaneditions.com//en/sheet-music-for-guitar/guitar-solo/p17554731.html
 Three River Moments:  
 http://www.henry-lemoine.com/en/catalogue/rechercheFiche.html?cotage=27461
 Accessorizer:  
 http://www.kevincallahan.org/software/accessorizer.html
 Homepage:  http://www.kevincallahan.org/
http://www.xeniamara.com
 
> 
> 
> 
> 
> -Laurent.
> -- 
> Laurent Daudelin
> AIM/iChat/Skype:LaurentDaudelin   
> http://nemesys.dyndns.org
> Logiciels Nemesys Software
> laurent.daude...@gmail.com
> Photo Gallery Store: 
> http://laurentdaudelin.shutterbugstorefront.com/g/galleries
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/kcall%40mac.com
> 
> This email sent to kc...@mac.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/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

Re: Validating unique objects in CoreData

2010-02-13 Thread Roland King
ok, I don't see anything wrong with the predicate code, but I'm no core data 
expert. 

I'll make one totally challengable statement. Assuming that core data uses 
sqllite in a rational way to store objects (eg not storing everything as blobs 
of opaque data) for instance one table per entity where each column of the 
table is an attribute and evaluating the predicate does what you would expect 
it to do, ie uses SQL to do as much of the heavy lifting on a fetch request as 
possible, that column is indexed in the table and sqllite is using the index; 
taking multi-minutes to find one row out of 20,000 just doesn't make any sense, 
it should take seconds at most. 

I believe core data does use table-per-entity. I think that partly because the 
documentation hints at it, partly because it makes sense and partly because I 
looked at the implementation of one data model that I have. 

I can't see the point of making indexes if the predicate code doesn't generate 
SQL which doesn't use them, but it's possible. It's possible that core data 
goes and loads all the entity rows and inspects their attributes by hand and 
filters them in code, but this is apple not microsoft. 

So that leaves column isn't indexed as the most likely. But you've checked the 
'indexed' box. Here's another wild assed guess, does coredata only create a 
store when you have no current store? It certainly checks to see if the store 
is compatible with the model but as the indexed property is just a hint anyway, 
that store is compatible, just non-optimal .. it's possible if you created the 
store with the property defined as not-indexed and have just checked that box 
later, without regenerating the whole store, the index was never added. Did you 
do that, just check it later? Have you regenerated a complete new store since 
or are you using a store you've been populating for a while. 

Here's a particularly ugly idea, purists please stop reading now. We can look 
at the store and see if it has an index on that property ... first get up a 
terminal window and go to the path where your store is. I'm assuming you have 
sqlite3 installed like I do .. it came with the OS as far as I know. 

Your store should be called something.sqlite, let's say it's Foo. Type

sqlite3 Foo.sqlite

and that should open the store and give you a prompt. First you want to find 
the tables in the store, so type 

.tables

as far as I can see they are called Z, so for you I'd expect 
to see one of the tables called ZMCARTICLE. If there is one, you can find out 
what indices are on it

.indices ZMCARTICLE

I believe again the indices are called Z_Z_INDEX, so you'd expect to find ZMCARTICLE_ZMESSAGEID_INDEX in that list. 
If you don't have it, the store wasn't created with that index. If none of 
those tables exist at all, my rudimentary reverse engineering of the whole 
coredata thing is flawed (or I'm using some entirely different version from 
you). 

If the tables and indices exist, including the one on ZMESSAGEID, I'm out of 
ideas unless someone knows of a way to put coredata into a form of debug mode 
and see the SQL generated to figure out if it's doing anything smart. 

If either none of the above works or it does work but you don't have the index, 
you have a couple of options. The right one is to delete your whole message 
store and run your app and make a brand new one to see if that then adds the 
indexed property with an index. Depending on how you've populated the store, 
that might be a real pain, perhaps you can force a migration or something. The 
other really stupid idea would be to just add the index and hope that doesn't 
break everything entirely which is entirely possible at which point you delete 
the store and start over. You would do that by running 

CREATE INDEX ZMCARTICLE_ZMESSAGEID_INDEX ON ZMCARTICLE (ZMESSAGEID);

Here's another useful thing I just came across, I would certainly run this to 
see if the SQL being executed makes sense. 


With Mac OS X version 10.4.3 and later, you can use the user default 
com.apple.CoreData.SQLDebug to log to stderr the actual SQL sent to SQLite. 
(Note that user default names are case sensitive.) For example, you can pass 
the following as an argument to the application:

-com.apple.CoreData.SQLDebug 1
Higher levels of debug numbers produce more information, although using higher 
numbers is likely to be of diminishing utility.



I'd love to hear about any other ways people have to debug coredata. I sort of 
trust apple has done a good job with it and for it to break down performance 
wise on looking for a row in 20,000 with a certain attribute doesn't make sense 
to me. If you really can't get it to work, I'd write a short project which 
inserts 20,000 simple objects into a store and another one which opened the 
store and goes looking for one by attribute in the way you have. If it takes 
multi-minutes, I'd sent it to apple as a bug. 


On 13-Feb-2010, at 6:32 PM, dani

Re: Validating unique objects in CoreData

2010-02-13 Thread Roland King
.. oh and one other thing, there's a core data instruments tool in XCode, well 
there is for OSX, not for iPhoneOS which I develop for which may be why I never 
saw it before. You could try that. 

On 13-Feb-2010, at 9:36 PM, Roland King wrote:

> ok, I don't see anything wrong with the predicate code, but I'm no core data 
> expert. 
> 
> I'll make one totally challengable statement. Assuming that core data uses 
> sqllite in a rational way to store objects (eg not storing everything as 
> blobs of opaque data) for instance one table per entity where each column of 
> the table is an attribute and evaluating the predicate does what you would 
> expect it to do, ie uses SQL to do as much of the heavy lifting on a fetch 
> request as possible, that column is indexed in the table and sqllite is using 
> the index; taking multi-minutes to find one row out of 20,000 just doesn't 
> make any sense, it should take seconds at most. 
> 
> I believe core data does use table-per-entity. I think that partly because 
> the documentation hints at it, partly because it makes sense and partly 
> because I looked at the implementation of one data model that I have. 
> 
> I can't see the point of making indexes if the predicate code doesn't 
> generate SQL which doesn't use them, but it's possible. It's possible that 
> core data goes and loads all the entity rows and inspects their attributes by 
> hand and filters them in code, but this is apple not microsoft. 
> 
> So that leaves column isn't indexed as the most likely. But you've checked 
> the 'indexed' box. Here's another wild assed guess, does coredata only create 
> a store when you have no current store? It certainly checks to see if the 
> store is compatible with the model but as the indexed property is just a hint 
> anyway, that store is compatible, just non-optimal .. it's possible if you 
> created the store with the property defined as not-indexed and have just 
> checked that box later, without regenerating the whole store, the index was 
> never added. Did you do that, just check it later? Have you regenerated a 
> complete new store since or are you using a store you've been populating for 
> a while. 
> 
> Here's a particularly ugly idea, purists please stop reading now. We can look 
> at the store and see if it has an index on that property ... first get up a 
> terminal window and go to the path where your store is. I'm assuming you have 
> sqlite3 installed like I do .. it came with the OS as far as I know. 
> 
> Your store should be called something.sqlite, let's say it's Foo. Type
> 
>   sqlite3 Foo.sqlite
> 
> and that should open the store and give you a prompt. First you want to find 
> the tables in the store, so type 
> 
>   .tables
> 
> as far as I can see they are called Z, so for you I'd 
> expect to see one of the tables called ZMCARTICLE. If there is one, you can 
> find out what indices are on it
> 
>   .indices ZMCARTICLE
> 
> I believe again the indices are called Z_Z NAME>_INDEX, so you'd expect to find ZMCARTICLE_ZMESSAGEID_INDEX in that 
> list. If you don't have it, the store wasn't created with that index. If none 
> of those tables exist at all, my rudimentary reverse engineering of the whole 
> coredata thing is flawed (or I'm using some entirely different version from 
> you). 
> 
> If the tables and indices exist, including the one on ZMESSAGEID, I'm out of 
> ideas unless someone knows of a way to put coredata into a form of debug mode 
> and see the SQL generated to figure out if it's doing anything smart. 
> 
> If either none of the above works or it does work but you don't have the 
> index, you have a couple of options. The right one is to delete your whole 
> message store and run your app and make a brand new one to see if that then 
> adds the indexed property with an index. Depending on how you've populated 
> the store, that might be a real pain, perhaps you can force a migration or 
> something. The other really stupid idea would be to just add the index and 
> hope that doesn't break everything entirely which is entirely possible at 
> which point you delete the store and start over. You would do that by running 
> 
>   CREATE INDEX ZMCARTICLE_ZMESSAGEID_INDEX ON ZMCARTICLE (ZMESSAGEID);
> 
> Here's another useful thing I just came across, I would certainly run this to 
> see if the SQL being executed makes sense. 
> 
> 
> With Mac OS X version 10.4.3 and later, you can use the user default 
> com.apple.CoreData.SQLDebug to log to stderr the actual SQL sent to SQLite. 
> (Note that user default names are case sensitive.) For example, you can pass 
> the following as an argument to the application:
> 
> -com.apple.CoreData.SQLDebug 1
> Higher levels of debug numbers produce more information, although using 
> higher numbers is likely to be of diminishing utility.
> 
> 
> 
> I'd love to hear about any other ways people have to debug coredata. I sort 
> of trust apple has done a good job with it and fo

Re: Creating an Application Support folder

2010-02-13 Thread Ken Thomases
On Feb 12, 2010, at 10:17 AM, Sean McBride wrote:

> On 2/10/10 10:44 PM, Paul Johnson said:
> 
>> I'm trying to find a best way to create the Application Support
>> folder. I'm rather new at Cocoa so it's taking me a while to do even
>> this simple thing.
> 
> Since you're new to Cocoa, I'm guessing all the other replies have
> probably provided the real answers you need.
> 
> However, I just tried a little test.  I renamed my App Support folder
> then did this:
> 
> NSSearchPathForDirectoriesInDomains (
>  NSApplicationSupportDirectory,
>   NSUserDomainMask, YES);
> 
> It just returned the path, but did not create the folder.
> 
> This is in contrast to FSFindFolder() which can optionally (attempt to)
> create the folder for you.
> 
> So although unlikely, be prepared for the folder to not exist.

If you're targeting Snow Leopard or later, the new recommended routines are:

-[NSFileManager URLForDirectory:inDomain:appropriateForURL:create:error:]
-[NSFileManager URLsForDirectory:inDomains:]

The former can be told to create the directory for you.

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: Connected Objects being allocated

2010-02-13 Thread Donald Klett
Steven,

Thanks for your analysis.  I must admit I am still somewhat confused, but you 
have given me something to think about.   And thanks to Henry McGilton for his 
reply.

I have David Chisnall's book on Cocoa Programming, so I will try to understand 
your suggestion concerning using view and window controllers.  This is all new. 
 I have been a Java developer for about seven years and want to branch out.  So 
all help is very welcome.

I also have to read more about what happens when an app loads.  I thought I had 
an idea of what happens, but maybe not completely.  I am sure I will be back 
with more questions.  Thanks again.

Don

On Feb 12, 2010, at 7:06 PM, Steven Degutis wrote:

> Don,
> 
> Your first snippet of code is great and follows MVC just fine. However, your 
> second snippet breaks away from proper MVC, in the vein of over-thinking your 
> architecture.
> 
> When in doubt, start simple and extend as needed. In your first snippet, your 
> Controller class is a valid Controller in the MVC sense of things. Just stick 
> it in a NIB file, connect the outlets, and you're all groovy.
> 
> But here's some things to explicitly avoid:
> 
> (1) Name classes inappropriately. As mentioned before, "View" should not be a 
> subclass of NSObject without any view components. It should be a subclass of 
> NSView or something similar (NSControl, NSTableView, etc)
> (2) We Cocoa coders don't usually instantiate views inside -init, but rather 
> inside a NIB file. Having NIBs loaded automatically for us via 
> NSViewController or NSWindowController is pretty standard and good practice.
> (3) View classes shouldn't usually have Controller code in it. View classes 
> should be generic and reusable, whereas Controller is specific to a single 
> purpose inside an app (or multiple apps, if it's a shared framework).
> (4) Try to use a prefix in your class names. I usually use SD, like SDView or 
> SDController or SDButton, for instance. This helps prevent namespace 
> collisions. Not entirely relevant to your question, just throwing it out 
> there.
> 
> -Steven
> 
> 
> On Fri, Feb 12, 2010 at 4:31 PM, Donald Klett  wrote:
> Once again, I am not understanding some aspect of Objective C and/or Cocoa.
> 
> I created a simple class that contains two NSTextField objects.  I used IB to 
> connect the Controller object with the two text fields.  The code follows.  
> This example runs correctly and does copy the value from one text field to 
> the other.
> 
> #import 
> 
> @interface Controller : NSObject {
>IBOutlet NSTextField*   textField;
>IBOutlet NSTextField*   copyField;
> }
> 
> - (IBAction) buttonTarget: (id) sender;
> 
> @end
> 
> #import "Controller.h"
> 
> @implementation Controller
> 
> - (IBAction) buttonTarget: (id) sender {
>int textValue;
> 
>textValue = [textField intValue];
>[copyField setIntegerValue:textValue];
> }
> 
> @end
> 
> Now if I extend this to two objects (Controller and View), the resulting code 
> does not execute correctly.  Again, I used IB to connect the View object to 
> the two text fields.  Using the debugger I find that the two NSTextField 
> objects have not been allocated (both have nil values).  The code follows:
> 
> #import 
> #import "View.h"
> 
> @interface Controller : NSObject {
> 
>View*   view;
> }
> 
> - (IBAction) buttonTarget: (id) sender;
> 
> @end
> 
> #import "Controller.h"
> #import "View.h"
> 
> @implementation Controller
> 
> - (id) init {
>if (self = [super init]) {
>view = [[View alloc] init];
>}
>return self;
> }
> 
> - (IBAction) buttonTarget: (id) sender {
>[view copyFieldValue];
> }
> 
> @end
> 
> #import 
> 
> @interface View : NSObject {
> 
>IBOutlet NSTextField*   textField;
>IBOutlet NSTextField*   copyField;
> 
> }
> 
> - (void) copyFieldValue;
> 
> @end
> 
> #import "View.h"
> 
> 
> @implementation View
> 
> - (void) copyFieldValue {
>[copyField setIntegerValue:[textField intValue]];
> }
> 
> @end
> 
> I have no idea what I am doing wrong.  Any help would be most appreciated.  
> Thanks in advance.
> 
> Don Klett
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post 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/steven.degutis%40gmail.com
> 
> This email sent to steven.degu...@gmail.com
> 
> 
> 
> -- 
> Steven Degutis
> http://www.thoughtfultree.com/
> http://www.degutis.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/

Re: Connected Objects being allocated

2010-02-13 Thread Steven Degutis
I don't know anything about that book, but I've always recommended Aaron
Hillegass's book on Cocoa Programming for Mac OS X, as it's what I used to
learn how to code Cocoa code.

http://www.bignerdranch.com/book/cocoa_programming_for_mac_os_x_3rd_edition

-Steven

On Sat, Feb 13, 2010 at 10:17 AM, Donald Klett  wrote:

> Steven,
>
> Thanks for your analysis.  I must admit I am still somewhat confused, but
> you have given me something to think about.   And thanks to Henry McGilton
> for his reply.
>
> I have David Chisnall's book on Cocoa Programming, so I will try to
> understand your suggestion concerning using view and window controllers.
>  This is all new.  I have been a Java developer for about seven years and
> want to branch out.  So all help is very welcome.
>
> I also have to read more about what happens when an app loads.  I thought I
> had an idea of what happens, but maybe not completely.  I am sure I will be
> back with more questions.  Thanks again.
>
> Don
>
> On Feb 12, 2010, at 7:06 PM, Steven Degutis wrote:
>
> > Don,
> >
> > Your first snippet of code is great and follows MVC just fine. However,
> your second snippet breaks away from proper MVC, in the vein of
> over-thinking your architecture.
> >
> > When in doubt, start simple and extend as needed. In your first snippet,
> your Controller class is a valid Controller in the MVC sense of things. Just
> stick it in a NIB file, connect the outlets, and you're all groovy.
> >
> > But here's some things to explicitly avoid:
> >
> > (1) Name classes inappropriately. As mentioned before, "View" should not
> be a subclass of NSObject without any view components. It should be a
> subclass of NSView or something similar (NSControl, NSTableView, etc)
> > (2) We Cocoa coders don't usually instantiate views inside -init, but
> rather inside a NIB file. Having NIBs loaded automatically for us via
> NSViewController or NSWindowController is pretty standard and good practice.
> > (3) View classes shouldn't usually have Controller code in it. View
> classes should be generic and reusable, whereas Controller is specific to a
> single purpose inside an app (or multiple apps, if it's a shared framework).
> > (4) Try to use a prefix in your class names. I usually use SD, like
> SDView or SDController or SDButton, for instance. This helps prevent
> namespace collisions. Not entirely relevant to your question, just throwing
> it out there.
> >
> > -Steven
> >
> >
> > On Fri, Feb 12, 2010 at 4:31 PM, Donald Klett  wrote:
> > Once again, I am not understanding some aspect of Objective C and/or
> Cocoa.
> >
> > I created a simple class that contains two NSTextField objects.  I used
> IB to connect the Controller object with the two text fields.  The code
> follows.  This example runs correctly and does copy the value from one text
> field to the other.
> >
> > #import 
> >
> > @interface Controller : NSObject {
> >IBOutlet NSTextField*   textField;
> >IBOutlet NSTextField*   copyField;
> > }
> >
> > - (IBAction) buttonTarget: (id) sender;
> >
> > @end
> >
> > #import "Controller.h"
> >
> > @implementation Controller
> >
> > - (IBAction) buttonTarget: (id) sender {
> >int textValue;
> >
> >textValue = [textField intValue];
> >[copyField setIntegerValue:textValue];
> > }
> >
> > @end
> >
> > Now if I extend this to two objects (Controller and View), the resulting
> code does not execute correctly.  Again, I used IB to connect the View
> object to the two text fields.  Using the debugger I find that the two
> NSTextField objects have not been allocated (both have nil values).  The
> code follows:
> >
> > #import 
> > #import "View.h"
> >
> > @interface Controller : NSObject {
> >
> >View*   view;
> > }
> >
> > - (IBAction) buttonTarget: (id) sender;
> >
> > @end
> >
> > #import "Controller.h"
> > #import "View.h"
> >
> > @implementation Controller
> >
> > - (id) init {
> >if (self = [super init]) {
> >view = [[View alloc] init];
> >}
> >return self;
> > }
> >
> > - (IBAction) buttonTarget: (id) sender {
> >[view copyFieldValue];
> > }
> >
> > @end
> >
> > #import 
> >
> > @interface View : NSObject {
> >
> >IBOutlet NSTextField*   textField;
> >IBOutlet NSTextField*   copyField;
> >
> > }
> >
> > - (void) copyFieldValue;
> >
> > @end
> >
> > #import "View.h"
> >
> >
> > @implementation View
> >
> > - (void) copyFieldValue {
> >[copyField setIntegerValue:[textField intValue]];
> > }
> >
> > @end
> >
> > I have no idea what I am doing wrong.  Any help would be most
> appreciated.  Thanks in advance.
> >
> > Don Klett
> >
> > ___
> >
> > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> >
> > Please do not post 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.appl

cocoa-dev@lists.apple.com

2010-02-13 Thread Adam Warski

> I don't think that will be possible. The actual display of the menu is 
> handled by the Carbon Menu Manager, and it doesn't support the kind of hooks 
> you'd need.


Ah, that's a pity. And there's no way to hack into Carbon directly?

-- 
Adam Warski
http://www.warski.org
http://www.softwaremill.eu




___

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

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


cocoa-dev@lists.apple.com

2010-02-13 Thread Eric Schlegel

On Feb 13, 2010, at 8:41 AM, Adam Warski wrote:

> 
>> I don't think that will be possible. The actual display of the menu is 
>> handled by the Carbon Menu Manager, and it doesn't support the kind of hooks 
>> you'd need.
> 
> 
> Ah, that's a pity. And there's no way to hack into Carbon directly?

It would be fairly tricky to implement drag&drop from a menu item even from a 
regular Carbon app (and certainly unsupported), so I really wouldn't recommend 
it.

-eric

___

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

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


cocoa-dev@lists.apple.com

2010-02-13 Thread Steven Degutis
Hack is a great way to describe it. This concept goes against the HIG that
Apple specifies, and is not standard user interaction. Thus, there is no
supported APIs to do this, because it's a "bad idea" to implement such a
feature.

-Steven

On Sat, Feb 13, 2010 at 11:41 AM, Adam Warski  wrote:

>
> > I don't think that will be possible. The actual display of the menu is
> handled by the Carbon Menu Manager, and it doesn't support the kind of hooks
> you'd need.
>
>
> Ah, that's a pity. And there's no way to hack into Carbon directly?
>
> --
> Adam Warski
> http://www.warski.org
> http://www.softwaremill.eu
>
>
>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post 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/steven.degutis%40gmail.com
>
> This email sent to steven.degu...@gmail.com
>



-- 
Steven Degutis
http://www.thoughtfultree.com/
http://www.degutis.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


Re: get the list of controls in a NSView

2010-02-13 Thread Jonathan Chacón
Hello everybody,

Graham, you can read a little tutorial about how to design an interface using 
voiceOver and interface builder.

voiceOver is an assistive tool for blind users in MacOS. voiceOver is a screen 
reader.

the article is here: 
http://programaraciegas.weblog.discapnet.es/articulo.aspx?idA=1599


well, I'll make the tests using tag methods this weekeng... I'll post the 
results soon

thanks and regards
Jonathan Chacón

El 13/02/2010, a las 10:59, Graham Cox escribió:

> 
> On 13/02/2010, at 12:46 PM, Roland King wrote:
> 
>> Remember the original poster is blind
> 
> 
> Ah, I hadn't made the connection that this was the same thread. I must admit 
> it's hard to see how Cocoa *development* can be made accessible with IB as it 
> stands now.
> 
> --Graham
> 
> 

___

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

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

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

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


Re: Creating an Application Support folder

2010-02-13 Thread Sean McBride
Ken Thomases (k...@codeweavers.com) on 2010-02-13 08:58 said:

>If you're targeting Snow Leopard or later, the new recommended routines are:
>
>-[NSFileManager URLForDirectory:inDomain:appropriateForURL:create:error:]
>-[NSFileManager URLsForDirectory:inDomains:]
>
>The former can be told to create the directory for you.

That's a much nicer API.  Now if they'd just expand the
NSSearchPathDirectory choices, FSFindFolder could finally be obsoleted.

Sean

--
"When the winds of change are blowing, some people are building shelters
and others are building windmills" - Chinese proverb

___

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

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


How to get small UISegmentedControl?

2010-02-13 Thread Laurent Daudelin
Is there anyway to have smaller segmented controls besides the large ones 
available in IB? I'm talking the size of the one in Settings->General for 
Location Services. Any idea?

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://nemesys.dyndns.org
Logiciels Nemesys Software  
laurent.daude...@gmail.com
Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries

___

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

Please do not post 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: Validating unique objects in CoreData

2010-02-13 Thread daniele malcom
Hi Roland, in fact indices table exists (for DDArticle entity):
Enter SQL statements terminated with a ";"
sqlite> .tables
ZDDARTICLE    Z_METADATA    Z_PRIMARYKEY
sqlite> .indices ZDDARTICLE
ZDDARTICLE_ZMESSAGEID_INDEX
ZDDARTICLE_ZPARENT_INDEX

With my macbook pro insertion of 30k articles took about 2/3 minutes.
I've uploaded a test project:
http://dl.dropbox.com/u/103260/CoreDataTreeTest.zip
I really don't know why it should take this long time but using
Instruments the big part is obviously fetch for searching id and
parent.

On Sat, Feb 13, 2010 at 2:53 PM, Roland King  wrote:
>
> .. oh and one other thing, there's a core data instruments tool in XCode, 
> well there is for OSX, not for iPhoneOS which I develop for which may be why 
> I never saw it before. You could try that.
>
> On 13-Feb-2010, at 9:36 PM, Roland King wrote:
>
> > ok, I don't see anything wrong with the predicate code, but I'm no core 
> > data expert.
> >
> > I'll make one totally challengable statement. Assuming that core data uses 
> > sqllite in a rational way to store objects (eg not storing everything as 
> > blobs of opaque data) for instance one table per entity where each column 
> > of the table is an attribute and evaluating the predicate does what you 
> > would expect it to do, ie uses SQL to do as much of the heavy lifting on a 
> > fetch request as possible, that column is indexed in the table and sqllite 
> > is using the index; taking multi-minutes to find one row out of 20,000 just 
> > doesn't make any sense, it should take seconds at most.
> >
> > I believe core data does use table-per-entity. I think that partly because 
> > the documentation hints at it, partly because it makes sense and partly 
> > because I looked at the implementation of one data model that I have.
> >
> > I can't see the point of making indexes if the predicate code doesn't 
> > generate SQL which doesn't use them, but it's possible. It's possible that 
> > core data goes and loads all the entity rows and inspects their attributes 
> > by hand and filters them in code, but this is apple not microsoft.
> >
> > So that leaves column isn't indexed as the most likely. But you've checked 
> > the 'indexed' box. Here's another wild assed guess, does coredata only 
> > create a store when you have no current store? It certainly checks to see 
> > if the store is compatible with the model but as the indexed property is 
> > just a hint anyway, that store is compatible, just non-optimal .. it's 
> > possible if you created the store with the property defined as not-indexed 
> > and have just checked that box later, without regenerating the whole store, 
> > the index was never added. Did you do that, just check it later? Have you 
> > regenerated a complete new store since or are you using a store you've been 
> > populating for a while.
> >
> > Here's a particularly ugly idea, purists please stop reading now. We can 
> > look at the store and see if it has an index on that property ... first get 
> > up a terminal window and go to the path where your store is. I'm assuming 
> > you have sqlite3 installed like I do .. it came with the OS as far as I 
> > know.
> >
> > Your store should be called something.sqlite, let's say it's Foo. Type
> >
> >       sqlite3 Foo.sqlite
> >
> > and that should open the store and give you a prompt. First you want to 
> > find the tables in the store, so type
> >
> >       .tables
> >
> > as far as I can see they are called Z, so for you I'd 
> > expect to see one of the tables called ZMCARTICLE. If there is one, you can 
> > find out what indices are on it
> >
> >       .indices ZMCARTICLE
> >
> > I believe again the indices are called Z_Z > NAME>_INDEX, so you'd expect to find ZMCARTICLE_ZMESSAGEID_INDEX in that 
> > list. If you don't have it, the store wasn't created with that index. If 
> > none of those tables exist at all, my rudimentary reverse engineering of 
> > the whole coredata thing is flawed (or I'm using some entirely different 
> > version from you).
> >
> > If the tables and indices exist, including the one on ZMESSAGEID, I'm out 
> > of ideas unless someone knows of a way to put coredata into a form of debug 
> > mode and see the SQL generated to figure out if it's doing anything smart.
> >
> > If either none of the above works or it does work but you don't have the 
> > index, you have a couple of options. The right one is to delete your whole 
> > message store and run your app and make a brand new one to see if that then 
> > adds the indexed property with an index. Depending on how you've populated 
> > the store, that might be a real pain, perhaps you can force a migration or 
> > something. The other really stupid idea would be to just add the index and 
> > hope that doesn't break everything entirely which is entirely possible at 
> > which point you delete the store and start over. You would do that by 
> > running
> >
> >       CREATE INDEX ZMCARTICLE_ZMESSAGEID_INDEX ON ZMCARTICLE (ZMESSAG

Re: How to get small UISegmentedControl?

2010-02-13 Thread Henry McGilton (Boulevardier)

On Feb 13, 2010, at 11:39 AM, Laurent Daudelin wrote:

> Is there anyway to have smaller segmented controls besides the large ones 
> available in IB? I'm talking the size of the one in Settings->General for 
> Location Services. Any idea?


Using Interface Builder's Attributes Inspector, set the style to Bar.
There's a pull-down named Style right at the top of the inspector,
with choices of Plain, Bordered, or Bar . . .

If you're doing it programmatically, do a
  
[yourControl setSegmentedControlStyle: UISegmentedControlStyleBar];


Cheers,
. . . . . . . .Henry


=
iPhone App Development and Developer Education . . .
Visit  www.nonatomic-retain.com

Mac OSX Application Development, Plus a Great Deal More . . .
Visit  www.trilithon.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: Validating unique objects in CoreData

2010-02-13 Thread Jerry Krinock

On 2010 Feb 13, at 13:51, daniele malcom wrote:

> Hi Roland, in fact indices table exists (for DDArticle entity):
> Enter SQL statements terminated with a ";"
> sqlite> .tables
> ZDDARTICLEZ_METADATAZ_PRIMARYKEY
> sqlite> .indices ZDDARTICLE
> ZDDARTICLE_ZMESSAGEID_INDEX
> ZDDARTICLE_ZPARENT_INDEX
> 
> With my macbook pro insertion of 30k articles took about 2/3 minutes.
> I've uploaded a test project:
> http://dl.dropbox.com/u/103260/CoreDataTreeTest.zip
> I really don't know why it should take this long time but using
> Instruments the big part is obviously fetch for searching id and
> parent.

Sorry, I've not downloaded your project yet.

If you're using garbage collection, ignore this.  If not, in your previous 
code, I noticed there was a memory leak in using -newArticleWithID:.

Another silly idea, just for fun, would be to create that predicate in code.  I 
just don't like -predicateWithFormat:.  Something like this (untested code):

NSExpression* lhs = [NSExpression expressionForKeyPath:@"messageid"] ;
NSExpression* rhs = [NSExpression expressionForConstantValue:_msgid];
NSPredicate *predicate ; 
predicate = [NSComparisonPredicate predicateWithLeftExpression:lhs
   rightExpression:rhs
  
modifier:NSDirectPredicateModifier
  
type:NSEqualToPredicateOperatorType
   options:0] ;

For some real evil, run that query using the sqlite command-line program and 
see how long it takes :0

___

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

Please do not post 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: Validating unique objects in CoreData

2010-02-13 Thread Sean McBride
Roland King (r...@rols.org) on 2010-02-13 22:06 said:

>That's not a horrible solution, except for the feeling that core data
>ought to let you do what you want without having to implement your own
>UUID cache.

I have found it useful, on many occasions, to add a 'uuid' attribute to
many of my Core Data entities.  I set it in awakeFromInsert.  I have
found NSManagedObject's objectID method largely useless since, as the
docs say, "if the receiver has not yet been saved, the object ID is a
temporary value that will change when the object is saved".  I guess
that could be acceptable in some situations, but in a document-based
app, it's the user that decides when saving happens.  I have also found
it odd that Core Data behaves like this, but I guess there is some SQL/
database reason for it all...

Sean

--
"None are more hopelessly enslaved than those who falsely believe they
are free." - Goethe

___

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

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

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

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


Re: How to get small UISegmentedControl?

2010-02-13 Thread Roland King
You mean the on-off switch? That's not a segmented control it's a  
toggle switch.


There's a useful ui catalog example you can build and keep on your  
phone which shows all the available widgets and most of the different  
flavours. I keep it around.




On 14-Feb-2010, at 3:39, Laurent Daudelin   
wrote:


Is there anyway to have smaller segmented controls besides the large  
ones available in IB? I'm talking the size of the one in Settings- 
>General for Location Services. Any idea?


-Laurent.
--
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelinhttp://nemesys.dyndns.org
Logiciels Nemesys Software  
laurent.daude...@gmail.com
Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries

___

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

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


Crash while drawing cell in NSOutlineView

2010-02-13 Thread Trygve Inda
In code based largely on Apple's SourceView, I am drawing by IconAndTextCell
and getting a crash...

Anyone seen this and know what it might be?

I have added code to draw a badge which I am updating frequently - if I only
call it once, it works ok... But if it is called rapidly I get:

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib   0x7fff818ab120 objc_msgSend + 44
1   com.apple.CoreFoundation  0x7fff867ac246
_CFAutoreleasePoolPop + 230
2   com.apple.AppKit  0x7fff81a69d3d -[NSTableView
drawRow:clipRect:] + 1343
3   com.apple.AppKit  0x7fff81a695cb -[NSTableView
drawRowIndexes:clipRect:] + 369
4   com.apple.AppKit  0x7fff81a6944c -[NSOutlineView
drawRowIndexes:clipRect:] + 131
5   com.apple.AppKit  0x7fff81a67f78 -[NSTableView
drawRect:] + 1302
6   com.apple.AppKit  0x7fff81a5e05e -[NSView
_drawRect:clip:] + 3566
7   com.apple.AppKit  0x7fff81a5b834 -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRect
ForView:topView:] + 2112
8   com.apple.AppKit  0x7fff81a5c1bf -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRect
ForView:topView:] + 4555
9   com.apple.AppKit  0x7fff81a5c1bf -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRect
ForView:topView:] + 4555
10  com.apple.AppKit  0x7fff81a5c1bf -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRect
ForView:topView:] + 4555
11  com.apple.AppKit  0x7fff81a5c1bf -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRect
ForView:topView:] + 4555
12  com.apple.AppKit  0x7fff81a5ae17 -[NSThemeFrame
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRect
ForView:topView:] + 254
13  com.apple.AppKit  0x7fff81a576bf -[NSView
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 2683
14  com.apple.AppKit  0x7fff819d0f37 -[NSView
displayIfNeeded] + 969


___

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

Please do not post 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: Crash while drawing cell in NSOutlineView

2010-02-13 Thread Sean McBride
Trygve Inda (cocoa...@xericdesign.com) on 2010-02-14 22:13 said:

>In code based largely on Apple's SourceView, I am drawing by IconAndTextCell
>and getting a crash...
>
>Anyone seen this and know what it might be?
>
>I have added code to draw a badge which I am updating frequently - if I only
>call it once, it works ok... But if it is called rapidly I get:
>
>Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
>0   libobjc.A.dylib   0x7fff818ab120 objc_msgSend + 44

Have you read this?



Sean

--
"It is difficult to get a man to understand something when his salary
depends upon him not understanding it." - Upton Sinclair

___

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

Please do not post 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: Crash while drawing cell in NSOutlineView

2010-02-13 Thread Trygve Inda
> Trygve Inda (cocoa...@xericdesign.com) on 2010-02-14 22:13 said:
> 
>> In code based largely on Apple's SourceView, I am drawing by IconAndTextCell
>> and getting a crash...
>> 
>> Anyone seen this and know what it might be?
>> 
>> I have added code to draw a badge which I am updating frequently - if I only
>> call it once, it works ok... But if it is called rapidly I get:
>> 
>> Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
>> 0   libobjc.A.dylib   0x7fff818ab120 objc_msgSend + 44
> 
> Have you read this?
> 
>  objc_explain_So_you_crashed_in_objc_msgSend.html>
> 
> Sean
> 
> --
> "It is difficult to get a man to understand something when his salary
> depends upon him not understanding it." - Upton Sinclair
> 
> 

Most excellent!

Thank you for this reference... As obviously I had not come across it.

Maybe I will get to do some non-work this Saturday night.

Cheers,

Trygve


___

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

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

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

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


Re: How to get small UISegmentedControl?

2010-02-13 Thread Laurent Daudelin
Roland, I must have worked too late. You're right. Thanks!

-Laurent.
-- 
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin 
http://nemesys.dyndns.org
Logiciels Nemesys Software  
laurent.daude...@gmail.com
Photo Gallery Store: http://laurentdaudelin.shutterbugstorefront.com/g/galleries

On Feb 13, 2010, at 17:24, Roland King wrote:

> You mean the on-off switch? That's not a segmented control it's a toggle 
> switch.
> 
> There's a useful ui catalog example you can build and keep on your phone 
> which shows all the available widgets and most of the different flavours. I 
> keep it around.
> 
> 
> 
> On 14-Feb-2010, at 3:39, Laurent Daudelin  wrote:
> 
>> Is there anyway to have smaller segmented controls besides the large ones 
>> available in IB? I'm talking the size of the one in Settings->General for 
>> Location Services. Any idea?
>> 
>> -Laurent.
>> -- 
>> Laurent Daudelin
>> AIM/iChat/Skype:LaurentDaudelinhttp://nemesys.dyndns.org
>> Logiciels Nemesys Software  
>> laurent.daude...@gmail.com
>> Photo Gallery Store: 
>> http://laurentdaudelin.shutterbugstorefront.com/g/galleries
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> Please do not post 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


Re: Validating unique objects in CoreData

2010-02-13 Thread Roland King
ok I downloaded your project. I agree with Jerry there's a memory leak, 
actually worse than that, you aren't actually remembering the article to set 
its parent if you create it, so 

[ DDArticle newArticleWithID: messageid context:ctx ];

should be 

article = [ DDArticle newArticleWithID: messageid context:ctx ];
[ article release ];

I got the test to run in 30 seconds, which isn't too bad as just looping over 
the articles takes about 7 seconds itself. Here's your problem, you're never 
saving the work, so you are building up all the articles you're adding in 
memory. Yes the SQL store has an index on it and yes coredata is issuing the 
correct select command but .. there's nothing in the store. So as well as 
looking in the store, it also has to scan every one of the objects still 
waiting to be persisted. Clearly even though it uses an index on the SQL, it 
doesn't use the index hint to build an in-memory map for finding the in-memory 
objects which match a predicate. So yes your adds go slower and slower and 
slower as core data each time does one SQL lookup in an always empty database 
which finds 0 objects in 0.0005 of a second, then goes scanning an increasing 
set of pending objects one by one. Since you never match as your IDs are 
unique, it scans the whole set every time. If you log it you'll see it adding 
slower and slower each iteration. 

So I tried adding in [ archive save ] to make it commit and was surprised to 
find nothing changed, until I realized that [ archive save ] saves the wrong 
context, in fact your example code never saves anything to the DB at all! 

Adding this in inside your add loop

if( [ [ ctx updatedObjects ] count ] > 100 )
[ ctx save:nil ];

means the working set is never larger than 100, so that limits the amount of 
in-memory lookup, once the objects are cached in the DB, the SQL lookup piece 
is blisteringly quick, so your check for existing objects runs in nearly 
constant time. 100 is a parameter you can tweak, you could just save every 
single time but that probably has overhead, if you make it much larger than 100 
you have the save overhead less often but you have to scan more in-memory 
objects, it's a compromise. 

1000 checks and inserts a second seems .. about ok to me and if you make sure 
and save the context regularly, you should be able to keep that rate up even as 
the database size grows. 

On 14-Feb-2010, at 5:51 AM, daniele malcom wrote:

> Hi Roland, in fact indices table exists (for DDArticle entity):
> Enter SQL statements terminated with a ";"
> sqlite> .tables
> ZDDARTICLEZ_METADATAZ_PRIMARYKEY
> sqlite> .indices ZDDARTICLE
> ZDDARTICLE_ZMESSAGEID_INDEX
> ZDDARTICLE_ZPARENT_INDEX
> 
> With my macbook pro insertion of 30k articles took about 2/3 minutes.
> I've uploaded a test project:
> http://dl.dropbox.com/u/103260/CoreDataTreeTest.zip
> I really don't know why it should take this long time but using
> Instruments the big part is obviously fetch for searching id and
> parent.
> 
> On Sat, Feb 13, 2010 at 2:53 PM, Roland King  wrote:
>> 
>> .. oh and one other thing, there's a core data instruments tool in XCode, 
>> well there is for OSX, not for iPhoneOS which I develop for which may be why 
>> I never saw it before. You could try that.
>> 
>> On 13-Feb-2010, at 9:36 PM, Roland King wrote:
>> 
>>> ok, I don't see anything wrong with the predicate code, but I'm no core 
>>> data expert.
>>> 
>>> I'll make one totally challengable statement. Assuming that core data uses 
>>> sqllite in a rational way to store objects (eg not storing everything as 
>>> blobs of opaque data) for instance one table per entity where each column 
>>> of the table is an attribute and evaluating the predicate does what you 
>>> would expect it to do, ie uses SQL to do as much of the heavy lifting on a 
>>> fetch request as possible, that column is indexed in the table and sqllite 
>>> is using the index; taking multi-minutes to find one row out of 20,000 just 
>>> doesn't make any sense, it should take seconds at most.
>>> 
>>> I believe core data does use table-per-entity. I think that partly because 
>>> the documentation hints at it, partly because it makes sense and partly 
>>> because I looked at the implementation of one data model that I have.
>>> 
>>> I can't see the point of making indexes if the predicate code doesn't 
>>> generate SQL which doesn't use them, but it's possible. It's possible that 
>>> core data goes and loads all the entity rows and inspects their attributes 
>>> by hand and filters them in code, but this is apple not microsoft.
>>> 
>>> So that leaves column isn't indexed as the most likely. But you've checked 
>>> the 'indexed' box. Here's another wild assed guess, does coredata only 
>>> create a store when you have no current store? It certainly checks to see 
>>> if the store is compatible with the model but as the indexed property is 
>>> just a hint anyway, that store is co

Core data - loading a subtree of objects

2010-02-13 Thread Gideon King
Hi, I have an application where I have a model for all the data of the 
application, but sometimes I want to replace a subtree within the object graph 
with a new set of objects loaded from a file. I am looking for advice on the 
best way to handle this.

If I created a completely separate model, then I would have to have a lot of 
the same object definitions in both models, and maintenance would be a 
nightmare.

These same classes are necessary in both the main data and the subset, so I 
don't think that the merged models thing works.

One thing I thought was the possibility of loading it using the same persistent 
store definition, but when it is that file type, it will just load this subset 
of the objects (it's an NSAtomicStore subclass) into a separate context, and 
then I use the objects from that context and migrate them to my main document 
context, replacing the objects that are there. Would that be a good solution?

Any advice on how to handle this would be very welcome.

Thanks

Gideon



___

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

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


executeFetchRequest with BETWEEN

2010-02-13 Thread Gerriet M. Denkmann
I would like to get some entities (in iPhone 3.1.3). So I do:

NSNumber *sta = ...
NSLog(@" sta %@ %@ %p", sta, [sta class],sta);  //  sta 6 NSCFNumber 
0x3b3a690
NSNumber *las = ...

NSArray *limits = [ [ NSArray alloc ] initWithObjects: sta, las, nil ];
predicate = [ NSPredicate predicateWithFormat: @"%K between %@", @"windex", 
limits ];
[ limits release ];

[ reques2 setPredicate: predicate ];
NSSortDescriptor *sd = [ [ NSSortDescriptor alloc ] initWithKey: @"windex" 
ascending: YES ];
NSArray *sortDescriptors = [ [ NSArray alloc ] initWithObjects: sd, nil ];
[ sd release ];
[ reques2 setSortDescriptors:(NSArray *)sortDescriptors ];
[ sortDescriptors release ];

NSLog(@" will executeFetchRequest %@", reques2);
//  will executeFetchRequest  (entity: DictWord; 
predicate: (windex BETWEEN {6, 4842}); sortDescriptors: (
(windex, ascending, compare:)
); limit: 0)

//  Note: windex is an int32 predicate of the entity DictWord

NSError *outError;
NSArray *results = [ moc executeFetchRequest: reques2  error: &outError ];

But instead of some nice results I get:
 *** -[NSCFNumber constantValue]: unrecognized selector sent to instance 
0x3b3a690

Note: constantValue is a message understood by NSExpression (not by NSNumber)
and 0x3b3a690 is my NSNumber sta (see above).

It seems that my predicate is wrong, but how to make it right?


Kind regards,

Gerriet.



___

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

Please do not post 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: Crash while drawing cell in NSOutlineView

2010-02-13 Thread Henry McGilton (Boulevardier)

On Feb 13, 2010, at 7:57 PM, Trygve Inda wrote:

>> Trygve Inda (cocoa...@xericdesign.com) on 2010-02-14 22:13 said:
>> 
>>> In code based largely on Apple's SourceView, I am drawing by IconAndTextCell
>>> and getting a crash...
>>> 
>>> Anyone seen this and know what it might be?
>>> 
>>> I have added code to draw a badge which I am updating frequently - if I only
>>> call it once, it works ok... But if it is called rapidly I get:
>>> 
>>> Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
>>> 0   libobjc.A.dylib   0x7fff818ab120 objc_msgSend + 44
>> 
>> Have you read this?
>> 
>> > objc_explain_So_you_crashed_in_objc_msgSend.html>
>> 
>> Sean
>> 
>> --
>> "It is difficult to get a man to understand something when his salary
>> depends upon him not understanding it." - Upton Sinclair
>> 
>> 
> 
> Most excellent!
> 
> Thank you for this reference... As obviously I had not come across it.
> 
> Maybe I will get to do some non-work this Saturday night.
> 

One bit caught my eye immediately:

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib   0x7fff818ab120 objc_msgSend + 44
1   com.apple.CoreFoundation  0x7fff867ac246
_CFAutoreleasePoolPop + 230 
  
2   com.apple.AppKit  0x7fff81a69d3d -[NSTableView
drawRow:clipRect:] + 1343
3   com.apple.AppKit  0x7fff81a695cb -[NSTableView

Possibly something got released that should not have been released ?

Cheers,
. . . . . . . .Henry



=
iPhone App Development and Developer Education . . .
Visit  www.nonatomic-retain.com

Mac OSX Application Development, Plus a Great Deal More . . .
Visit  www.trilithon.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


[iPhone] Black background behind UIView??

2010-02-13 Thread PCWiz
I have a really simple UIView subclass, all it contains is this:

- (void)drawRect:(CGRect)rect
{
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(ctx, 1.0f, 1.0f, 1.0f, 1.0f);
CGContextFillEllipseInRect(ctx, CGRectMake(10.0f, 10.0f, 100.0f, 
100.0f));
}

It should draw a white circle. To use it, I'm programatically creating the view 
using UIView initWithFrame: then adding it as a subview in my 
UIViewController's viewDidLoad method. The problem is that a black square 
appears behind the circle. I don't know if this is due to the fact that there 
are several CALayers under the view. Any suggestions?


Independent Cocoa Developer, Macatomy Software
http://macatomy.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


Executing shell script with root privilege

2010-02-13 Thread cocoa learner
 Hi all,

I want to execute a shell script with "root" privilege and here is the code
for that I am using -

- (BOOL) launchScript

{

OSStatus authStatus;

AuthorizationRef authRef = nil;

 authStatus = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment,
kAuthorizationFlagDefaults, &authRef);

if (authStatus != errAuthorizationSuccess)

{

return FALSE;

}

AuthorizationItem right = {kAuthorizationRightExecute, 0, NULL, 0};

AuthorizationRights rights = {1, &right};

AuthorizationFlags flags = (kAuthorizationFlagDefaults |

  kAuthorizationFlagInteractionAllowed |
kAuthorizationFlagPreAuthorize |

 kAuthorizationFlagExtendRights);



authStatus = AuthorizationCopyRights(authRef, &rights, NULL, flags, NULL);

if (authStatus != errAuthorizationSuccess)

{

AuthorizationFree(authRef, kAuthorizationFlagDestroyRights);

return FALSE;

}

char *cmd = "/Users/test/myScript";

char *args[] = {NULL};

FILE *pipe = NULL;

authStatus = AuthorizationExecuteWithPrivileges(authRef,

cmd,

 kAuthorizationFlagDefaults,

   args,

  &pipe);

   if (authStatus == errAuthorizationSuccess)

   {

   return TRUE;

   }

   return FALSE;

}


And the shell script looks like this -


#!/bin/bash

WHO=`whoami`

echo "I am executed as [ $WHO ]" > /tmp/debugScript

id -u >> /tmp/debugScript

And permission of this script is -
-rwx-- 1 root  wheel  536 Feb 14 10:51 /Users/test/myScript


When I am executing the app "launchScript" is returning me TRUE but my
script is not getting executed. I am totally lost, have no clue why it's
happening like this.

Does any body know why this script is not getting executed? Am I doing any
thing wrong?

Regards
Cocoa.learner
___

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

Please do not post 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: Core data - loading a subtree of objects

2010-02-13 Thread Jerry Krinock
Gideon, I don't understand all the details of your situation, but it is likely 
that you would find this thread interesting.

http://www.cocoabuilder.com/archive/cocoa/225972-copying-managed-objects-from-app-to-doc-mocontext.html

___

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

Please do not post 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: [iPhone] Black background behind UIView??

2010-02-13 Thread David Duncan
On Feb 13, 2010, at 9:45 PM, PCWiz wrote:

> I have a really simple UIView subclass, all it contains is this:
> 
> - (void)drawRect:(CGRect)rect
> {
>   CGContextRef ctx = UIGraphicsGetCurrentContext();
>   CGContextSetRGBFillColor(ctx, 1.0f, 1.0f, 1.0f, 1.0f);
>   CGContextFillEllipseInRect(ctx, CGRectMake(10.0f, 10.0f, 100.0f, 
> 100.0f));
> }
> 
> It should draw a white circle. To use it, I'm programatically creating the 
> view using UIView initWithFrame: then adding it as a subview in my 
> UIViewController's viewDidLoad method. The problem is that a black square 
> appears behind the circle. I don't know if this is due to the fact that there 
> are several CALayers under the view. Any suggestions?


By default views are opaque, and the backing store for the view is likely 
filled with zeros (this is not guaranteed, but common) so the view's backing 
store is interpreted as a white circle on a black background.

If you set opaque=NO, then you may get white on a clear background, but you can 
only guarantee such behavior if you set backgroundColor=[UIColor clearColor];
--
David Duncan
Apple DTS Animation and Printing

___

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

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