我正在使用retrofit 2.0,我正在我的Android应用程序中实现删除功能,但是,我无法成功,有人可以给我一个建议吗?
我试过两个:
@DELETE("books/{id}") void deleteBook(@Path("id") int itemId);
@DELETE("books/{id}") void deleteBook(@Path("id") int bookId, Callback<Response> callback);
Run Code Online (Sandbox Code Playgroud)
我得到错误java.lang.IllegalArgumentException:服务方法不能返回void.方法LibraryService.deleteBook.
我也尝试过这个:
Response deleteBook(@Path("id") int bookId);
Run Code Online (Sandbox Code Playgroud)
Call<Response> deleteBook(@Path("id") int bookId);
无论我使用okhttp3.Response还是retrofit2.Response,我都会收到错误:'*.Response'不是有效的响应体类型.你的意思是ResponseBody?
有人可以给我一个成功的删除示例吗?我在网上搜索但找不到足够的信息.非常感谢.
我有一个将生成框架的项目.我的架构设置是:
有效架构:armv7,arm64,i386.
在iOS 8.4中,我可以毫无问题地成功构建它.但是,当我更新到iOS 9时,我收到"不支持的架构"错误.看起来不支持i386,我该如何制作可以在模拟器中使用的框架?
这是错误消息:
CompileC build/iDock.build/Debug-iphoneos/iDock.build/Objects-normal/i386/iDockControl.o iDock/iDockControl.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/leon/Documents/Jul-27/iDock
export LANG=en_US.US-ASCII
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/local/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/local/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/local/bin:/Applications/Xcode.app/Contents/Developer/Tools:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-x objective-c -arch i386 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/var/folders/cy/52qx8n5j5qqfd4g4hsm9t1140000gn/C/com.apple.DeveloperTools/7.0-7A220/Xcode/ModuleCache/Session.modulevalidation
-fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wunreachable-code -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DDEBUG=1 -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -isysroot …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Retrofit 2.0 来实现一个图书馆系统。可以添加书籍,列出所有书籍信息,列出一本书信息,删除一本书,删除所有书籍,更新一本书信息。
我的 baseURL 末尾有一个“ / ”:
http://www.example.com/webservice/
Run Code Online (Sandbox Code Playgroud)
前三个功能非常有效:
@GET("books")
Call<ArrayList<Book>> listBooks();
@POST("books")
Call<Book> addBook(@Body Book book);
@GET("books/{id}")
Call<Book> getBookInfo(@Path("id") int bookId);
Run Code Online (Sandbox Code Playgroud)
但是,这三个根本不起作用:
@DELETE("books/{id}")
Call<Void> deleteBook(@Path("id") int bookId);
@PUT("books/{id}")
Call<Book> updateBook(@Path("id") int bookId , @Body Book book);
@DELETE("clean")
Call<Void> deleteAll();
Run Code Online (Sandbox Code Playgroud)
例如,这是我的 deleteBook 功能:
Gson gson = new GsonBuilder()
.setDateFormat(Constant.DATE_FORMAT)
.create();
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Constant.BASE_URL)
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
LibraryService libraryServiceAPI = retrofit.create(LibraryService.class);
Call<Void> deleteBookCall = libraryServiceAPI.deleteBook(bookId);
deleteBookCall.enqueue(new Callback<Void>() {
@Override
public void onResponse(Call<Void> call, Response<Void> response) {
if …Run Code Online (Sandbox Code Playgroud) 我正在使用CocoaLumberjack V2.4将日志保存到文件中.
这是将保存日志设置为文件的默认代码:
DDFileLogger *fileLogger = [[DDFileLogger alloc] init]; // File Logger
fileLogger.rollingFrequency = 60 * 60 * 24; // 24 hour rolling
fileLogger.logFileManager.maximumNumberOfLogFiles = 7;
[DDLog addLogger:fileLogger];
Run Code Online (Sandbox Code Playgroud)
日志保存在默认位置:/ AppData/Library/Caches/Logs /
我希望实现一个API来手动删除保存的日志.我检查他们有手动清除日志作为那里的公开问题.有人有建议吗?
android ×2
ios ×2
java ×2
retrofit ×2
retrofit2 ×2
frameworks ×1
http-delete ×1
i386 ×1
logging ×1
objective-c ×1
simulator ×1
xcode ×1