Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
So it looks like I'm actually getting somewhere with ingesting an XML feed and displaying the results thanks to this handy guide but there's one thing about it I don't quite understand. That tutorial and just about every other one I've found relies on the assumption that your tableView is going to be the main view on your xib. However in this app it has to be a subview and I don't get how that's possible.

For example, in my controller's .h file I'm extending the class like so:
code:
@interface VideoViewController : UITableViewController
But for a tableView in a subview I've read you're supposed to do this:
code:
@interface VideoViewController : KCAViewController <UITableViewDelegate, UITableViewDataSource>
The latter causes two probems:

1) any line that contains self.tableView will break because now the tableView is inside of another view. I'm not sure how to access the tableView as self.view.tableView doesn't seem to work. I really don't get this part.
2) even though I have the tableView's DataSource and delegate set to File's Owner none of the tableView initialization functions are getting called when the view loads. Setting the tableView's Referencing Outlet to the master view doesn't seem to do anything either.

Sorry for all of the questions but I swear every little bit helps as I've come a long way in a few short days.


e:poo poo sorry fankey i didn't mean to bump to the next page before your question had a chance to be answered. here's what he asked

Adbot
ADBOT LOVES YOU

Zhentar
Sep 28, 2003

Brilliant Master Genius

Yodzilla posted:

1) any line that contains self.tableView will break because now the tableView is inside of another view. I'm not sure how to access the tableView as self.view.tableView doesn't seem to work. I really don't get this part.

self.tableView just means your class has a @property UITableView* tableView. It doesn't matter if that table view is inside of another view, or is the main view, or isn't loaded anywhere at all. If you want those references to work in a non-UITableViewController, then you have to provide that property yourself.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
Yeah I figured it out last night. I didn't realize that if you want a tableView as a subview you have to extend <UITableViewDelegate, UITableViewDataSource>, declare ithe tableView object in your .h file, synthesize it in your .m, and then have the Referencing Outlet go back to the tableVIew you declared in the file's owner. Once it did that it worked great!

I'm still not sure WHY all of this stuff works the way it does but thankfully I was able to get it pulling down RSS data and clicking through to other pages just fine. I guess the only thing now is that I've got to figure out how to get the app not to hang while it loads the images.

Doc Block
Apr 15, 2003
Fun Shoe
What don't you understand? You can't access self.whatever if whatever isn't a declared property of self. UITableViewDelegate and UITableViewData aren't classes you're extending, they're protocols. Basically, saying that your class conforms to a certain protocol is a way of telling other classes that your class implements certain methods.

For instance, if your class is the delegate for a table view, the table view can check to see if your class has been declared as conforming to the UITableViewDelegate protocol, and know that your class implements the methods necessary for the table view to tell your class when something happens, etc.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
Gotcha. See I'm coming from a primarily .Net and Java background so doing things this way is a bit nebulous to me. I was basically given this project because "Hey you know how to make Droid apps, this probably the same thing!" so it's been a bit of a trial by fire combined with :downs:

It also doesn't help that no one I know professionally does any mobile development at all so the entirety of my resources have to come from Googling madly for code snippets and making sense of them along with the help you guys have provided.

Yodzilla fucked around with this message at 02:19 on Jun 26, 2011

Doc Block
Apr 15, 2003
Fun Shoe
Keep in mind that Cocoa and Cocoa Touch are pretty big on the whole model-view-controller paradigm. And protocols are pretty much the same thing as interfaces in C# and Java, as far as I know.

Read these two important links from the OP: The Objective-C Programming Language and Memory Management Programming Guide.

Also, even though you're a .NET and Java programmer, From C++ to Objective-C might be at least a little helpful, and is fairly short. This one helped me a lot.

And if you have questions about a specific class, a good place to start is Apple's own docs for that class (which are usually the first or second result of googling for the class name).

Doc Block fucked around with this message at 08:35 on Jun 26, 2011

kitten smoothie
Dec 29, 2001

pokeyman posted:

As far as I know it's replaced with the Developer NDA, so you still can't talk about session contents on a forum such as this one.

I wish I knew why Apple is so NDA-happy about this stuff. Anyone with a pulse can get a free basic developer account. All it takes is a hundred bucks to get access to the prerelease SDK, and the tech press is perfectly happy breaking the NDA anyway.

It seems to stifle interaction between developers since you are not supposed to talk about it under except under the watchful gaze of Apple's dev forum. I remember 2 years ago (the last year Apple didn't post these sessions) a guy in my local Cocoa dev social group went to WWDC. From the way he refused to talk about any of it under pain of the WWDC NDA, you'd think he was protecting nuclear weapons secrets, not iOS 3.0 APIs.

xzzy
Mar 5, 2009

kitten smoothie posted:

I wish I knew why Apple is so NDA-happy about this stuff. Anyone with a pulse can get a free basic developer account. All it takes is a hundred bucks to get access to the prerelease SDK, and the tech press is perfectly happy breaking the NDA anyway.

Apple didn't get its reputation for being one of the most litigious out there for no reason!

My suspicion is they just want it as an option to sue the poo poo out of someone who starts talking bad about their stuff in public.

kitten smoothie
Dec 29, 2001

xzzy posted:

Apple didn't get its reputation for being one of the most litigious out there for no reason!

My suspicion is they just want it as an option to sue the poo poo out of someone who starts talking bad about their stuff in public.

It did occur to me just now it might be because the presence of a feature in a beta OS image or SDK libraries could be taken as a commitment to actually deliver it in a final build. That way if some beta feature ends up getting axed before release and TUAW or Techcrunch tries to crucify them for it, Apple Legal can send them something reminding them that they shouldn't have talked about Fight Club. Or if some end user sues, Apple can shoot it down by saying the user should never have known about it anyway.

I used to work for a big software company that did something similar. They didn't NDA the heck out of everything, but every brochure, PowerPoint deck, etc that discussed planned features had a standard disclaimer that said we in no way were committing to deliver anything in there -- so don't go dropping a few hundred grand on our software and then sue us when some feature isn't in the box.

kitten smoothie fucked around with this message at 01:29 on Jun 27, 2011

Sch
Nov 17, 2005

bla bla blaufos!bla bla blaconspiracies!bla bla bla
Yeah, I think Apple's insistence on NDAs is just part of their "we don't announce products until they actually ship" MO.

If you watch the "Full Screen and Aqua Changes" WWDC video, for example, they discuss some stuff near the end that pretty clearly hints at future hardware. Of course even in the session they never make any direct reference to that. But I bet in a year or two Steve will get up on stage and present PENUS PENUS PENUS to a cheering audience, pointing out that they're the first to accomplish that, only to top it off with a "x% of apps in the App Store already support PENUS PENUS PENUS".

fankey
Aug 31, 2001

If I had to guess I'd say it's more likely an issue with patent rights.

From http://www.tms.org/pubs/journals/JOM/matters/matters-9405.html

quote:

Second, the use of confidentiality agreements can prevent the forfeiture of valuable patent rights. Under U.S. law and in other countries as well, the public disclosure of an invention can be deemed as a forfeiture of patent rights in that invention. A properly drafted confidentiality agreement can avoid the undesired—and often unintentional—forfeiture of valuable patent rights.

My non-lawyer understanding is that once something is public knowledge you loose the ability to file a patent. By wrapping things up in an NDA you can claim it was still confidential and are able to file a patent. I haven't read the Apple NDA to see if this applies but I know my work has used an NDA to make sure we could still patent things before releasing a product.

Small White Dragon
Nov 23, 2007

No relation.

mc.schroeder posted:

If you watch the "Full Screen and Aqua Changes" WWDC video, for example, they discuss some stuff near the end that pretty clearly hints at future hardware. Of course even in the session they never make any direct reference to that. But I bet in a year or two Steve will get up on stage and present PENUS PENUS PENUS to a cheering audience, pointing out that they're the first to accomplish that, only to top it off with a "x% of apps in the App Store already support PENUS PENUS PENUS".
That said, references to this particular feature were in the first Lion seeds.

Toady
Jan 12, 2009

Zhentar posted:

self.tableView just means your class has a @property UITableView* tableView.

Doc Block posted:

What don't you understand? You can't access self.whatever if whatever isn't a declared property of self.

Note that you don't need a @property declaration. A regular -(UITableView *)tableView method will also work. Dot-syntax and properties are just alternate ways of calling and declaring accessor methods.

mc.schroeder posted:

If you watch the "Full Screen and Aqua Changes" WWDC video, for example, they discuss some stuff near the end that pretty clearly hints at future hardware.

