Memory management about async object

2010-12-27 Thread ico
Hi,

I am working on an app that will asynchronous to load data. Suppose I have a
view controller with a method:

in MyViewController:

- (void) loadData {
DataHandler *myHandler = [[DataHandler alloc] init];
// set this view controller itself as a delegate, when the data loading
finished, myHandler will call its callback method
myHandler.delegate = self;
[myHandler startAsyncLoading];
}

// callback method get called by DataHandler when the data loading is done

- (void) myCallback:(id)responseData {
// setup the data source to be used later
}

In the DataHandler class, it will use NSURLConnection to call a webservice
to load the data asynchronous. And
it has a delegate instance variable which points to the MyViewController,
when
connectionDidFinishLoading is called, I will do like this:

- (void) connectionDidFinishLoading:(NSURLConnection *)connection {
// do something
[delegate myCallback:self];
// point 1
}

My question is, when should I release the myHandler? Should I release it in
the myCallback, but after
myCallback method finishes, it will return point 1 indicated as above, and
that myHandler instance is just
released.

Or there is a better way to deal with async object? I also wonder how
NSURLConnection class handle this itself.

Thanks.

-- 
==
Life isn't about finding yourself.
Life is about creating yourself.
___

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: Drawing to two CALayers at once (or pretend to)?

2010-12-27 Thread Seth Willits
On Dec 27, 2010, at 2:24 PM, vincent habchi wrote:

>> That, but I also don't see why the two layers would need to read the data 
>> separately. For example, their delegate can be the one to fetch and read the 
>> data and create the path from it, then save that CG path. When either layer 
>> draws, it would simply use that path. It'd be trivial.
> 
> That would be a nice trick, since it is more efficient to have the CGPaths 
> directly stored in a kind of NSArray than recomputed out of the DB, but I see 
> an obvious drawback: it is going to use a lot of memory to have all CGPaths 
> stored. Ideally, I was thinking about a way to do both operations "at once", 
> so the DB could be read line by line and contents immediately discarded (no 
> real memory overhead); but that seems unrealistic, given the present state of 
> the CA API. 


Well nobody says you have to keep the CGPaths around forever. Release them at 
your will. You can use NSCache even if you want.

You also have the option of simply assigning to the contents property of the 
layer. You don't *have* to wait for the drawing event to occur. 


--
Seth Willits



___

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

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

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

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


Re: Drawing to two CALayers at once (or pretend to)?

2010-12-27 Thread Raphael Sebbe
I think a single model instance, storing a parsed path, accessed by both
layers sounds like the best approach. If you have lots and lots of paths,
then the memory problem would be secondary to the problem of the time it
would take to parse them from your DB.

If you have actual figures, we can discuss that too.

Best,

On Mon, Dec 27, 2010 at 11:24 PM, vincent habchi  wrote:

> Le 27 déc. 2010 à 23:12, Seth Willits a écrit :
>
> > That, but I also don't see why the two layers would need to read the data
> separately. For example, their delegate can be the one to fetch and read the
> data and create the path from it, then save that CG path. When either layer
> draws, it would simply use that path. It'd be trivial.
>
> That would be a nice trick, since it is more efficient to have the CGPaths
> directly stored in a kind of NSArray than recomputed out of the DB, but I
> see an obvious drawback: it is going to use a lot of memory to have all
> CGPaths stored. Ideally, I was thinking about a way to do both operations
> "at once", so the DB could be read line by line and contents immediately
> discarded (no real memory overhead); but that seems unrealistic, given the
> present state of the CA API.
>
> Thanks too for this idea,
> Vincent___
>
> 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/raphael.sebbe%40gmail.com
>
> This email sent to raphael.se...@gmail.com
>



-- 
Raphael Sebbe
Creaceed — Creative iPhone & Mac apps
••• Twitter: http://twitter.com/rsebbe
••• Web: http://www.creaceed.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: Drawing to two CALayers at once (or pretend to)?

2010-12-27 Thread vincent habchi
Le 27 déc. 2010 à 23:12, Seth Willits a écrit :

> That, but I also don't see why the two layers would need to read the data 
> separately. For example, their delegate can be the one to fetch and read the 
> data and create the path from it, then save that CG path. When either layer 
> draws, it would simply use that path. It'd be trivial.

That would be a nice trick, since it is more efficient to have the CGPaths 
directly stored in a kind of NSArray than recomputed out of the DB, but I see 
an obvious drawback: it is going to use a lot of memory to have all CGPaths 
stored. Ideally, I was thinking about a way to do both operations "at once", so 
the DB could be read line by line and contents immediately discarded (no real 
memory overhead); but that seems unrealistic, given the present state of the CA 
API. 

