Well, I could probably finish your project in about a half hour and you could download it and everybody would go along their merry way. BUT, where’s the fun and intellectual growth in that, huh?
I’d recommend you look over Apple’s Table View example project.
Thanks, TJ. I want to learn about how this stuff works for future reference. So, I looked around and I put this together. According to Xcode it’s OK.
on awake from nib theObject
set rss_data_source to make new data source at end of data sources with properties {name:"CB.com Feed"}
make new data column at end of data columns of rss_data_source with properties {name:"title"}
make new data column at end of data columns of rss_data_source with properties {name:"link"}
set data source of theObject to rss_data_source
append rss_data_source with usable_record_list
end awake from nib
The problem is, whenever I build the project, it says that it can’t find the file for “-lcrt1.o”, so I can’t find out whether this will work or not. Does anyone know what this means and how I can rectify this problem?
The file name in the error rings no bells for me. Strange.
Try cleaning your targets (Apple-Shift-K) and build again.
As for the code, it looks good to me. A few tips, though:
I’m not sure how forgiving data source names are with dots and such. Since this isn’t going to be visible to the user, I might shorten that to just ‘feed’ or something, just to be sure. Plus, it’ll be easier to type for later use in your app’s code.
Another thing to make sure you check is your column identifiers. Click down into the table view and select each of your two columns. Make sure your identifiers are named the same as the names of your columns when you create them in the code.
So, your identifiers need to be named “title” and “link” exactly as well.
Finally, ensure that you’re addressing (in other parts of your app code) the table view with full object hierarchy. A table view is actually contained within a scroll view, although it isn’t immediately obvious when one first sets it up. In this one handler you’re working with, it shouldn’t be an issue. But it is an easy gotcha’ when addressing your table in other handlers.
You’ve done well to use the ‘append’ command. Technically, you can use a repeat loop to create rows with your data, but append is going to be faster.
Well, I think I’ve finally got it. thanks for all your help. The only
problem now is that I can’t buold the project because it can’t find that “-lcrt1.o” file, which I can;t seem to fix. I reinstalled the Developer tools and updated them, but the problem’s still there. Can someone please give me any possible other solutions? It’s driving me mad!
Here’s the code of my application:
-- CB News Hotline .applescript
-- CB News Hotline
global usable_record_list
on awake from nib theObject
set rss_data_source to make new data source at end of data sources with properties {name:"feed"}
make new data column at end of data columns of rss_data_source with properties {name:"title"}
make new data column at end of data columns of rss_data_source with properties {name:"link"}
set data source of theObject to rss_data_source
append rss_data_source with usable_record_list
end awake from nib
on opened theObject
load_news_feed()
end opened
on load_news_feed()
tell window "main"
start progress indicator "progress_wheel"
end tell
set raw_feed_text to (do shell script "curl [url=http://www.controlbooth.com/backend.php)]http://www.controlbooth.com/backend.php")[/url]
parse_feed(raw_feed_text) of me
set news_record_list to result
delay 1
set raw_feed_text to (do shell script "curl [url=http://www.controlbooth.com/backendforums.php)]http://www.controlbooth.com/backendforums.php")[/url]
parse_feed(raw_feed_text) of me
set forums_record_list to result
set usable_recored_list to (news_record_list & forums_record_list)
tell window "main"
stop progress indicator "progress_wheel"
end tell
end load_news_feed
on parse_feed(some_text)
set feed_item_list to {}
set AppleScript's text item delimiters to "<item>"
set no_header to (text items 2 through -1 of some_text)
set AppleScript's text item delimiters to "<item>"
set no_header2 to (every item in no_header) as string
set some_text_rev1 to "<item>" & no_header2
set AppleScript's text item delimiters to "</item>"
set no_footer to (text items 1 through -2 of some_text_rev1)
set AppleScript's text item delimiters to "</item>"
set no_footer2 to (every text item in no_footer) as string
set some_text_rev2 to (no_footer2 & "</item>")
-- Strip out carriage returns. These aren't useful to us for this purpose.
set AppleScript's text item delimiters to return
set z to (every text item in some_text_rev2)
set AppleScript's text item delimiters to ""
set y_noreturns to (every item in z as string)
set AppleScript's text item delimiters to "</item>"
set cList to every text item in y_noreturns
set AppleScript's text item delimiters to ""
repeat with c in cList
try
set final_item to (text 7 through -1 of c)
set end of feed_item_list to final_item
end try
end repeat
set final_record_list to {}
repeat with f in feed_item_list
set AppleScript's text item delimiters to "</title>"
set feedTitle to text 8 through -1 of (text item 1 of f)
set feedLink_long to (text item 2 of f)
set AppleScript's text item delimiters to "</link>"
set feedLink_short to (text 8 through -1 of text item 1 of feedLink_long)
set AppleScript's text item delimiters to ""
set myFeedRecord to {title:feedTitle, link:feedLink_short}
set end of final_record_list to myFeedRecord
end repeat
return final_record_list
end parse_feed
I’ve created a new project, and still the same thing. Also, I’ve tried building a different, pre-existing one, and the same problem comes up. Here’s the point where it fails:
Does that make any sense to anyone? Is there some specific part of the Developer Tools that I should reinstall? Thanks for any help anyone can give me.
OK, so I’ve reinstalled Xcode 3 times and counting. I really don;t see what more I can do. So, my question is, is there a way to display the list without using Xcode, because that really dosen’t look like it’s going to work out! Any help would be appreciated more then you can imagine. I can’t believe that my machine would simply stop being able to run Xcode, when it used to be able to. Thanks!
OK, so I’ve reinstalled Xcode 3 times and counting. I really don;t see what more I can do. So, my question is, is there a way to display the list without using Xcode, because that really dosen’t look like it’s going to work out! Any help would be appreciated more then you can imagine. I can’t believe that my machine would simply stop being able to run Xcode, when it used to be able to. Thanks!
Like Jon I also use a simple perl script and call it from applescript. This is the perl script I wrote:
here is the applescript code i use to run this perl script:
This will return the headlines themselves in a readable format that you can change. With alittle tweaking this will also return the links to said headlines. You can do something like this:
set thisText to do shell script "curl [url=http://www.controlbooth.com/backend.php]http://www.controlbooth.com/backend.php"[/url]
set feedList to {}
set thisText to extract_between(thisText, "<channel>", "</channel>", false)
repeat
if thisText does not contain "<item>" then exit repeat
set {thisItem, thisText} to extract_between(thisText, "<item>", "</item>", true)
set thisTitle to extract_between(thisItem, "<title>", "</title>", false)
set thisLink to extract_between(thisItem, "<link>", "</link>", false)
set end of feedList to {title:thisTitle, link:thisLink}
end repeat
feedList
on extract_between(thisText, startText, endText, returnRest)
set text item delimiters to startText
set thisText to text items 2 thru -1 of thisText as string
set text item delimiters to endText
if returnRest then return {text item 1 of thisText, text items 2 thru -1 of thisText as string}
text item 1 of thisText
end extract_between