foursquare / fsnetworking Goto Github PK
View Code? Open in Web Editor NEWfoursquare iOS networking library
License: Apache License 2.0
foursquare iOS networking library
License: Apache License 2.0
Hello
i am trying to add many upload requests to a "queue".
in your example you do:
self.connection = [self makeConnection];
[self.connection start];
i have 2 questions:
1st -> how can i upload many requests to a single queue?
2nd -> how can i cancel a specific one from the queue?
thanks a lot
I don't know if its supported, but it seems to work. Mostly.
In FSNConnection, there is the mutableset of current connections.
mutableConnections
It is a NSMutableSet and is a global, but accessed by eac h object with no @synchronize() {} block.
So the code need to change in two places -
In cleanup
NSMutableSet *requests = [self.class mutableConnections];
@synchronized(requests) {
[requests removeObject:self];
}
And in start
NSMutableSet *connections = [self.class mutableConnections];
@synchronized(connections) {
[connections addObject:self];
}
I got a crash (as would make sense) when using about 3 of these on threads on 10.8.4 Mac, with XCode 5. With Zombies and what not on, it pointed right at the cleanup line.
--Tom
Hi I experience some problems with [self.connection cancel]
in the dealloc
method. I have a feeling it sometimes also cancel other ongoing request in the queue. Is this possible ? I have experimented both with and without FSN_QUEUED_CONNECTIONS.
- (void)dealloc {
NSAssert(!self.connection, @"non-nil connection: %@", self.connection);
#if TARGET_OS_IPHONE
// if this task was set to run in background then the expiration handler should be retaining self
NSAssert1(self.taskIdentifier == UIBackgroundTaskInvalid,
@"deallocated request has background task identifier: %@", self);
#endif
[self clearBlocks]; // not cleanup; assert no taskIdentifer above instead
// just to be safe in production
FSNVerbose(@"%p: dealloc", self);
[self.connection cancel];
}
I am adding a few things to FSNData, and I would like to know the why straight C code was used for NSString *stringForMimeType(MimeType type);
over a class level method. Is it a preferred style, or some other reason?
Hi guys,
i went back in this problem, basically we can't post NSArray as params, so, i thought to create an NSMutableDictionary variable, and dynamically putting in it all my params, creating subarray, like this 'params[object][][field1]' and so on. But my problem is that him is overwriting always the same value, not creating subarray. 👎
i tried to create params like this: [NSString stringWithFormat:@"supply[%i][description]", i], but is really ugly.
any better ideas to solve this problem? any workaround much better?
thanks guys.
I am trying to integrate FSNetworking into my application. When I debug [FSNConnection start]
, I see the URL is invalid and I get the error "message sent to deallocated instance." When printed, I get:
(lldb)po self.url (NSURL *) $4 = 0x07e81150 [no Objective-C description available]
. The NSAssert(self.url, @"nil url")
passes, I am guessing this is a dangling pointer.
My project is compiled with ARC enabled, and I set -fno-objc-arc as suggested in the readme file.
Send NSArray/NSMutableArray as parameters as well, not just NSString or NSNumber or FSNData, thanks for that guys.
I’ve recently added FSNetworking to the CocoaPods package manager repo.
CocoaPods is a tool for managing dependencies for OS X and iOS Xcode projects and provides a central repository for iOS/OS X libraries. This makes adding libraries to a project and updating them extremely easy and it will help users to resolve dependencies of the libraries they use.
However, FSNetworking doesn't have any version tags. I’ve added the current HEAD as version 0.0.1, but a version tag will make dependency resolution much easier.
Semantic version tags (instead of plain commit hashes/revisions) allow for resolution of cross-dependencies.
In case you didn’t know this yet; you can tag the current HEAD as, for instance, version 1.0.0, like so:
$ git tag -a 1.0.0 -m "Tag release 1.0.0"
$ git push --tags
--Mistakenly opened this under wrong project, please remove--
Is there a default value? I skimmed the source, but couldn't find any instance of "timeout".
Since not too much activity in FSNetworking, probably using AFNetworking with better support a better idea
failWithError: is not designed to be called more than once, but in our case it is sometimes called twice: when the internet connectivity dies, and when UIApplication decides to run 'fireExpirationHandler'.
Presumably, 'endBackgroundTask' should prevent this from happening, but the first time failWithError: is called, 'complete' is enqueued on the run loop, and may be called only after the second call to failWithError:. Hence the race condition.
Along with this method:
// convenience method to ensure that top-level json object is a dictionary
- (id)dictionaryFromJSONWithError:(NSError **)error; // error pointer must not be nil
it would be really great if you provide arrayFromJSONWithError
that internally calls this one and returns NSArray
of NSDictionary
instances from JSON, that would be good. I guess you also have such a need in 4sq API. Am I missing an obvious workaround?
Thanks.
There is stuff accumulating in my fork that i would like to see upstream; most recently I did a small refactor of adam's isAcceptableValue changes and he asked me to open an issue. It is all very straightforward stuff.
My change set does not fix the missing NSArray urlEncodedString implementation, but it does add one for NSNumber that replaces the old inlined conditional logic.
Thanks! -g
My backend has a DELETE endpoint. What needs to be changed for this library to support DELETE requests?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.