Thanks too for this idea,
Vincent___

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: Drawing to two CALayers at once (or pretend to)?

2010-12-27 Thread Seth Willits
On Dec 27, 2010, at 12:59 PM, vincent habchi wrote:

>>> Knowing that the path is computed by reading values in a database, I'd like 
>>> to avoid a double reading that costs some time (even if there is a cache) 
>>> and seems redundant
>> 
>> Ancient precept: Make it right, then make it fast. Do it the simplest 
>> reasonable way, even if you can imagine a "more efficient" way to do it. 
>> Then measure.
> 
> You're absolutely right. My concern was that the cache might not be 
> sufficient to hold all data because DB traffic can be pretty high. But, first 
> of all, I must write out this routine to put the text along the paths, and 
> that isn't going to be easy.


That, but I also don't see why the two layers would need to read the data 
separately. For example, their delegate can be the one to fetch and read the 
data and create the path from it, then save that CG path. When either layer 
draws, it would simply use that path. It'd be trivial.


--
Seth Willits



___

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

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

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

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


Re: Drawing to two CALayers at once (or pretend to)?

2010-12-27 Thread vincent habchi
Le 27 déc. 2010 à 21:34, Fritz Anderson a écrit :

> On 27 Dec 2010, at 2:04 PM, vincent habchi wrote:
> 
>> Knowing that the path is computed by reading values in a database, I'd like 
>> to avoid a double reading that costs some time (even if there is a cache) 
>> and seems redundant
> 
> Ancient precept: Make it right, then make it fast. Do it the simplest 
> reasonable way, even if you can imagine a "more efficient" way to do it. Then 
> measure.

You're absolutely right. My concern was that the cache might not be sufficient 
to hold all data because DB traffic can be pretty high. But, first of all, I 
must write out this routine to put the text along the paths, and that isn't 
going to be easy.

Thanks for your input,
Vincent

___

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: Drawing to two CALayers at once (or pretend to)?

2010-12-27 Thread Fritz Anderson
On 27 Dec 2010, at 2:04 PM, vincent habchi wrote:

> Knowing that the path is computed by reading values in a database, I'd like 
> to avoid a double reading that costs some time (even if there is a cache) and 
> seems redundant

Ancient precept: Make it right, then make it fast. Do it the simplest 
reasonable way, even if you can imagine a "more efficient" way to do it. Then 
measure.

The way you describe it, the underlying data has to be cached somewhere. The 
maker of the database has had years to tune the DB's cache. Better you should 
rely on that, than spend days in the hope that you can come up with something 
better in a week. If the performance doesn't turn out to be acceptable, at 
least you'll know you won't be wasting your time.

— F

___

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

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

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

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


Re: Text rendering/editing on OSX & iOS

2010-12-27 Thread Alastair Houghton
On 21 Dec 2010, at 14:29, Ricky Sharp wrote:

> I'm not sure what you mean by "it's the same".  Do you mean pixel for pixel 
> accuracy between Mac OS X and iOS?  I don't thing that may be possible (at 
> least at a high level) as there may be different rendering techniques.

Indeed, my understanding at present (from poking about rather than any official 
word from Apple) is that on Mac OS X the font rendering is being done by ATS, 
whereas on iOS it's currently using FreeType.  In both cases, the Quartz API 
over the top is the same, but it's using a different underlying rendering 
engine.

Kind regards,

Alastair.

--
http://alastairs-place.net




___

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

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

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

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


Drawing to two CALayers at once (or pretend to)?

2010-12-27 Thread vincent habchi
Hi everybody –

well, I don't have a precise question but rather a general advice. I need to 
draw a path on a CALayer and simultaneously lay out a text along this same path 
(that can be made up of straight lines and/or arcs) on another layer 
(CATextLayer, presumably). Knowing that the path is computed by reading values 
in a database, I'd like to avoid a double reading that costs some time (even if 
there is a cache) and seems redundant; therefore, I'd like to know if there is 
a sensible way to do this (I guess there is no way to draw on both layers at 
once), or if a double read is inevitable…

Thanks!
To all, a happy and prosperous new year.

Vincent___

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: Gap above NSMenuItem custom view

2010-12-27 Thread Joshua Garnham
Okay, you win. I will go ahead and use a borderless window. I know how to make 
a 
window borderless but where should I start then? How would you suggest I deal 
with adding and remove items from this sudo menu. Should I use NSTableView?





From: Kyle Sluder 
To: Joshua Garnham 
Cc: cocoa-dev@lists.apple.com
Sent: Sun, 26 December, 2010 22:04:22
Subject: Re: Gap above NSMenuItem custom view

On Sun, Dec 26, 2010 at 4:16 PM, Joshua Garnham
 wrote:
>
> I see your point but I just found this post on Stack Overflow detailing how 
>someone else has done it.
>
>http://stackoverflow.com/questions/4064386/reverse-engineering-an-nsmenu-for-a-status-bar-item
>m
>
> However I am having dificulty compiling the code as I get EXC_BAD_ACCESS on 
> the 
>line where the event handler is installed. Can you shed any light on the code 
>in 
>that question?

1. Your question has nothing to do with compiling code. EXC_BAD_ACCESS
is a runtime exception caused by a bad pointer dereference.
2. Nobody can debug anything like this without your exact source code
and a stack trace leading up to the exception, at a bare minimum.
3. The code you posted relies on private API.
4. None of this will work on 64-bit Mac OS X.

So the answer is to stop beating this dead horse and do it the right
way. File a bug asking for support for this in NSMenu in a future
version of OS X if you like, but in the meantime your one, single,
solitary, only option is to forsake NSMenu and use a borderless
NSWindow.

--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: UITableView Custom Section Headers

2010-12-27 Thread ico
Hi Fritz,

Actually I just found the answer hours ago, I forgot all the magic things
are in the delegate protocol,
of course I need to implement those methods to make magic happen.
Anyway, thank you for your response.

On Mon, Dec 27, 2010 at 11:16 PM, Fritz Anderson wrote:

> On 27 Dec 2010, at 4:30 AM, ico wrote:
>
> > I don't know if you have figured this out. I also want to know how to do
> the
> > customization
> > on the section part of the tableview, not the cell but the section part.
> I
> > want to put some
> > custom content including an image on my section header rather than just
> some
> > text.
> >
> > Can anyone tells me how to do this? Thanks.
> >
> > 2010/8/17 Luis Israel Pasos Peña 
>
>  tableView:viewForFooterInSection:
>  tableView:viewForHeaderInSection:
>
>— F
>
>


-- 
==
Life isn't about finding yourself.
Life is about creating yourself.
___

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: UITableView Custom Section Headers

2010-12-27 Thread Fritz Anderson
On 27 Dec 2010, at 4:30 AM, ico wrote:

> I don't know if you have figured this out. I also want to know how to do the
> customization
> on the section part of the tableview, not the cell but the section part. I
> want to put some
> custom content including an image on my section header rather than just some
> text.
> 
> Can anyone tells me how to do this? Thanks.
> 
> 2010/8/17 Luis Israel Pasos Peña 

 tableView:viewForFooterInSection:
 tableView:viewForHeaderInSection:

— F

___

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

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

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

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


Re: UITableView Custom Section Headers

2010-12-27 Thread Luke Hiesterman


On Dec 27, 2010, at 2:30 AM, ico  wrote:

> Hi,
> I don't know if you have figured this out. I also want to know how to do the
> customization
> on the section part of the tableview, not the cell but the section part. I
> want to put some
> custom content including an image on my section header rather than just some
> text.
> 
> Can anyone tells me how to do this? Thanks.
> 
> 2010/8/17 Luis Israel Pasos Peña 
> 
>> I was creating an RSS reader that I thought was really cool, but then I saw
>> Jason Beaver's and Luke Hiesterman's presentation at WWDC 2010 and I went...
>> OK that's cooler.
>> 
>> So basically, I'm stuck with a couple of things in the new version of the
>> RSS reader:
>> 
>> 1. I'm implementing UIViewControllers as custom section headers, but I
>> don't know if this is the best approach. What I'm trying to do is to add an
>> Activity indicator , label and a reload button to each header so that the
>> user is able to reload a feed directly from each header. Also, the
>> allocations of the headers seem to happen every time I scroll through the
>> UITableView, I figure this isn't good at all.

You should not be using view controllers for the section headers. Remember that 
view controllers are designed around screenfuls of content - not to manage some 
subview of your table. Therefore you might be using a UITableViewController for 
the current screen, but for implementing your custom headers, all you will be 
doing is creating a custom subclass of UIView. 

As for the allocation problem, feel free to cache your custom header views if 
that makes sense for your application. Then when we ask for the header again, 
you can return the cached version. 

>> 
>> 2. I need to retrieve only the feed particular to that specific section and
>> then replace it on the tableview. To do this I need the section number. How
>> can I get the section from the tap on the section header?

There's more than one way to skin this cat, but in my demo app, I simply 
assigned the section number as a property of the custom header view when I 
created it. That way, when it was tapped it could send a message back to the 
view controller that included its section index. 

>> 
>> I don't know if Luke is still on this list, and I also know this is might
>> be too much to ask, but is there anyway we could take a look at the
>> TableViewUpdates project, much like Francois Jouaux did with Padalicious?
>> Maybe not all of it, just the part related to the headers?
>> 

This project has been made into sample code on developer.apple.com. 
https://developer.apple.com/library/ios/samplecode/TableViewUpdates/

Luke___

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

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

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

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


Re: Setting the date of a UIDatePicker [Solved]

2010-12-27 Thread Hrishikesh Murukkathampoondi
Setting it in viewDidLoad: works. I  guess setting properties of any outlet 
should be done in viewDidLoad

My earlier init method was called but maybe the outlet was not yet hooked up 
then.
Hrishi

On 27-Dec-2010, at 8:16 PM, Hrishikesh Murukkathampoondi wrote:

> I am trying to set the date of a UIDatePicker in my view. I have tried using 
> both the following in
> 
> - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle 
> *)nibBundleOrNil
> 
> of my view controller but it does not work. The date is still set to what 
> ever is specified in IB (and I am unable to set that to "current date".
> 
> [dueDate setDate:[NSDate date] animated:NO];
> dueDate.date = [NSDate date];
> 
> Should I be doing something more to set the date?
> Hrishi

___

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


Setting the date of a UIDatePicker

2010-12-27 Thread Hrishikesh Murukkathampoondi
I am trying to set the date of a UIDatePicker in my view. I have tried using 
both the following in

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

of my view controller but it does not work. The date is still set to what ever 
is specified in IB (and I am unable to set that to "current date".

[dueDate setDate:[NSDate date] animated:NO];
dueDate.date = [NSDate date];

Should I be doing something more to set the date?
Hrishi___

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: Strange error solved by turning off "Non-contiguous Layout"

2010-12-27 Thread Brad Stone
Yeah, that was it.  I get by the place where the it used to deadlock.  I'm make 
a note of that!  Thanks

On Dec 26, 2010, at 10:57 PM, Nick Zitzmann wrote:

> 
> On Dec 26, 2010, at 5:00 PM, Brad Stone wrote:
> 
>> Ken - I never knew how to take a sample of the processes.  It's given me 
>> some visibility into the spinning beach ball.  I still get the deadlock in 
>> the commitEditing which is in saveDocumentWithDelegate only on some 
>> documents when I edit text that requires me to scroll an NSTextView.  Does 
>> anything jump out at you in this call graph?  What is NSOperation waiting 
>> for?
> 
> Did you turn on the "can draw concurrently" option on the text view or its 
> scroll view? If so, then turn that off. That option will not work, except in 
> views that specifically support threaded drawing. IIRC, none of the AppKit's 
> views support this (except for NSButton and NSProgressIndicator, but they 
> have separate APIs for this for historical reasons).
> 
> Nick Zitzmann
> 
> 
> 
> 

___

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

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

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

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


Re: UITableView Custom Section Headers

2010-12-27 Thread ico
Hi,
I don't know if you have figured this out. I also want to know how to do the
customization
on the section part of the tableview, not the cell but the section part. I
want to put some
custom content including an image on my section header rather than just some
text.

Can anyone tells me how to do this? Thanks.

2010/8/17 Luis Israel Pasos Peña 

> I was creating an RSS reader that I thought was really cool, but then I saw
> Jason Beaver's and Luke Hiesterman's presentation at WWDC 2010 and I went...
> OK that's cooler.
>
> So basically, I'm stuck with a couple of things in the new version of the
> RSS reader:
>
> 1. I'm implementing UIViewControllers as custom section headers, but I
> don't know if this is the best approach. What I'm trying to do is to add an
> Activity indicator , label and a reload button to each header so that the
> user is able to reload a feed directly from each header. Also, the
> allocations of the headers seem to happen every time I scroll through the
> UITableView, I figure this isn't good at all.
>
> 2. I need to retrieve only the feed particular to that specific section and
> then replace it on the tableview. To do this I need the section number. How
> can I get the section from the tap on the section header?
>
> I don't know if Luke is still on this list, and I also know this is might
> be too much to ask, but is there anyway we could take a look at the
> TableViewUpdates project, much like Francois Jouaux did with Padalicious?
> Maybe not all of it, just the part related to the headers?
>
> Thanx in advance, for
> helping!___
>
> 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/jche128%40gmail.com
>
> This email sent to jche...@gmail.com
>



-- 
==
Life isn't about finding yourself.
Life is about creating yourself.
___

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