Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
78c554e3
Commit
78c554e3
authored
Oct 20, 2011
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the MacRubySample load a twitter feed by using ASIHTTPRequest and SBJson.
parent
ecbb384d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
18 deletions
+40
-18
AppDelegate.rb
examples/MacRubySample/MacRubySample/AppDelegate.rb
+34
-17
MainMenu.xib
examples/MacRubySample/MacRubySample/en.lproj/MainMenu.xib
+0
-0
Podfile
examples/MacRubySample/Podfile
+1
-1
README
examples/MacRubySample/README
+5
-0
No files found.
examples/MacRubySample/MacRubySample/AppDelegate.rb
View file @
78c554e3
# Load the BridgeSupport metadata generated by CocoaPods from all dependencies.
p
NSBundle
.
mainBundle
.
pathForResource
(
"Pods"
,
ofType
:"bridgesupport"
)
load_bridge_support_file
NSBundle
.
mainBundle
.
pathForResource
(
"Pods"
,
ofType
:"bridgesupport"
)
class
AppDelegate
attr_accessor
:window
URL
=
"http://api.twitter.com/1/statuses/user_timeline.json?screen_name=%s"
attr_accessor
:window
,
:tableView
,
:reloadButton
,
:handleTextField
def
awakeFromNib
@tweets
=
[]
@handleTextField
.
stringValue
=
"alloy"
end
def
applicationDidFinishLaunching
(
notification
)
@queue
=
NSOperationQueue
.
new
refreshData
(
nil
)
end
#NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://gowalla.com/users/mattt.json"]];
#AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
#NSLog(@"Name: %@ %@", [JSON valueForKeyPath:@"first_name"], [JSON valueForKeyPath:@"last_name"]);
#} failure:nil];
def
refreshData
(
sender
)
url
=
NSURL
.
URLWithString
(
URL
%
@handleTextField
.
stringValue
.
strip
)
@handleTextField
.
enabled
=
@reloadButton
.
enabled
=
false
@request
=
ASIHTTPRequest
.
requestWithURL
(
url
)
@request
.
completionBlock
=
lambda
do
puts
"Request completed!"
@tweets
=
@request
.
responseString
.
JSONValue
@tableView
.
reloadData
@handleTextField
.
enabled
=
@reloadButton
.
enabled
=
true
end
@request
.
failedBlock
=
lambda
do
puts
"Request failed :("
puts
@request
.
error
.
localizedDescription
@handleTextField
.
enabled
=
@reloadButton
.
enabled
=
true
end
@request
.
startAsynchronous
end
#NSOperationQueue *queue = [[[NSOperationQueue alloc] init] autorelease];
#[queue addOperation:operation];
def
numberOfRowsInTableView
(
tableView
)
@tweets
.
size
end
def
refreshData
(
sender
)
url
=
NSURL
.
URLWithString
(
"http://api.twitter.com/1/statuses/user_timeline.json?screen_name=alloy"
)
request
=
NSURLRequest
.
requestWithURL
(
url
)
operation
=
AFJSONRequestOperation
.
JSONRequestOperationWithRequest
(
request
,
success
:lambda
{
|
request
,
response
,
json
|
p
json
},
failure
:nil
)
@queue
.
addOperation
(
operation
)
p
@queue
def
tableView
(
tableView
,
objectValueForTableColumn
:column
,
row
:row
)
if
tweet
=
@tweets
[
row
]
tweet
[
'text'
]
end
end
end
examples/MacRubySample/MacRubySample/en.lproj/MainMenu.xib
View file @
78c554e3
This diff is collapsed.
Click to expand it.
examples/MacRubySample/Podfile
View file @
78c554e3
...
...
@@ -3,4 +3,4 @@ platform :osx
generate_bridge_support!
dependency
'ASIHTTPRequest'
dependency
'
CocoaLumberjack
'
dependency
'
SBJson
'
examples/MacRubySample/README
0 → 100644
View file @
78c554e3
This example uses MacRuby which needs Garbage Collection support. Since CocoaPods
does not yet have a way to make a project build with GC support, you will have to
do this manually in the generated Pods.xcodeproj project.
You can find it in the build settings of the target app.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment