How to layout a networked application - conventions?

Discussion in 'iOS Programming' started by RossOliver, Jul 15, 2008.

  1. RossOliver macrumors regular

    Nov 6, 2006

    I'm after a little guidance as to how best to make my application networkable. Trying to decipher the WiTap example is proving difficult and leaves me with some questions.

    What is the general procedure for networking two instances of an application? I figure you use NSNetService/NSNetServiceBrowser to find a service, then use a TCP class to make the connection. Does the TCP class manage the peers or is that usually the job of the main application? Does the TCP class outline protocols (in the sense of how data is transferred (message layout) not as in cocoa protocols) translating input received over the connection into something more manageable for the application to act on?

    A UML diagram of the WiTap sample would have been helpful :rolleyes:

    Thanks for your time,

  2. RossOliver thread starter macrumors regular

    Nov 6, 2006
    Out of interest, NSConnection looks a whole lot easier than using CFNetwork to communicate across networks - is there any particular reason why we can't use NSConnection? For some reason it doesn't appear in my iphone os docs but I created an instance in my application and it compiled so I presume it is part of the iphone os?

  3. sujithkrishnan macrumors 6502

    May 9, 2008
    Hi Ross,

    can u give me a snippet of the most native method of establishing a http connection to get an image (or any file) from a URL ?
    I tried following line in my app, but INSTRUMENTS showing LEAK in the line.

    This line is in the cellForRowAtIndex delegate method of a UITableViewCell...
    INSTRUMENTS showing REALLOC as leak reason...

    cell.image = [UIImage imagWithData:[NSData datafromURL:myURL]];
    I broke down the statement into

    NSURL *myURL = [[NSURL alloc]intWithString:myURLString];
    NSData *dataImage = [[NSData alloc]initWithURL:myURL];
    UIImage *imageTemp = [[UIImage alloc]initWithData:dataImage];
    cell.image = imageTemp;
    [imageTemp release];
    [dataImage release];
    [myURL release];
    Still its showing mem-LEAK in SECOND line.....

    So i planned to make my own connection (in native style and try...)
    Or is there any other suggestion from you???
  4. mpramodjain macrumors regular

    Nov 20, 2008
    Hi Sujith,

    I am also having the same problem. Did you got your Own Connection or any solution for the above problem. If So Please help.

    Thank You. :(

Share This Page