They've been referencing this hypothetical hardware since the "Resolution Independent UI Release Notes for Mac OS X v10.4." It's seriously been that long that they've been hammering on high-resolution OS X.

aehiilrs
Apr 1, 2007
I wrote an iPhone app for work and am now in the process of doing the same thing in Blackberry WebWorks.

I would just like to say that the iOS SDK, tools, and documentation are amazing and I miss them very much. :(

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
Anyone used an html page and web view for their app help file? I can muddle my way through design but I'm really just looking for a product, template, or whatever that will make it easier to create a page that doesn't look like absolute dog-crap. I've been scouring template sites but can't find anything suitable so far.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Ender.uNF posted:

Anyone used an html page and web view for their app help file? I can muddle my way through design but I'm really just looking for a product, template, or whatever that will make it easier to create a page that doesn't look like absolute dog-crap. I've been scouring template sites but can't find anything suitable so far.

Simple is good. Send me your HTML and I'll make it purdy for you, since you've answered many questions of mine here.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
I can vouch for Lumpy's good design work.

Doc Block
Apr 15, 2003
Fun Shoe
Lemme just go ahead and post this: UIWebView Must Die

echobucket
Aug 19, 2004

Doc Block posted:

Lemme just go ahead and post this: UIWebView Must Die

Wow, his comments about how slow UIWebView is explains why when I used the Laker framework for an app, it was REALLY slow moving between pages.

http://www.lakercompendium.com/

skidooer
Aug 6, 2001

Doc Block posted:

Lemme just go ahead and post this: UIWebView Must Die
Ah, that takes me back to the time I wrote my own HTML renderer before CoreText was available. Fun times. Funnily enough, I just started playing with CoreText last night. Who says it isn't copy/paste-able? :)

Sch
Nov 17, 2005

bla bla blaufos!bla bla blaconspiracies!bla bla bla

skidooer posted:

Funnily enough, I just started playing with CoreText last night. Who says it isn't copy/paste-able? :)

Wait, are you saying you implemented your own custom text selection, which works and behaves exactly like the native one, including markers, loupe and so on, directly on top of low-level CoreText APIs? In one night?

skidooer
Aug 6, 2001

mc.schroeder posted:

Wait, are you saying you implemented your own custom text selection, which works and behaves exactly like the native one, including markers, loupe and so on, directly on top of low-level CoreText APIs? In one night?
I wish. No, it is UITextView backed, so it uses the native controls. It works very well for what I need, though I realize that wouldn't be suitable for all situations. I just was poking fun at one of the comments in the article.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

skidooer posted:

I wish. No, it is UITextView backed, so it uses the native controls. It works very well for what I need, though I realize that wouldn't be suitable for all situations. I just was poking fun at one of the comments in the article.

Wait, so you implemented a UITextView that does syntax coloring? Can you give any tips? I have a project in my mind that would have a use for that and I looked at Core Text a bit, but I never got to dive in further. Does a UITextView make it fairly easy to style it's backing store?

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

Lumpy posted:

Simple is good. Send me your HTML and I'll make it purdy for you, since you've answered many questions of mine here.

Awww shucks ;-*

I will send you what I have and my sad attempt to make something more than 1996-esque html. Many thanks!


edit: Also, remember to thank your designers kids.

Simulated fucked around with this message at 18:41 on Jun 29, 2011

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
I'm having some trouble with custom fonts being applied to button and I'm not sure what the best way to handle it is. In the interface builder I can choose the font for a button but it's reading from the fonts that I have on my system, not the fonts that the app has access to.

I've included the font file that I want to use as a Reference in my project and in the Info.plist I've added a "Fonts provided by application" array with one item, the name of the file in this case BerkeBol for Berkeley Bold.

It seems that selecting Berkeley Bold in the interface builder doesn't do anything as it just goes back to whatever the default is and trying to apply the font programatically doesn't seem to work either.

code:
theButton.titleLabel.font = [UIFont fontWithName:@"BerkeBol" size:22.0];
I've also tried setting the fontWithName value to longer names like "ITC-Berkeley-Oldstyle-Bold" which is the full Font Book name with spaces turned into dashes like I've read you're supposed to. I've tried it with just spaces and that doesn't work either.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

Yodzilla posted:

I'm having some trouble with custom fonts being applied to button and I'm not sure what the best way to handle it is. In the interface builder I can choose the font for a button but it's reading from the fonts that I have on my system, not the fonts that the app has access to.

I've included the font file that I want to use as a Reference in my project and in the Info.plist I've added a "Fonts provided by application" array with one item, the name of the file in this case BerkeBol for Berkeley Bold.

It seems that selecting Berkeley Bold in the interface builder doesn't do anything as it just goes back to whatever the default is and trying to apply the font programatically doesn't seem to work either.

code:
theButton.titleLabel.font = [UIFont fontWithName:@"BerkeBol" size:22.0];
I've also tried setting the fontWithName value to longer names like "ITC-Berkeley-Oldstyle-Bold" which is the full Font Book name with spaces turned into dashes like I've read you're supposed to. I've tried it with just spaces and that doesn't work either.


I am doing this exact thing and it is working for me. Make sure:

1. The Fonts Provided by Application in info.plist must be the *exact* filename, including case and extension. If your font file doesnt have an extension, give it the correct one (tg: ttf).

2. The font name often doesn't match what you might consider a sensible value, so double-click the font file to open it in Font Book. Look at the title, which should be the "Family Name" of the font.

3. Now call [UIFont fontNamesForFamilyName:@""] with that title then log those array values to the console. That should tell you the real exact name(s) of the font to pass to fontWithName:. Use the names exactly as printed, case and all.

Yodzilla
Apr 29, 2005

Now who looks even dumber?

Beef Witch
Holy poo poo that got it working. I also downloaded a new file in case the old one was corrupt or something, added the .ttf extension, and readded it to the root of my project because gently caress it I just want to get this stupid poo poo working.

Also I found this handy code for listing all of the font families available to your iOS app:

code:
// List all fonts on iPhone
    NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
    NSArray *fontNames;
    NSInteger indFamily, indFont;
    for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
    {
        NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
        fontNames = [[NSArray alloc] initWithArray:
                     [UIFont fontNamesForFamilyName:
                      [familyNames objectAtIndex:indFamily]]];
        for (indFont=0; indFont<[fontNames count]; ++indFont)
        {
            NSLog(@"    Font name: %@", [fontNames objectAtIndex:indFont]);
        }
        [fontNames release];
    }
    [familyNames release];
And yeah I could use the font's name as displayed spaces and all. Thanks!

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

Yodzilla posted:

stuff

You are welcome.

Also just for people who are new to the platform, that example code is weirdly allocating memory that isn't necessary. I know you didn't write it but I don't want people to see this thread and think you need to do that. This code is cleaner and faster:

code:
    for (NSString *familyName in [UIFont familyNames])
    {
        NSLog(@"Family name: %@", familyName);
        for(NSString *fontName in [UIFont fontNamesForFamilyName:familyName])
        {
            NSLog(@"    Font name: %@", fontName);
        }
    }
Specifically junk like this: "NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];" is totally unnecessary. familyNames is returning an auto-released array that is guaranteed to survive as long as your method is executing so why allocate memory for a new array just to copy the contents of the old array into the new array, that is then released? That's a lot of useless copying and the original array will still live until the autorelease pool is emptied at the end of the run loop anyway.

I can only guess the original author did that thinking the array from UIFont was going to disappear but that's not possible. Worst-case, you could send a retain message to the array (which retains all the objects it contains anyway) then release it later (or assign it to a retain property). But again, that's all a bit pointless.


ProTip #8273: "for(type name in collection)" syntax is much faster to execute than any other pattern and you should use it unless you explicitly need the numeric index of an object.

Vinlaen
Feb 19, 2008

What are some popular (?) options for developers not wanting to code in Objective-C?

I'd love to use Unity3D but I want a 2D game... Another choice is Monotouch but it doesn't seem very popular what-so-ever for games.

Are there any games in the top 20 that aren't written in pure Objective-C (with cocos2d most likely?)

Doc Block
Apr 15, 2003
Fun Shoe
What's wrong with Objective-C?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Vinlaen posted:

What are some popular (?) options for developers not wanting to code in Objective-C?

Check the OP.

Yakattak
Dec 17, 2009

I am Grumpypuss
>:3

I feel like its harder to go through all the loops and bounds to not use Objective-C, than it is to learn and use Objective-C.

Small White Dragon
Nov 23, 2007

No relation.

Yakattak posted:

I feel like its harder to go through all the loops and bounds to not use Objective-C, than it is to learn and use Objective-C.
A number of games (especially ports) simply define an AppDelegate and UIView subclass in Objective-C, and then handle everything else in C.

Yakattak
Dec 17, 2009

I am Grumpypuss
>:3

Small White Dragon posted:

A number of games (especially ports) simply define an AppDelegate and UIView subclass in Objective-C, and then handle everything else in C.

Objective-C is a superset so they're close enough. :colbert:

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Yakattak posted:

I feel like its harder to go through all the loops and bounds to not use Objective-C, than it is to learn and use Objective-C.

You can get pretty far learning just enough to translate library calls in the docs to your language of choice. Though I'd argue one's understanding of how to use said libraries benefits enormously from understanding its native and targeted languages.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
Rhetorical question: Why is using iAds together with UITableViewController such a huge PITA, especially given how central table views are to iPhone apps and how heavily Apple pushes you to use UITableViewController?

You can't use header/footer because your app will be rejected (the Ad can't be scrolled offscreen).

You can't subclass UITableViewController or muck with its view hierarchy because it assumes that it's self.view and self.tableView are one and the same (and forces the tableView to take up the available space). Attempting to mess with this will crash or just make the table view invisible.

If you have your view controller inherit from UIViewController instead, you lose a whole bunch of built-in stuff. You have to manually clear selection when the view reappears, manually hook up the delegates, etc... but the biggest one is the view no longer scrolls to make text fields visible when the keyboard comes on-screen. I've searched and searched and there are about 10 different solutions to this problem involving mucking with content insets, moving the table view's origin, etc. All of which have problems (they need intimate knowledge of the table view contents to know when a first responder is activated/deactivated, they don't animate properly like the UITableViewController does, they don't handle all orientations, etc).

I wish I could create my own container view but that is verboten in the current SDK. It really seems like Apple needs a container that handles iAds automatically or needs support for non-scrolling headers/footers in UITableViewController/UITableView.

Zhentar
Sep 28, 2003

Brilliant Master Genius

Ender.uNF posted:

and how heavily Apple pushes you to use UITableViewController?

They do? I must have missed that. The UITableViewController is only like two dozen lines of code worth worth of minor convenience functions to make implementing a simple tableview easy. You really should just stop trying to force it into doing what you want and use a UIViewController regardless of what Apple is pushing.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

Zhentar posted:

They do? I must have missed that. The UITableViewController is only like two dozen lines of code worth worth of minor convenience functions to make implementing a simple tableview easy. You really should just stop trying to force it into doing what you want and use a UIViewController regardless of what Apple is pushing.

Have you tried to duplicate it's keyboard scroll functionality when moving between UITextView cells? Perhaps I'm totally missing something here.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

How would you accomplish a custom view (or whatever it would be called) like the 'downloads' window in Firefox?



Do you have to create a view that procedurally adds all the items like the icon and text labels, or is there an easier way? Are they all held in some sort of existing class?

Adbot
ADBOT LOVES YOU

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Bob Morales posted:

How would you accomplish a custom view (or whatever it would be called) like the 'downloads' window in Firefox?

I'll assume you're just interested in the view part, and none of the possible implementation details.

Well, it's its own window, so I'd start with a subclass of NSWindowController. There's two main parts: the scrollable list of downloads and the little status bar at the bottom. Easiest first: the status bar is just (in order) a label, an NSPathControl, then a standard push button.

For the lits of downloads, I'd use an NSCollectionView. For its Item, the view has an image view (for the icon), two labels (for the filename and done/percentage), then two hyperlink buttons (make your own or grab from e.g. BWToolkit).

This can all be done in nibs, and if you end up using bindings there's very little code that needs to be written at all. I'll go a bit into implementation: have your window controller subclass maintain an array of paths, then plug it into an NSArrayController. Bind the collection view to the array controller, then bind each part of the item view (icon, filename, etc.) to the item itself. Here's where you write a bit of code: implement icon and filename properties on the collection view item that derives their values from the path (make sure to use keyPathsForValuesAffectingValueForKey:) , then implement a couple IBActions for the open and remove links that just hands the path off to NSWorkspace or the array controller.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply