Coder Social home page Coder Social logo

ios_practice_project's Introduction

IOS-Pratice-MusicLover

This project finishing the basic IOS Tutorial.

The Music Model:

Properties:

  • var name: String
  • var photo: UIImage?
  • var rating: Int
  • var animatedImage: FLAnimatedImage?
  • var photoURLString: String?
  • var isGif: Bool = false

In my local file and web server file:

Properties:

  • var name: String
  • var rating: Int
  • var photoURLString: String?

Other properties in Music Model, we could using function in the music model to get them

Implementing the bellow requirements:

  1. Basic Tutorial,(Using TableView to arrange the objects, implement the ranking method)
  • Using SDWebImageManager() to manage the image
  • Using UIStackView to actualize the RatingControl
  1. Not only for static image, implement to load/download the "gif" dynamic image.
  • Change the photoImageView to FLAnimatedImageView to actualize display the animated image
  • FLAnimatedImageView using
  1. Implement store data into local file(music.json)
  • In MusicTableViewController.loadMusics() function
  • Using JSONEncoder and JSONDecoder to encode and decode JSON data
  • The File path achieved by
    • static let DocumentsDirectory = FileManager().urls(for: .documentDirectory, in: .userDomainMask).first!
    • static let ArchiveURL = DocumentsDirectory.appendingPathComponent("musics.json")
  1. Implement store data into web server(http://127.0.0.1:8000/musics/)
  • Using Django Rest Framework to implement the web local server
  • In Django/ Folder, is the implement of this server. It's using python language to implement.
  • In MusicTableViewController.getDataFromMockServer() and MusicTableViewController.postDataToMockServer(), achieve the GET method and POST method
  • Attention: don't forget using DispatchQueue.main.async() to asynchronous the self.tableView.reloadData(). This make sure there is something shows in our simulator

Run:

  1. install cocoapod, go to the project folder, run "pod install"

  2. start the server, do bellow comands in terminal

    install python and virtualenv

    Go to Django folder

    virtual -p /usr/local/bin/python3 venv

    source venv/bin/activate

    pip install Django

    sudo easy_install pip

    touch requirements.txt

    pip freeze > requirements.txt

    django-admin startproject config

    pip install djangorestframework

    go to /config/config/settings.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # Ensure a comma ends this line 'rest_framework', # Add this line ]

    cd into the folder where manage.py file is, python3 manage.py startapp api INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'api', # Add this line ]

    I have already finishing the model, view, and url part, if don't change it, go! cd into the manage.py file,

    python3 manage.py makemigrations

    python3 manage,py migrate

    without error, run the server!

    python3 manage.py runserver

  3. After setting the server, run the project in MusicLover.xcworkspace

  4. Could Add/Delete/Save object, for web server, could check it through open the url link(http://127.0.0.1:8000/musics/), for local server, uncommand the line under "load data local", and command the line under "load data by url server"

reference link: https://scotch.io/tutorials/build-a-rest-api-with-django-a-test-driven-approach-part-1

ios_practice_project's People

Contributors

dependabot[bot] avatar hevawu avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.